Package javax.activation

Examples of javax.activation.MimeType


   */
  public static boolean isXml(String a) {
    boolean answer = isMatch(Constants.XML_MEDIA_TYPE, a) || isMatch("text/xml", a);
    if (!answer) {
      try {
        MimeType mta = new MimeType(a);
        answer =
          (("application".equalsIgnoreCase(mta.getPrimaryType()) ||
            "text".equalsIgnoreCase(mta.getPrimaryType())) &&
            mta.getSubType().equals("xml") ||
            mta.getSubType().endsWith("+xml"));
      } catch (Exception e) {}
    }
    return answer;
  }
View Full Code Here


   * Returns true if this is a valid media type
   */
  public static boolean isMimeType(String a) {
    boolean answer = false;
    try {
      new MimeType(a);
      answer = true;
    } catch (MimeTypeParseException e) {
      answer = false;
    }
    return answer;
View Full Code Here

   */
  public static <T extends Base>String getMimeType(T base) {
    String type = null;
    if (base instanceof Document) {
      Document doc = (Document)base;
      MimeType mt = doc.getContentType();
      type = (mt != null) ? mt.toString() : getMimeType(doc.getRoot());
    } else if (base instanceof Element) {
      Element el = (Element)base;
      if (el.getDocument() != null) {
        MimeType mt = el.getDocument().getContentType();
        type = (mt != null) ? mt.toString() : null;
      }
      if (type == null) {
        if (el instanceof Feed || el instanceof Entry)
          type = Constants.ATOM_MEDIA_TYPE;
        else if (el instanceof Service)
View Full Code Here

  /**
   * Compare two media types according to their relative level of specificity
   */
  public static int compare(String t1, String t2) {
    try {
      MimeType mt1 = new MimeType(t1);
      MimeType mt2 = new MimeType(t2);
      return compare(mt1,mt2);
    } catch (Exception e) {}
    return 0;
  }
View Full Code Here

    List<Link> links,
    String type,
    String hreflang)
      throws MimeTypeParseException {
    for (Link link : links) {
      MimeType mt = link.getMimeType();
      boolean typematch = 
        MimeTypeHelper.isMatch(
          (mt != null) ? mt.toString() : null, type);
      boolean langmatch =
        "*".equals(hreflang) ||
        ((hreflang != null) ?
          hreflang.equals(link.getHrefLang()) :
          link.getHrefLang() == null);
View Full Code Here

    return (href != null) ? new IRI(href) : null;
  }

  public MimeType getMimeType() throws MimeTypeParseException {
    String type = getAttributeValue("type");
    return (type != null) ? new MimeType(type) : null;
  }
View Full Code Here

      removeAttribute(new QName("filesize"));
  }
 
  public MimeType getType() throws MimeTypeParseException {
    String type = getAttributeValue("type");
    return (type != null) ? new MimeType(type) : null;
  }
View Full Code Here

    setAttributeValue(REL, rel);
  }

  public MimeType getMimeType() throws MimeTypeParseException {
    String type = getAttributeValue(TYPE);
    return (type != null) ? new MimeType(type) : null;
  }
View Full Code Here

    setAttributeValue(TYPE, (type != null) ? type.toString() : null);
  }

  public void setMimeType(String type) throws MimeTypeParseException {
    if (type != null)
      setAttributeValue(TYPE, (new MimeType(type)).toString());
    else
      removeAttribute(TYPE);
  }
View Full Code Here

      _removeAllChildren();
    }
  }

  public MimeType getMimeType() {
    MimeType type = null;
    String mimeType = getAttributeValue(TYPE);
    if (mimeType != null) {
      try {
        type = new MimeType(mimeType);
      } catch (Exception e) {}
    }
    return type;
  }
View Full Code Here

TOP

Related Classes of javax.activation.MimeType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.