eu.medsea.mimeutil
Class TextMimeType

java.lang.Object
  extended by eu.medsea.mimeutil.MimeType
      extended by eu.medsea.mimeutil.TextMimeType
All Implemented Interfaces:
Serializable, Comparable

public class TextMimeType
extends MimeType

This class can be used to represent a mime type for a text file. This should only be returned by MimeDetector(s) that use magic number type matching. It allows for an encoding to be associated to a text type mime type such as text/plain.

Author:
Steven McArdle
See Also:
Serialized Form

Constructor Summary
TextMimeType(MimeType mimeType)
          Construct a new TestMimeType from an existing MimeType
TextMimeType(String mimeType)
          Construct a new TextMimeType from a string representation of a MimeType
TextMimeType(String mimeType, String encoding)
          Construct a TextMimeType from a string representation of a MimeType and an encoding that should be one of the known encodings.
 
Method Summary
static void addKnownEncoding(String encoding)
          Add a new encoding to the internal encodings this class knows about.
 String getEncoding()
          Get the encoding currently set for this TextMimeType.
 Collection getKnownEncodings()
          Get the list of currently known encodings.
 boolean isKnownEncoding(String encoding)
          Utility method to see if the passed in encoding is known to this class.
 void setEncoding(String encoding)
          Set the encoding used for the file or stream this MimeType is associated with
 
Methods inherited from class eu.medsea.mimeutil.MimeType
compareTo, equals, getMediaType, getSpecificity, getSubType, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextMimeType

public TextMimeType(MimeType mimeType)
Construct a new TestMimeType from an existing MimeType

Parameters:
mimeType -

TextMimeType

public TextMimeType(String mimeType)
Construct a new TextMimeType from a string representation of a MimeType

Parameters:
mimeType -

TextMimeType

public TextMimeType(String mimeType,
                    String encoding)
Construct a TextMimeType from a string representation of a MimeType and an encoding that should be one of the known encodings.

Parameters:
mimeType -
encoding -
See Also:
getKnownEncodings(), addKnownEncoding(String)
Method Detail

getKnownEncodings

public Collection getKnownEncodings()
Get the list of currently known encodings. This list is initialised from the file located in eu.medsea.mimeutil.TextEncodings. If a problem occurs while reading this file a default hard coded set of encodings are used. New encodings can be added to the known encodings usingsetEncoding(String)

Returns:
collection of strings representing te encodings known to this class.
See Also:
setEncoding(String)

addKnownEncoding

public static void addKnownEncoding(String encoding)
Add a new encoding to the internal encodings this class knows about.

Parameters:
encoding -
See Also:
getKnownEncodings()

getEncoding

public String getEncoding()
Get the encoding currently set for this TextMimeType. It will be one of the know encodings either initialised at class load time or one that has been added manually.

Returns:
the encoding as a string
See Also:
getKnownEncodings(), setEncoding(String)

setEncoding

public void setEncoding(String encoding)
Set the encoding used for the file or stream this MimeType is associated with

Parameters:
encoding -

isKnownEncoding

public boolean isKnownEncoding(String encoding)
Utility method to see if the passed in encoding is known to this class.

Parameters:
encoding -
Returns:
true if encoding passed in is one of the known encodings else false
See Also:
getKnownEncodings()


Copyright © 2007-2009 Medsea Business Solutions S.L.. All Rights Reserved.