Examples of MediaType


Examples of javax.ws.rs.core.MediaType

   public void testConsume2() throws Exception
   {
      Registry registry = new ResourceMethodRegistry(ResteasyProviderFactory.getInstance());
      registry.addPerRequestResource(XmlResource2.class);

      MediaType contentType = MediaType.valueOf("application/xml;schema=bar");

      {
         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         accepts.add(MediaType.valueOf("application/xml;schema=junk;q=1.0"));
         accepts.add(MediaType.valueOf("application/xml;schema=stuff;q=0.5"));
View Full Code Here

Examples of javax.ws.rs.core.MediaType

   public void testConsume3() throws Exception
   {
      Registry registry = new ResourceMethodRegistry(ResteasyProviderFactory.getInstance());
      registry.addPerRequestResource(XmlResource2.class);

      MediaType contentType = MediaType.valueOf("application/xml;schema=blah");

      {
         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         accepts.add(MediaType.valueOf("application/xml;schema=junk;q=1.0"));
         accepts.add(MediaType.valueOf("application/xml;schema=stuff;q=0.5"));
View Full Code Here

Examples of nl.siegmann.epublib.domain.MediaType

   * @param filename
   * @return the MediaType based on the file extension.
   */
  public static MediaType determineMediaType(String filename) {
    for(int i = 0; i < mediatypes.length; i++) {
      MediaType mediatype = mediatypes[i];
      for(String extension: mediatype.getExtensions()) {
        if(StringUtil.endsWithIgnoreCase(filename, extension)) {
          return mediatype;
        }
      }
    }
View Full Code Here

Examples of org.apache.abdera.ext.serializer.annotation.MediaType

            if (mtaccessor != null) {
                Object mtvalue = eval(mtaccessor, contentValue);
                mediatype = mtvalue != null ? toString(mtvalue) : null;
            }
            if (mediatype == null) {
                MediaType mt = valueContext.getAnnotation(MediaType.class);
                mediatype = mt != null && !mt.value().equals(DEFAULT) ? mt.value() : null;
            }
            if (mediatype != null)
                sw.writeAttribute("type", mediatype);
        }
View Full Code Here

Examples of org.apache.axiom.mime.MediaType

            charset = null;
            isMTOM = false;
            soapFactory = metaFactory.getSOAP11Factory();
            soapEnvelopeNamespaceURI = null;
        } else {
            MediaType baseType = contentType.getMediaType();
            MediaType soapContentType;
            if (baseType.equals(MediaType.APPLICATION_XOP_XML)) {
                isMTOM = true;
                String typeParam = contentType.getParameter("type");
                if (typeParam == null) {
                    throw new SOAPException("Missing 'type' parameter in XOP content type");
                } else {
                    try {
                        soapContentType = new ContentType(typeParam).getMediaType();
                    } catch (ParseException ex) {
                        throw new SOAPException("Failed to parse the 'type' parameter", ex);
                    }
                }
            } else {
                isMTOM = false;
                soapContentType = baseType;
            }
           
            if (soapContentType.equals(MediaType.TEXT_XML)) {
                soapEnvelopeNamespaceURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
                soapFactory = metaFactory.getSOAP11Factory();
            } else if (soapContentType.equals(MediaType.APPLICATION_SOAP_XML)) {
                soapEnvelopeNamespaceURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
                soapFactory = metaFactory.getSOAP12Factory();
            } else {
                throw new SOAPException("Unrecognized content type '" + soapContentType + "'");
            }
View Full Code Here

Examples of org.apache.jena.atlas.web.MediaType

        return mapContentTypeToLang.get(key) ;
    }

    public static String getCharsetForContentType(String contentType)
    {
        MediaType ct = MediaType.create(contentType) ;
        if ( ct.getCharset() != null )
            return ct.getCharset() ;
       
        String mt = ct.getContentType() ;
        if ( contentTypeNTriples.equals(mt) )       return charsetUTF8 ;
        if ( contentTypeNTriplesAlt.equals(mt) )    return charsetASCII ;
        if ( contentTypeNQuads.equals(mt) )         return charsetUTF8 ;
        if ( contentTypeNQuadsAlt1.equals(mt) )      return charsetASCII ;
        if ( contentTypeNQuadsAlt2.equals(mt) )      return charsetASCII ;
View Full Code Here

Examples of org.apache.jetspeed.capabilities.MediaType

                {
                    map.addMediaType((MediaType) media.next());
                }

                //Set preferred Mimetype
                MediaType mtEntry =
                    getMediaTypeForMimeType(map.getPreferredType().getName());

                map.setPreferredMediaType(mtEntry);

                // Add map to cache
View Full Code Here

Examples of org.apache.tika.mime.MediaType

            }
        }

        DefaultDetector detector = new DefaultDetector();
        Metadata metadata = new Metadata();
        MediaType mediaType = detector.detect(new BufferedInputStream(in), metadata);
        mimeType = mediaType.toString();
        if (mimeType != null) {
            return mimeType;
        }

        return "application/octet-stream";
View Full Code Here

Examples of org.apache.tomcat.util.http.parser.MediaType

        if (type == null) {
            this.contentType = null;
            return;
        }

        MediaType m = null;
        try {
             m = HttpParser.parseMediaType(new StringReader(type));
        } catch (IOException e) {
            // Ignore - null test below handles this
        }
        if (m == null) {
            // Invalid - Assume no charset and just pass through whatever
            // the user provided.
            this.contentType = type;
            return;
        }

        this.contentType = m.toStringNoCharset();

        String charsetValue = m.getCharset();

        if (charsetValue != null) {
            charsetValue = charsetValue.trim();
            if (charsetValue.length() > 0) {
                charsetSet = true;
View Full Code Here

Examples of org.cruxframework.crux.core.server.rest.core.MediaType

  public Object extractValue(String strVal, HttpRequest request)
  {
    Object value = extractValue(strVal);
    if (strVal != null && value == null)
    {
      MediaType mediaType = request.getHttpHeaders().getMediaType();
      if (mediaType == null)
      {
        mediaType = MediaType.WILDCARD_TYPE;
      }
      if (mediaType.isCompatible(MediaType.APPLICATION_JSON_TYPE))
      {
        if (this.reader == null)
        {
          lock.lock();
          try
          {
            if (this.reader == null)
            {
              this.reader = JsonUtil.createReader(type);
            }
          }
          finally
          {
            lock.unlock();
          }
        }
        try
                {
          if (strVal == null || strVal.length()==0)
          {
            strVal = defaultValue;
          }
                  value = this.reader.readValue(strVal);
                }
                catch (Exception e)
                {
              throw new BadRequestException("Can not read request body for path: " + request.getUri().getPath(), e);
                }
      }
      else
      {
        throw new UnsupportedMediaTypeException("Media type not supported: " + mediaType.toString());
      }
    }
    return value;
  }
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.