Examples of MimeType


Examples of org.apache.pivot.util.MIMEType

import org.junit.Test;

public class MIMETypeTest {
    @Test
    public void testMIMEType() {
        MIMEType mimeType = MIMEType.decode("foo; a=123; b=456; c=789");
        assertEquals(mimeType.getBaseType(), "foo");
        assertEquals(mimeType.get("a"), "123");
        assertEquals(mimeType.get("b"), "456");
        assertEquals(mimeType.get("c"), "789");
    }
View Full Code Here

Examples of org.apache.tika.mime.MimeType

        return type;
    }

    public String getExtension(String mimeType) {
        try {
            MimeType type = types.forName(mimeType);
            String extension = type.getExtension();
            if (extension != null && extension.length() > 1) {
                return extension.substring(1); // skip leading "."
            }
        } catch (MimeTypeException e) {
            // ignore
View Full Code Here

Examples of org.apache.tika.mime.MimeType

    // set headers
    headers.set(Response.CONTENT_LENGTH, new Long(size).toString());
    headers.set(Response.LAST_MODIFIED, HttpDateFormat.toString(f
        .lastModified()));
   
    MimeType mimeType = MIME.getMimeType(f);
    String mimeTypeString = mimeType != null ? mimeType.getName() : "";
    headers.set(Response.CONTENT_TYPE, mimeTypeString);

    // response code
    this.code = 200; // http OK
  }
View Full Code Here

Examples of org.apache.tika.mime.MimeType

        if (!stream.markSupported()) {
            stream = new BufferedInputStream(stream);
        }

        // Automatically detect the MIME type of the document
        MimeType type = getMimeType(stream, metadata);
        metadata.set(Metadata.CONTENT_TYPE, type.getName());

        // Get the parser configured for the detected MIME type
        Parser parser = config.getParser(type.getName());
        if (parser == null) {
            parser = config.getParser(MimeTypes.DEFAULT);
        }
        if (parser == null) {
            throw new TikaException("No parsers available: " + type.getName());
        }

        // Parse the document
        parser.parse(stream, handler, metadata);
    }
View Full Code Here

Examples of org.apache.tika.mime.MimeType

        // Get type based on magic prefix
        stream.mark(types.getMinLength());
        try {
            byte[] prefix = getPrefix(stream, types.getMinLength());
            MimeType type = types.getMimeType(prefix);
            if (type != null) {
                return type;
            }
        } finally {
            stream.reset();
        }

        // Get type based on resourceName hint (if available)
        String resourceName = metadata.get(Metadata.RESOURCE_NAME_KEY);
        if (resourceName != null) {
            MimeType type = types.getMimeType(resourceName);
            if (type != null) {
                return type;
            }
        }
View Full Code Here

Examples of org.codehaus.enunciate.rest.MimeType

    Set<String> allKnownContentTypes = ((EnunciateFreemarkerModel)FreemarkerModel.get()).getContentTypesToIds().keySet();
    String typeValue = mediaType.getType();
    List<String> typeSet = new ArrayList<String>();
    typeSet.add(typeValue);
    try {
      MimeType mimeType = MimeType.parse(typeValue);
      for (String knownType : allKnownContentTypes) {
        try {
          MimeType knownMimeType = MimeType.parse(knownType);
          if (mimeType.isAcceptable(knownMimeType)) {
            typeSet.add(knownType);
          }
        }
        catch (Exception e) {
View Full Code Here

Examples of org.exist.util.MimeType

                name = file.getName();
                path = file.getParent();
               
                Collection target = (path==null) ? root : XMLDBAbstractCollectionManipulator.createCollection(root, path);
               
                  MimeType mime = MimeTable.getInstance().getContentTypeFor(name);
                 
                try{
                  NodeValue content = ModuleUtils.streamToXML(context, new ByteArrayInputStream(baos.toByteArray()));
                  resource = target.createResource(name, "XMLResource");
                  ContentHandler handler = ((XMLResource)resource).setContentAsSAX();
                  handler.startDocument();
                  content.toSAX(context.getBroker(), handler, null);
                  handler.endDocument();
                } catch(SAXException e){
                  resource = target.createResource(name, "BinaryResource");
                  resource.setContent(baos.toByteArray());
                    }
               
                if (resource != null){
                  if (mime != null){
                    ((EXistResource)resource).setMimeType(mime.getName());
                  }
                  target.storeResource(resource);
                }
                 
                }
View Full Code Here

Examples of org.exoplatform.web.url.MimeType

        //
        String csrfCheck = props.get(PortletURLBuilder.CSRF_PROP);
        url.setCSRFCheck(Boolean.parseBoolean(csrfCheck));

        //
        MimeType mimeType = Boolean.TRUE.equals(format.getWantEscapeXML()) ? MimeType.XHTML : MimeType.PLAIN;
        url.setMimeType(mimeType);

        //
        return url.toString();
    }
View Full Code Here

Examples of org.geotools.ml.MimeType

     * @generated modifiable
     */
    public Object parse(ElementInstance instance, Node node, Object value)
        throws Exception {
        Map mime = (Map) node.getChildValue("mimetype");
        MimeType mimeType = new MimeType((String) mime.get("type"), (String) mime.get("subtype"));

        String name = (String) node.getChildValue("name");

        //content is optional
        List contentList = node.getChildValues("content");
View Full Code Here

Examples of org.geowebcache.mime.MimeType

        Map<String, String> keysValues = new TreeMap<String, String>();

        Iterator<MimeType> iter = tl.getMimeTypes().iterator();

        while (iter.hasNext()) {
            MimeType mime = iter.next();
            keysValues.put(mime.getFormat(), mime.getFormat());
        }

        makePullDown(doc, "format", keysValues, ImageMime.png.getFormat());
        doc.append("</td></tr>\n");
    }
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.