org.apache.james.mime4j.field
Class DefaultFieldParser

java.lang.Object
  extended by org.apache.james.mime4j.field.DelegatingFieldParser
      extended by org.apache.james.mime4j.field.DefaultFieldParser
All Implemented Interfaces:
FieldParser<ParsedField>

public class DefaultFieldParser
extends DelegatingFieldParser

Default (strict) implementation of the FieldParser interface.


Constructor Summary
DefaultFieldParser()
           
 
Method Summary
static FieldParser<ParsedField> getParser()
          Gets the default instance of this class.
static ParsedField parse(ByteSequence raw, DecodeMonitor monitor)
          Parses the given byte sequence and returns an instance of the ParsedField class.
static ParsedField parse(java.lang.String rawStr)
           
static ParsedField parse(java.lang.String rawStr, DecodeMonitor monitor)
          Parses the given string and returns an instance of the ParsedField class.
 
Methods inherited from class org.apache.james.mime4j.field.DelegatingFieldParser
getParser, parse, setFieldParser
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFieldParser

public DefaultFieldParser()
Method Detail

getParser

public static FieldParser<ParsedField> getParser()
Gets the default instance of this class.

Returns:
the default instance

parse

public static ParsedField parse(ByteSequence raw,
                                DecodeMonitor monitor)
                         throws MimeException
Parses the given byte sequence and returns an instance of the ParsedField class. The type of the class returned depends on the field name; see parse(String) for a table of field names and their corresponding classes.

Parameters:
raw - the bytes to parse.
monitor - decoding monitor used while parsing/decoding.
Returns:
a parsed field.
Throws:
MimeException - if the raw string cannot be split into field name and body.

parse

public static ParsedField parse(java.lang.String rawStr,
                                DecodeMonitor monitor)
                         throws MimeException
Parses the given string and returns an instance of the ParsedField class. The type of the class returned depends on the field name:

Class returnedField names
ContentTypeFieldContent-Type
ContentLengthFieldContent-Length
ContentTransferEncodingFieldContent-Transfer-Encoding
ContentDispositionFieldContent-Disposition
ContentDescriptionFieldContent-Description
ContentIdFieldContent-ID
ContentMD5FieldContent-MD5
ContentLanguageFieldContent-Language
ContentLocationFieldContent-Location
MimeVersionFieldMIME-Version
DateTimeFieldDate, Resent-Date
MailboxFieldSender, Resent-Sender
MailboxListFieldFrom, Resent-From
AddressListFieldTo, Cc, Bcc, Reply-To, Resent-To, Resent-Cc, Resent-Bcc
UnstructuredFieldSubject and others

Parameters:
rawStr - the string to parse.
Returns:
a parsed field.
Throws:
MimeException - if the raw string cannot be split into field name and body.

parse

public static ParsedField parse(java.lang.String rawStr)
                         throws MimeException
Throws:
MimeException


Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.