com.berryworks.edireader
Class ParserRegistry

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

public class ParserRegistry
extends java.lang.Object

Data structure that associates leading character sequences with specific parser implementations. When an EDI or EDI-like stream of data is to be parsed without pre-knowledge of which particular EDI standard is to be used, this parser registry is used to select a parser based on the initial characters of data.

The parsers for ANSI X.12 and UN/EDIFACT are included in the registry be default. The classes that implement these parsers are provided by the core EDIReader framework.

Parsers for other formats, including HL7, ACH, and NSF, are also listed in the registry. The classes that implement these formats are optional modules not included in the core EDIReader framework. If an optional parser module is present in the classpath, the registry is therefore able to select and load the appropriate parser in response to the leading character sequences in the data.

It is also possible for a developer to implement a parser for an EDI-like data format and register that parser along with the leading data characters which signal the instance of an interchange of that format. In this way, the EDIReader framework can be extended to parse previously unsupported data formats in the same way that it supports X12 and EDIFACT.


Method Summary
static EDIReader get(java.lang.String firstChars)
          Returns an instance of some EDIReader subclass based on the first several chars of data to be parsed.
static void register(java.lang.String firstChars, java.lang.String className)
          Registers a parser and associates it with the leading data characters that signal an instance of an interchange supported by the parser.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

get

public static EDIReader get(java.lang.String firstChars)
Returns an instance of some EDIReader subclass based on the first several chars of data to be parsed.

Parsers for ANSI X12 and UN/EDIFACT are built-in. Other parsers can be registered, including custom parsers developed by users. Parsers registered via register() are considered first for a match with the incoming data before the built-in parsers are considered, allowing users to provide custom implementations of X12 and EDIFACT parsers if needed.

Parameters:
firstChars - of data to be parsed
Returns:
subclass of EDIReader that knows how to parse the data, or null if no parser is available

register

public static void register(java.lang.String firstChars,
                            java.lang.String className)
Registers a parser and associates it with the leading data characters that signal an instance of an interchange supported by the parser.

Parameters:
firstChars - of data to be parsed
className - fully qualified classname of an EDIReader subclass