net.sf.japaki.self
Class SyntaxParser

java.lang.Object
  extended by net.sf.japaki.self.SyntaxParser

public class SyntaxParser
extends Object

Provides a parser for syntax definitions. The parser accepts the following patterns:

pattern description parser bean
abc A constant in the in- or output stream. LeafParser ConstantParserBean
<property> Selects the parser based on the property type. LeafParser LeafParserBean
<property,,"pattern"> Selects the parser based on the property type and uses the pattern. LeafParser LeafParserBean
<property,parserName> Uses the parser stored under parserName to parse the property. LeafParser LeafParserBean
<property,parserName,"pattern"> Uses the parser stored under parserName to parse the property and uses the pattern. LeafParser LeafParserBean
<property,,subParser,delimiter> Parses a collection with the specified subparser. CollectionParser LeafParserBean
<property,,subParser,delimiter> Parses a map with the specified subparser. MapParser LeafParserBean
\n A line break. LineFeed FixedParserBean
parser1parser2parser3 The parsers are used one after another. BeanParser BeanParserBean
[parser] The parsers is only used if possible (if no exception is thrown). OptionalParser OptionalParserBean
(parser1|parser2|parser3) Exactly one of the parsers is used. ChoiceParser ChoiceParserBean


Constructor Summary
protected SyntaxParser()
           
 
Method Summary
protected
<B,T extends B>
void
add(String name, Parser<B> parser, Class<T> type)
          Adds a parser to the parser store
protected  void addParsersToEntry(ArrayList<Parser<? super SinglePropertyBean<ParserBean>>> parsers)
          Adds the parsers to the main choice parser.
protected  void fillStore()
          Adds the parser definitions of the syntax parser to the store.
protected  ParserStore getParserStore()
          Returns the underlying parser store.
static Parser<BeanParserBean> getSyntaxParser()
          Returns the main parser
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SyntaxParser

protected SyntaxParser()
Method Detail

getParserStore

protected final ParserStore getParserStore()
Returns the underlying parser store.

Returns:
the underlying parser store

add

protected <B,T extends B> void add(String name,
                                   Parser<B> parser,
                                   Class<T> type)
Adds a parser to the parser store

Parameters:
name - see ParserStore
parser - see ParserStore
type - see ParserStore

fillStore

protected void fillStore()
Adds the parser definitions of the syntax parser to the store.


addParsersToEntry

protected void addParsersToEntry(ArrayList<Parser<? super SinglePropertyBean<ParserBean>>> parsers)
Adds the parsers to the main choice parser. this is the anchor for changes in subclasses.

Parameters:
parsers - parsers that are options for an entry

getSyntaxParser

public static Parser<BeanParserBean> getSyntaxParser()
Returns the main parser

Returns:
the main parser