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  MimeEntityConfig config
           
protected  int endState
           
protected  org.apache.commons.logging.Log log
           
protected  BodyDescriptor parent
           
protected  int startState
           
protected  int state
           
 
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()
           
 Field getField()
          This method is valid, if getState() returns EntityStates.T_FIELD.
protected abstract  int getLineNumber()
          Returns the current line number or -1 if line number information is not available.
 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

config

protected final MimeEntityConfig config

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()
Returns the current line number or -1 if line number information is not available.


getDataStream

protected abstract LineReaderInputStream getDataStream()

parseField

protected boolean parseField()
                      throws MimeException,
                             java.io.IOException
Throws:
MimeException
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 Field getField()
This method is valid, if getState() returns EntityStates.T_FIELD.

Specified by:
getField in interface EntityStateMachine
Returns:
String with the fields raw contents.
Throws:
java.lang.IllegalStateException - getState() returns another value than EntityStates.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-2009 The Apache Software Foundation. All Rights Reserved.