com.berryworks.edireader
Class PluginController

java.lang.Object
  extended by com.berryworks.edireader.PluginController

public class PluginController
extends java.lang.Object

Determines and maintains state transitions for the segment looping structure within a particular EDI document.

An EDI parser delegates the job of detecting segment loop boundaries to a PluginController. This allows the EDI parsers for ANSI and EDIFACT to be fully consistent with their use of plugins and focus on the specifics of the particular EDI standard.

This base implementation of PluginController provides the normal segment loop support based on LoopDescriptors in Plugins. It is possible, however, to extend this behavior by subclassing PluginController and Plugin. A ValidatingPlugin is one example, which provides for certain EDI validation rules, beyond those applied by normal EDIReader parsing, to be applied while a document is being parsed. Another example is a FilteringPlugin, which allows a plugin to provide custom logic to filter out certain LoopDescriptors based on run-time decisions.

See Also:
Plugin, LoopDescriptor, com.berryworks.edireader.validator.FilteringPluginController, com.berryworks.edireader.validator.ValidatingPluginController

Constructor Summary
PluginController()
           
 
Method Summary
 int closedCount()
          Get the number of loops that were closed as the result of the most recent state transition.
static PluginController create(java.lang.String standard, java.lang.String docType, java.lang.String docVersion, java.lang.String docRelease, com.berryworks.edireader.tokenizer.Tokenizer tokenizer)
          Creates a new instance of a PluginController, selecting a plugin based on the standard, the type of document, and the version and release characteristics.
static PluginController create(java.lang.String standard, java.lang.String docType, com.berryworks.edireader.tokenizer.Tokenizer tokenizer)
          Creates a new instance of a PluginController, selecting a plugin based on the standard and type of document.
 java.lang.String getDocumentName()
          Returns the document name associated with the plugin.
 java.lang.String getLoopEntered()
          Return the name of a loop that was entered as the result of the most recent transition.
 int getNestingLevel()
          Get the nesting level of the current loop.
 Plugin getPlugin()
          Returns the Plugin used by this PluginController.
 boolean isEnabled()
          Returns true if this controller is currently enabled.
 boolean isResumed()
          Returns true if the most recent loop transition was to resume an outer loop.
 java.lang.String lastPluginLoaded()
          Returns the class name of the most recently loaded plugin.
static void setDebug(boolean d)
          Sets debugging on or off.
 boolean transition(java.lang.String segmentName)
          Compute a state transition that may have occurred as the result of the presence of a particular segment type at this point in parsing the document.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PluginController

public PluginController()
Method Detail

create

public static PluginController create(java.lang.String standard,
                                      java.lang.String docType,
                                      com.berryworks.edireader.tokenizer.Tokenizer tokenizer)
Creates a new instance of a PluginController, selecting a plugin based on the standard and type of document.

Parameters:
standard -
docType -
tokenizer -
Returns:
instance

create

public static PluginController create(java.lang.String standard,
                                      java.lang.String docType,
                                      java.lang.String docVersion,
                                      java.lang.String docRelease,
                                      com.berryworks.edireader.tokenizer.Tokenizer tokenizer)
Creates a new instance of a PluginController, selecting a plugin based on the standard, the type of document, and the version and release characteristics.

This factory method delegates to the corresponding create method on a PluginControllerImpl, if such a class is available. If not, then this factory method simply returns an instance of this PluginController class, which supports the required interfaces but disables the entire plugin mechanism.

Parameters:
standard -
docType -
docVersion -
docRelease -
tokenizer -
Returns:
instance

transition

public boolean transition(java.lang.String segmentName)
                   throws EDISyntaxException
Compute a state transition that may have occurred as the result of the presence of a particular segment type at this point in parsing the document.

Parameters:
segmentName - type of segment encountered, for example: 837
Returns:
true if there was a transition to a new loop, false otherwise
Throws:
EDISyntaxException - Description of the Exception

getLoopEntered

public java.lang.String getLoopEntered()
Return the name of a loop that was entered as the result of the most recent transition.

Returns:
name of the entered loop, or null if no loop was entered

closedCount

public int closedCount()
Get the number of loops that were closed as the result of the most recent state transition. Re-entering the implicit outer loop does not count as a loop closing.

Returns:
Description of the Return Value

getNestingLevel

public int getNestingLevel()
Get the nesting level of the current loop.

Returns:
Description of the Return Value

isEnabled

public boolean isEnabled()
Returns true if this controller is currently enabled.

Returns:

getDocumentName

public java.lang.String getDocumentName()
Returns the document name associated with the plugin.

Returns:

getPlugin

public Plugin getPlugin()
Returns the Plugin used by this PluginController.

Returns:
Plugin

isResumed

public boolean isResumed()
Returns true if the most recent loop transition was to resume an outer loop.

Returns:

lastPluginLoaded

public java.lang.String lastPluginLoaded()
Returns the class name of the most recently loaded plugin.

Returns:

setDebug

public static void setDebug(boolean d)
Sets debugging on or off.

Parameters:
d -