jxUtil 0.6

org.sourceforge.jxutil.net
Class ContentType

java.lang.Object
  |
  +--org.sourceforge.jxutil.net.ContentType
All Implemented Interfaces:
Cloneable, Comparable

public final class ContentType
extends Object
implements Comparable, Cloneable

The ContentType class implements RFC 822 style content types. Instances of ContentType are immutable like Strings.

Version:
0.01, 99/10/18
Author:
Keve Muller

Field Summary
static ContentType anyUni
           
private  int hashCode
          Cached hashCode value.
static ContentType imageUni
           
private  String[] parameter
          The optional parameter part.
private  String subtype
          The subtype part.
static ContentType textUni
           
private  String type
          The type part.
static ContentType unknown
           
 
Constructor Summary
  ContentType(String s)
          Initialise a ContentType from its String representation.
  ContentType(String type, String subtype, Map paramMap)
           
private ContentType(String type, String subtype, String[] parameter)
           
 
Method Summary
 ContentType addParam(Map paramMap)
          Return a new ContentType with the given key/value pairs added to its parameters.
 ContentType addParam(String key, String value)
          Return a new ContentType with the given key/value pair added to its parameters.
 int compareTo(Object o)
          Compare.
 boolean equals(Object obj)
           
static ContentType forClass(Class cl)
           
 String getParameter(String key)
          Get the value of a parameter.
 String getParameter(String key, String def)
          Get the value of a parameter with default.
 Map getParameters()
          Copy the parameters into a map.
 String getSubType()
          Access subtype field.
 String getType()
          Access type field.
 ContentType getUniversalType()
          Return a ContentType which is a parent of this type.
 int hashCode()
          Return the cached hashCode.
 boolean isUniversal()
           
private  String[] makeParameter(Map paramMap)
           
 boolean matches(ContentType ctype)
           
 String toString()
          Format the the ContentType instance into its String representatsion.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

anyUni

public static final ContentType anyUni

hashCode

private final int hashCode
Cached hashCode value.


imageUni

public static final ContentType imageUni

parameter

private final String[] parameter
The optional parameter part. For efficient storage the paremeters are combined into this array.


subtype

private final String subtype
The subtype part.


textUni

public static final ContentType textUni

type

private final String type
The type part.


unknown

public static final ContentType unknown
Constructor Detail

ContentType

public ContentType(String s)
            throws NullPointerException
Initialise a ContentType from its String representation. TODO:


ContentType

public ContentType(String type,
                   String subtype,
                   Map paramMap)

ContentType

private ContentType(String type,
                    String subtype,
                    String[] parameter)
Method Detail

addParam

public final ContentType addParam(Map paramMap)
Return a new ContentType with the given key/value pairs added to its parameters.


addParam

public final ContentType addParam(String key,
                                  String value)
Return a new ContentType with the given key/value pair added to its parameters.


compareTo

public final int compareTo(Object o)
Compare.

Specified by:
compareTo in interface Comparable

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

forClass

public static final ContentType forClass(Class cl)

getParameter

public final String getParameter(String key)
Get the value of a parameter.


getParameter

public final String getParameter(String key,
                                 String def)
Get the value of a parameter with default.


getParameters

public final Map getParameters()
Copy the parameters into a map.


getSubType

public final String getSubType()
Access subtype field.


getType

public final String getType()
Access type field.


getUniversalType

public final ContentType getUniversalType()
Return a ContentType which is a parent of this type.


hashCode

public final int hashCode()
Return the cached hashCode.

Overrides:
hashCode in class Object

isUniversal

public boolean isUniversal()

makeParameter

private String[] makeParameter(Map paramMap)

matches

public boolean matches(ContentType ctype)

toString

public final String toString()
Format the the ContentType instance into its String representatsion.

Overrides:
toString in class Object

jxUtil 0.6

Copyright © 2001,2002 Keve Müller, et al.; see LICENSE file for details.