Apache JAMES Mime4j 0.6-redhat-2

org.apache.james.mime4j.field
Class AbstractField

java.lang.Object
  extended by org.apache.james.mime4j.field.AbstractField
All Implemented Interfaces:
ParsedField, Field
Direct Known Subclasses:
AddressListField, ContentDispositionField, ContentTransferEncodingField, ContentTypeField, DateTimeField, MailboxField, MailboxListField, UnstructuredField

public abstract class AbstractField
extends Object
implements ParsedField

The base class of all field classes.


Constructor Summary
protected AbstractField(String name, String body, ByteSequence raw)
           
 
Method Summary
 String getBody()
          Gets the unfolded, unparsed and possibly encoded (see RFC 2047) field body string.
 String getName()
          Gets the name of the field (Subject, From, etc).
 ParseException getParseException()
          Returns the exception that was thrown by the field parser while parsing the field value.
static DefaultFieldParser getParser()
          Gets the default parser used to parse fields.
 ByteSequence getRaw()
          Gets the original raw field string.
 boolean isValidField()
          Returns true if this field is valid, i.e.
static ParsedField parse(ByteSequence raw)
          Parses the given byte sequence and returns an instance of the Field class.
static ParsedField parse(String rawStr)
          Parses the given string and returns an instance of the Field class.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractField

protected AbstractField(String name,
                        String body,
                        ByteSequence raw)
Method Detail

parse

public static ParsedField parse(ByteSequence raw)
                         throws MimeException
Parses the given byte sequence and returns an instance of the Field 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.
Returns:
a ParsedField instance.
Throws:
MimeException - if the raw string cannot be split into field name and body.
See Also:
isValidField()

parse

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

Class returnedField names
ContentTypeFieldContent-Type
ContentTransferEncodingFieldContent-Transfer-Encoding
ContentDispositionFieldContent-Disposition
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 ParsedField instance.
Throws:
MimeException - if the raw string cannot be split into field name and body.
See Also:
isValidField()

getParser

public static DefaultFieldParser getParser()
Gets the default parser used to parse fields.

Returns:
the default field parser

getName

public String getName()
Gets the name of the field (Subject, From, etc).

Specified by:
getName in interface Field
Returns:
the field name.

getRaw

public ByteSequence getRaw()
Gets the original raw field string.

Specified by:
getRaw in interface Field
Returns:
the original raw field string.

getBody

public String getBody()
Gets the unfolded, unparsed and possibly encoded (see RFC 2047) field body string.

Specified by:
getBody in interface Field
Returns:
the unfolded unparsed field body string.

isValidField

public boolean isValidField()
Description copied from interface: ParsedField
Returns true if this field is valid, i.e. no errors were encountered while parsing the field value.

Specified by:
isValidField in interface ParsedField
Returns:
true if this field is valid, false otherwise.
See Also:
ParsedField.isValidField()

getParseException

public ParseException getParseException()
Description copied from interface: ParsedField
Returns the exception that was thrown by the field parser while parsing the field value. The result is null if the field is valid and no errors were encountered.

Specified by:
getParseException in interface ParsedField
Returns:
the exception that was thrown by the field parser or null if the field is valid.
See Also:
ParsedField.getParseException()

toString

public String toString()
Overrides:
toString in class Object

Apache JAMES Mime4j 0.6-redhat-2

Copyright © 2004-2012 JBoss by Red Hat. All Rights Reserved.