Package org.w3c.www.mime

Examples of org.w3c.www.mime.MimeType


    return null;
 
      String language = refframe.getContentLanguage();
      String encoding = refframe.getContentEncoding();
      String charset  = refframe.getCharset();
      MimeType mtype  = refframe.getContentType();
     
      HTTPFrame itsframe = null;
      for (int i = num; i < variants.length; i++) {
    try {
        resource = (FramedResource)variants[i].unsafeLock();
        itsframe = (HTTPFrame)
                     resource.unsafeGetFrame(httpFrameClass);
        if (language != null) {
      if (!language.equals(itsframe.getContentLanguage())) {
          b_language = true;
      }
        } else {
      if (itsframe.getContentLanguage() != null) {
          b_language = true;
      }
        }
        if (encoding != null) {
      if (!encoding.equals(itsframe.getContentEncoding())) {
          b_encoding = true;
      }
        } else {
      if (itsframe.getContentEncoding() != null) {
          b_encoding = true;
      }
        }
        if (charset != null) {
      if (!charset.equals(itsframe.getCharset())) {
          b_charset = true;
      }
        } else {
      if (itsframe.getCharset() != null) {
          b_charset = true;
      }
        }
        if (mtype != null) {
      MimeType o_type = itsframe.getContentType();
      if ((o_type != null) && (mtype.match(o_type) !=
              MimeType.MATCH_SPECIFIC_SUBTYPE)) {
          b_type = true;
      }
        } else {
View Full Code Here


    try {
        FramedResource resource = (FramedResource)rr.unsafeLock() ;
        HTTPFrame itsframe =
      (HTTPFrame) resource.unsafeGetFrame(httpFrameClass);
        if (itsframe != null) {
      MimeType vt;
      vt = (MimeType) itsframe.unsafeGetValue(
                                    ATTR_CONTENT_TYPE, null);
      String fcharset = vt.getParameterValue("charset");
      // if not defined in the frame, it must be the default
      if (fcharset == null) {
          fcharset = "ISO-8859-1";
      }
      double qual = 0.0 ;
View Full Code Here

    try {
        FramedResource resource = (FramedResource)rr.unsafeLock() ;
        HTTPFrame itsframe =
      (HTTPFrame) resource.unsafeGetFrame(httpFrameClass);
        if (itsframe != null) {
      MimeType vt;
      vt = (MimeType) itsframe.unsafeGetValue(
                                    ATTR_CONTENT_TYPE, null);
      int jmatch = -1 ;
      int jidx   = -1 ;
      for (int j = 0 ; j < accepts.length ; j++) {
          try {
        int match = vt.match(accepts[j].getMimeType());
        if ( match > jmatch ) {
            jmatch = match ;
            jidx   = j ;
        }
          } catch (HttpInvalidValueException ivex) {
View Full Code Here

            " for a PUT, as no ETags were sent");
      throw new HTTPException (reply);
  }
  // now filter out variants
  nb_v = variants.length;
  MimeType type = request.getContentType();
  String encodings[] = request.getContentEncoding();
  String languages[] = request.getContentLanguage();
  ResourceReference rr;

  if (type != null || encodings != null || languages != null) {
      // the request is not too bad ;)
      for (int i = 0 ; i < variants.length ; i++) {
    if (variants[i] == null)
        continue;
    rr = variants[i];
    try {
        resource = (FramedResource)rr.unsafeLock() ;
        itsframe = (HTTPFrame)resource.getFrame(httpFrameClass);
        if (itsframe == null) {
      nb_v--;
      variants[i] = null;
      continue;
        }
        // remove the non matching mime types
        if (type != null) {
      MimeType fmt = itsframe.getContentType();
      if (fmt == null || (fmt.match(type) !=
              MimeType.MATCH_SPECIFIC_SUBTYPE)) {
          nb_v--;
          variants[i] = null;
          continue;
      }
View Full Code Here

     * @return an object or <strong>null</strong> if the object was not
     * initialized
     */
    public Object getValue() {
  try {
      return new MimeType(comp.getText());
  } catch (Exception ex) {
      // no mime type then!
  }
  return null;
    }
View Full Code Here

         , Attribute a
         , Object o
         , Properties p)
  throws RemoteAccessException
    {
  MimeType type = (MimeType)o;
  if (o == null) {
      oldvalue = "*none*";
      createComponent(oldvalue);;
  } else {
      createComponent(type.toString());
      oldvalue = type.toString();
  }
    }
View Full Code Here

  return types;
    }

    protected double getCompressibilityFactor(Reply reply) {
        // Match possible mime types:
  MimeType t[]     = getMimeTypes();
  if ( t != null ) {
      for (int i = 0 ; i < t.length ; i++) {
    if ( t[i] == null )
        continue;
    if ( t[i].match(reply.getContentType()) > 0 ) {
View Full Code Here

    protected void doEncoding(HttpAcceptEncoding enc, Reply reply) {
        // Anything to compress ?
  if ( ! reply.hasStream() )
      return;
  // Match possible mime types:
  MimeType t[]     = getMimeTypes();
  boolean  matched = false;
  if ( t != null ) {
      for (int i = 0 ; i < t.length ; i++) {
    if ( t[i] == null )
        continue;
View Full Code Here

    // then override some configuration
    while ( e.hasMoreElements() ) {
        // use some well known descriptions
        HeaderDescription d = (HeaderDescription) e.nextElement();
        if ( d.isHeader(HttpEntityMessage.H_CONTENT_TYPE)) {
      MimeType mtype = null;
      try {
          mtype = msg.getContentType();
      } catch (Exception ex) {
          // ok by default use something binary
          mtype = MimeType.APPLICATION_OCTET_STREAM;
      }
      if (mtype.hasParameter("charset")) {
          String charset =mtype.getParameterValue("charset");
          MimeType m = new MimeType(mtype.getType(),
                  mtype.getSubtype());
          frame.setValue("content-type", m);
          frame.setValue("charset", charset);
      } else {
          frame.setValue("content-type", mtype);
View Full Code Here

     * @param type The name of the content-type.
     * @return An instance of Extension, or <strong>null</strong>.
     */

    public synchronized ResourceReference loadContentType (String type) {
  MimeType mtype = null;
 
  try {
      mtype = new MimeType(type);
  } catch (MimeTypeFormatException ex) {
      return null;
  }
  ResourceReference rr = getContentTypes();
  try {
      TemplateContainer types = (TemplateContainer) rr.lock();
      Enumeration e = types.enumerateResourceIdentifiers(true);
      String key = "*:*"; // if there is no better match...
      int match = -1;
      int cmatch;
      while (e.hasMoreElements()) {
    String ext_entry = (String)e.nextElement();
    MimeType entry_type = null;
    try {
        entry_type = new MimeType(ext_entry.replace(':','/'));
    } catch (MimeTypeFormatException mex) {
        // ok there is a configuration problem here
        continue;
    }
    cmatch = mtype.match(entry_type);
View Full Code Here

TOP

Related Classes of org.w3c.www.mime.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.