Examples of MimeType


Examples of javax.activation.MimeType

    return getHeader("Slug");
  }

  public MimeType getContentType() throws MimeTypeParseException {
    String value = getHeader("Content-Type");
    return (value != null) ? new MimeType(value) : null;
  }
View Full Code Here

Examples of javax.activation.MimeType

  }

  @Override
  public MimeType getContentType()
    throws MimeTypeParseException {
      MimeType t = super.getContentType();
      if (t == null) {
        String type = MimeTypeHelper.getMimeType(base);
        if (type != null) t = new MimeType(type);
      }
      return t;
  }
View Full Code Here

Examples of javax.activation.MimeType

    private final MimeType mimeTypeApplicationZip;
    private final MimeType mimeTypeApplicationJson;

    public DeveloperUtilitiesServiceDefault() {
        try {
            mimeTypeTextCsv = new MimeType("text", "csv");
            mimeTypeApplicationJson = new MimeType("application", "jzon");
            mimeTypeApplicationZip = new MimeType("application", "zip");
        } catch (MimeTypeParseException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

Examples of javax.activation.MimeType

        case COLLECTION:
        try {
          if (MimeTypeHelper.isMatch(
            request.getContentType(),
            "application/atom+xml")) {
            MimeType type = new MimeType(request.getContentType());
            String charset = type.getParameter("charset");
            String uri = AppTest.INSTANCE.getBase() + "/collections/entries";
            ParserOptions options = getParser().getDefaultParserOptions();
            options.setCharset(charset);
            Document doc = getParser().parse(request.getInputStream(), uri, options);
            if (doc.getRoot() instanceof Entry) {
View Full Code Here

Examples of javax.activation.MimeType

        switch(t) {
          case ENTRY:
            try {
              if (MimeTypeHelper.isMatch(request.getContentType(), "application/atom+xml")) {
                Entry entry = feed.getRoot().getEntries().get(target);
                MimeType type = new MimeType(request.getContentType());
                String charset = type.getParameter("charset");
                String uri = AppTest.INSTANCE.getBase() + "/collections/entries/" + target;
                ParserOptions options = getParser().getDefaultParserOptions();
                options.setCharset(charset);
                Document doc = getParser().parse(request.getInputStream(), uri, options);
                if (doc.getRoot() instanceof Entry) {
View Full Code Here

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

Examples of javax.activation.MimeType

    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

Examples of javax.activation.MimeType

    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

Examples of javax.activation.MimeType

  /**
   * 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);
      if (isMatch(mta,mtb)) {
        String type = mta.getParameter("type");
        return (type != null && type.equalsIgnoreCase("entry"));
      }
    } catch (Exception e) {}
View Full Code Here

Examples of javax.activation.MimeType

  /**
   * 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);
      if (isMatch(mta,mtb)) {
        String type = mta.getParameter("type");
        return (type != null && type.equalsIgnoreCase("feed"));
      }
    } catch (Exception e) {}
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.