Package javax.activation

Examples of javax.activation.MimeType


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


  public DataHandler getDataHandler() {
    if (!Type.MEDIA.equals(type))
      throw new UnsupportedOperationException(
        "Only supported on media content entries");
    MimeType type = getMimeType();
    java.net.URL src = null;
    try {
      src = getSrc().toURL();
    } catch (Exception e) {}
    DataHandler dh = null;
    if (src == null) {
      dh = (DataHandler)DataHandlerUtils.getDataHandlerFromText(
        getText(), (type != null) ? type.toString() : null);
    } else {
      dh = new DataHandler(new URLDataSource(src));
    }
    return dh;
  }
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

    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

      }
     
      Entry orig_entry = getEntryFromCollectionProvider(entryObj, new IRI(getFeedIriForEntry(entryObj, request)), request);
      if (orig_entry != null) {

        MimeType contentType = request.getContentType();
        if (contentType != null && !MimeTypeHelper.isAtom(contentType.toString()))
          return new EmptyResponseContext(415);

        Entry entry = getEntryFromRequest(request);
        if (entry != null) {
          if (!entry.getId().equals(orig_entry.getId()))
View Full Code Here

 
  private ResponseContext createOrUpdateEntry(
    RequestContext request,
    boolean createFlag) {
      try {
        MimeType mimeType = request.getContentType();
        String contentType = mimeType == null ? null : mimeType.toString();
        if (contentType != null &&
            !MimeTypeHelper.isAtom(contentType) &&
            !MimeTypeHelper.isXml(contentType))
          return ProviderHelper.notsupported(request);
        Abdera abdera = request.getAbdera();
View Full Code Here

      long cl = context.getContentLength();
      String cc = context.getCacheControl();
      if (cl > -1) response.setHeader("Content-Length", Long.toString(cl));
      if (cc != null && cc.length() > 0) response.setHeader("Cache-Control",cc);
      try {
        MimeType ct = context.getContentType();
        if (ct != null) response.setContentType(ct.toString());
      } catch (Exception e) {}
      String[] names = context.getHeaderNames();
      for (String name : names) {
        Object[] headers = context.getHeaders(name);
        for (Object value : headers) {         
View Full Code Here

  public ResponseContext setContentType(String type, String charset) {
    if (type == null) {
      return removeHeader("Content-Type");
    }
    try {
      MimeType mimeType = new MimeType(type);
      if (charset != null) mimeType.setParameter("charset", charset);
      return setHeader("Content-Type", mimeType.toString());
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

    this.base = base;
    setStatus(200);
    setStatusText("OK");
    this.chunked = chunked;
    try {
      MimeType type = getContentType();
      String charset = type.getParameter("charset");
      if (charset == null) charset = getCharsetFromBase(base);
      if (charset == null) charset = "UTF-8";
      type.setParameter("charset", charset);
      setContentType(type.toString());
    } catch (Exception e) {}
  }
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.