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()); } }
public static String getFormattedContentType(final ContentType contentType){ return getFormattedContentType(contentType.getContentType(), contentType.getCharset()); }
public void setContentType(ContentType contentType) { setContentTypeCharset(contentType.getContentType(), contentType.getCharset()); }
@Override public void setBody(byte[] body, ContentType type) { // Call super: super.setBody(body, type); // Display the new body: if(type != null && StringUtil.isNotEmpty(type.getContentType())) { if(HttpUtil.isTextContentType(type.getContentType())) { jp_text.setBody(body, type); jsp.setViewportView(jp_text); } else if(HttpUtil.isWebImageContentType(type.getContentType())) { jp_image.setBody(body, type); jsp.setViewportView(jp_image); } else { setBinaryBody(); } } else { setBinaryBody(); } }
final String mime = FileUtil.getMimeType(file); if(!mime.equals("content/unknown")) { final String origContentType = jp_content_type_charset.getContentType().getContentType(); if(!mime.equals(origContentType)) { final int result = JOptionPane.showConfirmDialog(parent,
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())); } } } }
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; }
final String origContentType = jp_content_type_charset.getContentType().getContentType(); if(!mime.equals(origContentType)) { final int result = JOptionPane.showConfirmDialog(rest_ui.getFrame(),
final boolean isXml = HttpUtil.isXmlContentType(type.getContentType()); final boolean isJson = HttpUtil.isJsonContentType(type.getContentType()); final boolean isHTML = HttpUtil.isHTMLContentType(type.getContentType()); se_response.setSyntax(TextEditorSyntax.JSON); if(HttpUtil.isJsContentType(type.getContentType())) { se_response.setSyntax(TextEditorSyntax.JS); if(HttpUtil.isCssContentType(type.getContentType())) { se_response.setSyntax(TextEditorSyntax.CSS);