private boolean isXmlType(String type) { try { ContentType ct = new ContentType(type); return ct.getSubType().equals("xml") && (ct.getPrimaryType().equals("text") || ct.getPrimaryType().equals("application")); } catch (ParseException ex) { return false; } catch (RuntimeException ex) { return false; } } }
private boolean isXmlType(String type) { try { ContentType ct = new ContentType(type); return ct.getSubType().equals("xml") && (ct.getPrimaryType().equals("text") || ct.getPrimaryType().equals("application")); } catch (ParseException ex) { return false; } catch (RuntimeException ex) { return false; } } }
return false; String sType = cType.getSubType();
return false; String sType = cType.getSubType();
private boolean isXmlType(String type) { try { ContentType ct = new ContentType(type); return ct.getSubType().equals("xml") && (ct.getPrimaryType().equals("text") || ct.getPrimaryType().equals("application")); } catch (ParseException ex) { return false; } catch (RuntimeException ex) { return false; } } }
private boolean isXmlType(String type) { try { ContentType ct = new ContentType(type); return ct.getSubType().equals("xml") && (ct.getPrimaryType().equals("text") || ct.getPrimaryType().equals("application")); } catch (Exception ex) { return false; } } }
return false; String sType = cType.getSubType();
private boolean isXmlType(String type) { try { ContentType ct = new ContentType(type); return ct.getSubType().equals("xml") && (ct.getPrimaryType().equals("text") || ct.getPrimaryType().equals("application")); } catch (ParseException ex) { return false; } catch (RuntimeException ex) { return false; } } }
private boolean isXmlType(String type) { try { ContentType ct = new ContentType(type); return ct.getSubType().equals("xml") && (ct.getPrimaryType().equals("text") || ct.getPrimaryType().equals("application")); } catch (ParseException ex) { return false; } catch (RuntimeException ex) { return false; } } }
private boolean isXmlType(String type) { try { ContentType ct = new ContentType(type); return ct.getSubType().equals("xml") && (ct.getPrimaryType().equals("text") || ct.getPrimaryType().equals("application")); } catch (ParseException ex) { return false; } catch (RuntimeException ex) { return false; } } }
private boolean isXmlType(String type) { try { ContentType ct = new ContentType(type); return ct.getSubType().equals("xml") && (ct.getPrimaryType().equals("text") || ct.getPrimaryType().equals("application")); } catch (ParseException ex) { return false; } catch (RuntimeException ex) { return false; } } }
/** * Extracts the subtype from a content type * * @param contentType the content type * @return subtype of the content type. */ private static String getContentTypeSubType(String contentType) { final ContentType contentTypeValue; try { contentTypeValue = new ContentType(contentType); return contentTypeValue.getSubType(); } catch (ParseException e) { throw new MuleRuntimeException(e); } }
/** * Extracts the subtype from a content type * * @param contentType the content type * @return subtype of the content type. */ public static String getContentTypeSubType(String contentType) { final ContentType contentTypeValue; try { contentTypeValue = new ContentType(contentType); return contentTypeValue.getSubType(); } catch (ParseException e) { throw new MuleRuntimeException(e); } }
public static ContentType removeCharset(ContentType contentType) { ParameterList orgParamList = contentType.getParameterList(); ParameterList paramList = new ParameterList(); for (Enumeration<?> e = orgParamList.getNames(); e.hasMoreElements(); ) { String name = (String)e.nextElement(); if (!name.equalsIgnoreCase("charset")) { paramList.set(name, orgParamList.get(name)); } } return new ContentType(contentType.getPrimaryType(), contentType.getSubType(), paramList); } }
public static ContentType removeCharset(ContentType contentType) { ParameterList orgParamList = contentType.getParameterList(); ParameterList paramList = new ParameterList(); for (Enumeration<?> e = orgParamList.getNames(); e.hasMoreElements(); ) { String name = (String)e.nextElement(); if (!name.equalsIgnoreCase("charset")) { paramList.set(name, orgParamList.get(name)); } } return new ContentType(contentType.getPrimaryType(), contentType.getSubType(), paramList); } }
public static ContentType addCharset(ContentType contentType, String charset) { ParameterList orgParamList = contentType.getParameterList(); ParameterList paramList = new ParameterList(); if (orgParamList != null) { for (Enumeration<?> e = orgParamList.getNames(); e.hasMoreElements(); ) { String name = (String)e.nextElement(); paramList.set(name, orgParamList.get(name)); } } paramList.set("charset", charset); return new ContentType(contentType.getPrimaryType(), contentType.getSubType(), paramList); }
public static ContentType addCharset(ContentType contentType, String charset) { ParameterList orgParamList = contentType.getParameterList(); ParameterList paramList = new ParameterList(); if (orgParamList != null) { for (Enumeration<?> e = orgParamList.getNames(); e.hasMoreElements(); ) { String name = (String)e.nextElement(); paramList.set(name, orgParamList.get(name)); } } paramList.set("charset", charset); return new ContentType(contentType.getPrimaryType(), contentType.getSubType(), paramList); }
private void updateContentType(boolean cleanDefaultRoot) throws MessagingException { BodyPart part = null; if (rootId == null) { part = getBodyPart(0); } else { part = getBodyPart(rootId); if (part == null) { if (cleanDefaultRoot) rootId = null; else throw new MessagingException("Can not set root: " + rootId + ": not found"); } } if (part != null) { String primaryType = baseContentTypeObject.getPrimaryType(); String subType = baseContentTypeObject.getSubType(); ParameterList params = baseContentTypeObject.getParameterList(); ContentType newContentType = new ContentType(primaryType, subType, params); ContentType rootContentType = new ContentType(part.getDataHandler().getContentType()); newContentType.setParameter("type", rootContentType.getBaseType()); if (rootId != null) newContentType.setParameter("start", rootId); contentType = newContentType.toString(); } }
private void updateContentType(boolean cleanDefaultRoot) throws MessagingException { BodyPart part = null; if (rootId == null) { part = getBodyPart(0); } else { part = getBodyPart(rootId); if (part == null) { if (cleanDefaultRoot) rootId = null; else throw new MessagingException("Can not set root: " + rootId + ": not found"); } } if (part != null) { String primaryType = baseContentTypeObject.getPrimaryType(); String subType = baseContentTypeObject.getSubType(); ParameterList params = baseContentTypeObject.getParameterList(); ContentType newContentType = new ContentType(primaryType, subType, params); ContentType rootContentType = new ContentType(part.getDataHandler().getContentType()); newContentType.setParameter("type", rootContentType.getBaseType()); if (rootId != null) newContentType.setParameter("start", stripBrackets(rootId)); contentType = newContentType.toString(); } }
private void updateContentType(boolean cleanDefaultRoot) throws MessagingException { BodyPart part = null; if (rootId == null) { part = getBodyPart(0); } else { part = getBodyPart(rootId); if (part == null) { if (cleanDefaultRoot) rootId = null; else throw new MessagingException("Can not set root: " + rootId + ": not found"); } } if (part != null) { String primaryType = baseContentTypeObject.getPrimaryType(); String subType = baseContentTypeObject.getSubType(); ParameterList params = baseContentTypeObject.getParameterList(); ContentType newContentType = new ContentType(primaryType, subType, params); ContentType rootContentType = new ContentType(part.getDataHandler().getContentType()); newContentType.setParameter("type", rootContentType.getBaseType()); if (rootId != null) newContentType.setParameter("start", stripBrackets(rootId)); contentType = newContentType.toString(); } }