public static Charset getCharsetDefault(final ContentType type) { return type != null? (type.getCharset() != null? type.getCharset(): DEFAULT_CHARSET) : DEFAULT_CHARSET; }
public static org.apache.http.entity.ContentType getContentType( org.wiztools.restclient.bean.ContentType ct) { return ContentType.create(ct.getContentType(), ct.getCharset()); } }
@Override public void setContentTypeCharset(ContentType contentType) { if(contentType != null) { setContentTypeCharset(contentType.getContentType(), contentType.getCharset()); } }
private static void addContentTypeCharsetAttribute(ContentType c, Element e) { if(c != null) { e.addAttribute(new Attribute("content-type", c.getContentType())); if(c.getCharset() != null) { e.addAttribute(new Attribute("charset", c.getCharset().name())); } } } }
public static String getFormattedContentType(final ContentType contentType){ return getFormattedContentType(contentType.getContentType(), contentType.getCharset()); }
public void setContentType(ContentType contentType) { setContentTypeCharset(contentType.getContentType(), contentType.getCharset()); }
static AbstractHttpEntity getEntity(ReqEntitySimple bean) throws UnsupportedEncodingException, IOException { AbstractHttpEntity entity = null; ContentType contentType = null; if (bean.getContentType() != null) { org.wiztools.restclient.bean.ContentType ct = bean.getContentType(); contentType = ContentType.create(ct.getContentType(), ct.getCharset()); } if (bean instanceof ReqEntityString) { entity = new StringEntity(((ReqEntityString) bean).getBody(), contentType); } else if (bean instanceof ReqEntityByteArray) { entity = new ByteArrayEntity(((ReqEntityByteArray) bean).getBody(), contentType); } else if (bean instanceof ReqEntityStream) { entity = new InputStreamEntity(((ReqEntityStream) bean).getBody(), ((ReqEntityStream) bean).getLength(), contentType); } else if (bean instanceof ReqEntityFile) { entity = new FileEntity(((ReqEntityFile) bean).getBody(), contentType); } return entity; }