org.openxri.resolve
Class MimeType

java.lang.Object
  extended by org.openxri.resolve.MimeType
All Implemented Interfaces:
java.lang.Comparable

public class MimeType
extends java.lang.Object
implements java.lang.Comparable

Encapsulates a media type in XRI Resolution. Contains minimal business rules to recognize the 3 'built-in' types used in XRI resolution: application/xrds+xml, application/xrd+xml and text/uri-list.

Author:
wtan

Field Summary
protected  java.lang.String original
           
static java.lang.String PARAM_CID
           
static java.lang.String PARAM_HTTPS
           
static java.lang.String PARAM_NO_DEFAULT_M
           
static java.lang.String PARAM_NO_DEFAULT_P
           
static java.lang.String PARAM_NO_DEFAULT_T
           
static java.lang.String PARAM_REFS
           
static java.lang.String PARAM_SAML
           
static java.lang.String PARAM_SEP
           
static java.lang.String PARAM_TRUST
          Deprecated.  
static java.lang.String PARAM_URIC
           
protected  java.util.HashMap params
           
protected  java.lang.String type
           
static java.lang.String URI_LIST
           
static java.lang.String XRD_XML
           
static java.lang.String XRDS_XML
           
 
Constructor Summary
  MimeType(java.lang.String type)
          Creates a MimeType object with no params.
protected MimeType(java.lang.String type, java.util.HashMap params, java.lang.String original)
          Creates a MimeType object
 
Method Summary
 int compareTo(java.lang.Object o)
          This compares two objects and return their weigted order based on the q parameter
 boolean equals(MimeType m)
          Compares the content of this object with the candidate.
 boolean equals(java.lang.Object o)
           
 java.lang.String getParam(java.lang.String key)
          Retrieves the MIME parameter value for the given key
 java.lang.String getType()
           
 boolean isSuperSetOf(MimeType m)
          Tests to see if this MimeType has the same type as m and that every parameter of m must be present and has the same value in this MimeType.
 boolean isType(java.lang.String mtype)
          Tests to see if this MimeType has the same type as the simple type mtype.
 boolean isValidXriResMediaType()
           
static void main(java.lang.String[] args)
           
 java.util.Set paramKeys()
          Gets the set of parameter keys
static MimeType parse(java.lang.String typeStr)
          Parses a HTTP Accept or Content-Type header value into the type and params components
 java.lang.String toNormalizedString()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PARAM_SEP

public static final java.lang.String PARAM_SEP
See Also:
Constant Field Values

PARAM_REFS

public static final java.lang.String PARAM_REFS
See Also:
Constant Field Values

PARAM_HTTPS

public static final java.lang.String PARAM_HTTPS
See Also:
Constant Field Values

PARAM_SAML

public static final java.lang.String PARAM_SAML
See Also:
Constant Field Values

PARAM_CID

public static final java.lang.String PARAM_CID
See Also:
Constant Field Values

PARAM_URIC

public static final java.lang.String PARAM_URIC
See Also:
Constant Field Values

PARAM_NO_DEFAULT_T

public static final java.lang.String PARAM_NO_DEFAULT_T
See Also:
Constant Field Values

PARAM_NO_DEFAULT_P

public static final java.lang.String PARAM_NO_DEFAULT_P
See Also:
Constant Field Values

PARAM_NO_DEFAULT_M

public static final java.lang.String PARAM_NO_DEFAULT_M
See Also:
Constant Field Values

PARAM_TRUST

public static final java.lang.String PARAM_TRUST
Deprecated. 
See Also:
Constant Field Values

XRDS_XML

public static final java.lang.String XRDS_XML
See Also:
Constant Field Values

XRD_XML

public static final java.lang.String XRD_XML
See Also:
Constant Field Values

URI_LIST

public static final java.lang.String URI_LIST
See Also:
Constant Field Values

type

protected java.lang.String type

params

protected java.util.HashMap params

original

protected java.lang.String original
Constructor Detail

MimeType

protected MimeType(java.lang.String type,
                   java.util.HashMap params,
                   java.lang.String original)
Creates a MimeType object


MimeType

public MimeType(java.lang.String type)
Creates a MimeType object with no params.

Parameters:
type - all-lowercase string with no leading or trailing whitespace.
Method Detail

getParam

public java.lang.String getParam(java.lang.String key)
Retrieves the MIME parameter value for the given key

Parameters:
key -
Returns:
String the value if present (could be an empty String), or null if not present

paramKeys

public java.util.Set paramKeys()
Gets the set of parameter keys

Returns:

equals

public boolean equals(MimeType m)
Compares the content of this object with the candidate. Both must have the same type and same parameter values.

Parameters:
m -
Returns:

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(java.lang.Object o)
This compares two objects and return their weigted order based on the q parameter

Specified by:
compareTo in interface java.lang.Comparable

isType

public boolean isType(java.lang.String mtype)
Tests to see if this MimeType has the same type as the simple type mtype. If this MimeType has sub-parameters, they are ignored.


isSuperSetOf

public boolean isSuperSetOf(MimeType m)
Tests to see if this MimeType has the same type as m and that every parameter of m must be present and has the same value in this MimeType.

Parameters:
m -
Returns:

parse

public static MimeType parse(java.lang.String typeStr)
Parses a HTTP Accept or Content-Type header value into the type and params components

Parameters:
typeStr -
Returns:
Returns a new MimeType object.

isValidXriResMediaType

public boolean isValidXriResMediaType()

getType

public java.lang.String getType()
Returns:
Returns the type.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
Returns the original type string (as given to parse.)

toNormalizedString

public java.lang.String toNormalizedString()
Returns:
Returns the normalized string suitable for use in Accept and Content-Type headers.

main

public static void main(java.lang.String[] args)


Copyright © 2005-2012. All Rights Reserved.