org.apache.james.mime4j.parser
Class AbstractEntity

java.lang.Object
  extended by org.apache.james.mime4j.parser.AbstractEntity
All Implemented Interfaces:
EntityStateMachine
Direct Known Subclasses:
MimeEntity

public abstract class AbstractEntity
extends java.lang.Object
implements EntityStateMachine

Abstract MIME entity.


Field Summary
protected  MutableBodyDescriptor body
           
protected  int endState
           
protected  org.apache.commons.logging.Log log
           
protected  boolean maximalBodyDescriptor
           
protected  BodyDescriptor parent
           
protected  int startState
           
protected  int state
           
protected  boolean strictParsing
           
 
Method Summary
protected  void debug(Event event)
          Logs (at debug) an indicative message based on the given event and the current state of the system.
 BodyDescriptor getBodyDescriptor()
          Gets a descriptor for the current entity.
protected abstract  LineReaderInputStream getDataStream()
           
 java.lang.String getField()
          This method is valid, if getState() returns #T_FIELD.
 java.lang.String getFieldName()
          This method is valid, if getState() returns #T_FIELD.
 java.lang.String getFieldValue()
          This method is valid, if getState() returns #T_FIELD.
protected abstract  int getLineNumber()
           
 int getState()
          Return the current state of the entity.
protected  java.lang.String message(Event event)
          Creates an indicative message suitable for display based on the given event and the current state of the system.
protected  void monitor(Event event)
          Monitors the given event.
protected  MutableBodyDescriptor newBodyDescriptor(BodyDescriptor pParent)
          Creates a new instance of BodyDescriptor.
protected  boolean parseField()
           
static java.lang.String stateToString(int state)
          Renders a state as a string suitable for logging.
 java.lang.String toString()
           
protected  void warn(Event event)
          Logs (at warn) an indicative message based on the given event and the current state of the system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.james.mime4j.parser.EntityStateMachine
advance, getContentStream, setRecursionMode
 

Field Detail

log

protected final org.apache.commons.logging.Log log

parent

protected final BodyDescriptor parent

startState

protected final int startState

endState

protected final int endState

maximalBodyDescriptor

protected final boolean maximalBodyDescriptor

strictParsing

protected final boolean strictParsing

body

protected final MutableBodyDescriptor body

state

protected int state
Method Detail

getState

public int getState()
Description copied from interface: EntityStateMachine
Return the current state of the entity.

Specified by:
getState in interface EntityStateMachine
Returns:
current state
See Also:
EntityStates

newBodyDescriptor

protected MutableBodyDescriptor newBodyDescriptor(BodyDescriptor pParent)
Creates a new instance of BodyDescriptor. Subclasses may override this in order to create body descriptors, that provide more specific information.


getLineNumber

protected abstract int getLineNumber()

getDataStream

protected abstract LineReaderInputStream getDataStream()

parseField

protected boolean parseField()
                      throws java.io.IOException
Throws:
java.io.IOException

getBodyDescriptor

public BodyDescriptor getBodyDescriptor()

Gets a descriptor for the current entity. This method is valid if getState() returns:

Specified by:
getBodyDescriptor in interface EntityStateMachine
Returns:
BodyDescriptor, not nulls

getField

public java.lang.String getField()
This method is valid, if getState() returns #T_FIELD.

Specified by:
getField in interface EntityStateMachine
Returns:
String with the fields raw contents.
Throws:
java.lang.IllegalStateException - getState() returns another value than #T_FIELD.

getFieldName

public java.lang.String getFieldName()
This method is valid, if getState() returns #T_FIELD.

Specified by:
getFieldName in interface EntityStateMachine
Returns:
String with the fields name.
Throws:
java.lang.IllegalStateException - getState() returns another value than #T_FIELD.

getFieldValue

public java.lang.String getFieldValue()
This method is valid, if getState() returns #T_FIELD.

Specified by:
getFieldValue in interface EntityStateMachine
Returns:
String with the fields value.
Throws:
java.lang.IllegalStateException - getState() returns another value than #T_FIELD.

monitor

protected void monitor(Event event)
                throws MimeException,
                       java.io.IOException
Monitors the given event. Subclasses may override to perform actions upon events. Base implementation logs at warn.

Parameters:
event - Event, not null
Throws:
MimeException - subclasses may elect to throw this exception upon invalid content
java.io.IOException - subclasses may elect to throw this exception

message

protected java.lang.String message(Event event)
Creates an indicative message suitable for display based on the given event and the current state of the system.

Parameters:
event - Event, not null
Returns:
message suitable for use as a message in an exception or for logging

warn

protected void warn(Event event)
Logs (at warn) an indicative message based on the given event and the current state of the system.

Parameters:
event - Event, not null

debug

protected void debug(Event event)
Logs (at debug) an indicative message based on the given event and the current state of the system.

Parameters:
event - Event, not null

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

stateToString

public static final java.lang.String stateToString(int state)
Renders a state as a string suitable for logging.

Parameters:
state -
Returns:
rendered as string, not null


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