net.noderunner.http
Class ContentType

java.lang.Object
  extended by net.noderunner.http.ContentType

public final class ContentType
extends Object

Content type field value class, see RFC 2045 section 5.1 on this. Immutable class.

Author:
Elias Ross

Nested Class Summary
static class ContentType.Parameter
          Content type parameter, see parameter definition in RFC 2045.
static class ContentType.StandardType
          Standard content types.
 
Constructor Summary
ContentType(String type, String subtype)
          Constructs a new ContentType.
ContentType(String type, String subtype, List<ContentType.Parameter> param)
          Constructs a new ContentType.
 
Method Summary
static void checkToken(String t)
          Checks a token syntax.
 ContentType.Parameter getParameter(String attribute)
          Returns the first parameter matching this attribute string.
 List<ContentType.Parameter> getParameters()
          Returns parameters, unmodifiable.
 String getParameterValue(String attribute)
          Returns the first parameter value matching this attribute string.
 String getSubtype()
          Returns content sub type.
 String getType()
          Returns type.
static ContentType parse(String string)
          Factory method, parsing a content type line and generating a content type object.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ContentType

public ContentType(String type,
                   String subtype)
Constructs a new ContentType.


ContentType

public ContentType(String type,
                   String subtype,
                   List<ContentType.Parameter> param)
Constructs a new ContentType.

Parameters:
type - non-null type
subtype - non-null subtype
param - list of parameters, optionally null
Method Detail

parse

public static ContentType parse(String string)
Factory method, parsing a content type line and generating a content type object.

Returns:
newly created content type object

checkToken

public static void checkToken(String t)
Checks a token syntax.

Throws:
IllegalArgumentException - if token is invalid

getType

public String getType()
Returns type.


getSubtype

public String getSubtype()
Returns content sub type.


getParameters

public List<ContentType.Parameter> getParameters()
Returns parameters, unmodifiable.


getParameter

public ContentType.Parameter getParameter(String attribute)
Returns the first parameter matching this attribute string. Returns null if not found.


getParameterValue

public String getParameterValue(String attribute)
Returns the first parameter value matching this attribute string. Returns null if not found.


toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.