Package javax.activation

Examples of javax.activation.MimeType


  
  private static final MimeType WILDCARD = createWildcard();
 
  private static MimeType createWildcard() {
    try {
      return new MimeType("*/*");
    } catch (Exception e) {
      return null; // Won't happen
    }
  }
View Full Code Here


    if ((a == null || a.length() == 0) &&
        (b == null || b.length() == 0))
          return true;
    boolean answer = false;
    try {
      MimeType mta = new MimeType(a);
      MimeType mtb = new MimeType(b);
      return isMatch(mta,mtb);
    } catch (Exception e) {}
    return answer;
  }
View Full Code Here

    try {
      if (a == null || b == null) return true;
      if (a.match(b)) return true;
      if (a.equals(WILDCARD)) return true;
      if (a.getPrimaryType().equals("*")) {
        MimeType c = new MimeType(b.getPrimaryType(), a.getSubType());
        return c.match(b);
      }
      if (b.getPrimaryType().equals("*")) {
        MimeType c = new MimeType(a.getPrimaryType(), b.getSubType());
        return c.match(a);
      }
    } catch (Exception e) {}
    return false;
  }
View Full Code Here

  }
 
  public MimeType getContentType() {
    try {
      String value = getHeader("Content-Type");
      return (value != null) ? new MimeType(value) : null;
    } catch (javax.activation.MimeTypeParseException e) {
      throw new org.apache.abdera.util.MimeTypeParseException(e);
    }
  }
View Full Code Here

  
  private static final MimeType WILDCARD = createWildcard();
 
  public static String getCharset(String mediatype) {
    try {
      MimeType mt = new MimeType(mediatype);
      return mt.getParameter("charset");
    } catch (Exception e) {
      return null;
    }
  }
View Full Code Here

    }
  }
 
  private static MimeType createWildcard() {
    try {
      return new MimeType("*/*");
    } catch (Exception e) {
      return null; // Won't happen
    }
  }
View Full Code Here

    if ((a == null || a.length() == 0) &&
        (b == null || b.length() == 0))
          return true;
    boolean answer = false;
    try {
      MimeType mta = new MimeType(a.toLowerCase());
      MimeType mtb = new MimeType(b.toLowerCase());
      return isMatch(mta,mtb);
    } catch (Exception e) {}
    return answer;
 
View Full Code Here

          return answer;
        } else return true;
      }
      if (a.equals(WILDCARD)) return true;
      if (a.getPrimaryType().equals("*")) {
        MimeType c = new MimeType(b.getPrimaryType(), a.getSubType());
        return isMatch(c,b);
      }
      if (b.getPrimaryType().equals("*")) {
        MimeType c = new MimeType(a.getPrimaryType(), b.getSubType());
        return isMatch(a,c);
      }
    } catch (Exception e) {}
    return false;
  }
View Full Code Here

  /**
   * Returns true if media type a specifically identifies an Atom entry document
   */
  public static boolean isEntry(String a) {
    try {
      MimeType mta = new MimeType(a.toLowerCase());
      MimeType mtb = new MimeType(Constants.ATOM_MEDIA_TYPE);
      MimeType mtc = new MimeType(Constants.ENTRY_MEDIA_TYPE);
      return isMatch(mta, mtc) || (isMatch(mta, mtb) && isMatchType(mta.getParameter("type"), "entry"));     
    } catch (Exception e) {}
    return false;
  }
View Full Code Here

  /**
   * Returns true if media type a explicitly identifies an Atom feed document
   */
  public static boolean isFeed(String a) {
    try {
      MimeType mta = new MimeType(a.toLowerCase());
      MimeType mtb = new MimeType(Constants.ATOM_MEDIA_TYPE);
      MimeType mtc = new MimeType(Constants.FEED_MEDIA_TYPE);
      return isMatch(mta, mtc) || (isMatch(mta, mtb) && isMatchType(mta.getParameter("type"), "feed"));
    } catch (Exception e) {}
    return false;
  }
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.