Package javax.activation

Examples of javax.activation.MimeType


  }

  @Override
  public MimeType getContentType() {
    try {
      MimeType t = super.getContentType();
      if (t == null) {
        String type = MimeTypeHelper.getMimeType(base);
        if (type != null) t = new MimeType(type);
      }
      return t;
    } catch (javax.activation.MimeTypeParseException e) {
      throw new org.apache.abdera.util.MimeTypeParseException(e);
    }
View Full Code Here


    String[] methods) {
      return (java.util.Arrays.binarySearch(methods, request.getMethod()) >= 0);
  }
 
  public static boolean isAtom(RequestContext request) {
    MimeType mt = request.getContentType();
    String ctype = (mt != null) ? mt.toString() : null;
    return ctype != null && MimeTypeHelper.isAtom(ctype);
  }
View Full Code Here

    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

            @Test
            public void happyCase() throws Exception {

                byte[] bytes = "{\"foo\": \"bar\"}".getBytes(Charset.forName("UTF-8"));
                final Blob newAttachment = new Blob("myfile.json", new MimeType("application/json"), bytes);

                // when
                toDoItem.setAttachment(newAttachment);

                // then
View Full Code Here

        final String name  = data.substring(0, colonIdx);
        final int colon2Idx  = data.indexOf(":", colonIdx+1);
        final String mimeTypeBase = data.substring(colonIdx+1, colon2Idx);
        final byte[] bytes = Base64.decodeBase64(data.substring(colon2Idx+1));
        try {
            return new Blob(name, new MimeType(mimeTypeBase), bytes);
        } catch (MimeTypeParseException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

        if(!(object instanceof Blob)) {
            return null;
        }
       
        final Blob blob = (Blob)object;
        final MimeType mimeType = blob.getMimeType();
        if(mimeType == null || !mimeType.getPrimaryType().equals("image")) {
            return null;
        }
       
        final BufferedImage image = asBufferedImage(blob);
        if(image == null) {
View Full Code Here

        final String name  = data.substring(0, colonIdx);
        final int colon2Idx  = data.indexOf(":", colonIdx+1);
        final String mimeTypeBase = data.substring(colonIdx+1, colon2Idx);
        final CharSequence chars = data.substring(colon2Idx+1);
        try {
            return new Clob(name, new MimeType(mimeTypeBase), chars);
        } catch (MimeTypeParseException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

     *
     * @param mimeType  the MIME type
     * @return    true if the same MIME type
     */
    public boolean isMimeTypeEqual(String mimeType) {
  MimeType mt = null;
  try {
      if (mimeObject == null)
    mimeObject = new MimeType(this.mimeType);
      mt = new MimeType(mimeType);
  } catch (MimeTypeParseException e) {}

  return mimeObject.match(mt);
    }
View Full Code Here

  }
 
  public MimeType getType() {
    try {
      String type = getAttributeValue("type");
      return (type != null) ? new MimeType(type) : null;
    } catch (javax.activation.MimeTypeParseException e) {
      throw new org.apache.abdera.util.MimeTypeParseException(e);
    }
  }
View Full Code Here

  public MimeType getContentType() {
    return contentType;
  }
 
  public void setContentType(String contentType) throws MimeTypeParseException {
    this.contentType = new MimeType(contentType);
    if (this.contentType.getParameter("charset") != null)
      setCharset(this.contentType.getParameter("charset"));
  }
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.