net.sf.japaki.text
Class CollectionParser<E>

java.lang.Object
  extended by net.sf.japaki.text.AbstractParser<Collection<E>>
      extended by net.sf.japaki.text.CollectionParser<E>
All Implemented Interfaces:
Parser<Collection<E>>

public class CollectionParser<E>
extends AbstractParser<Collection<E>>

Parser for collections.


Constructor Summary
protected CollectionParser(Parser<SinglePropertyBean<E>> parser, Parser<Object> delimiterParser)
          Creates a new collection parser based on the specified parser.
 
Method Summary
static
<E> Parser<Collection<E>>
newParser(Parser<? super E> parser, Factory<? extends E> factory, Parser<Object> delimiterParser)
          Creates a new collection parser based on the specified parser.
static
<E> Parser<Collection<E>>
newParser(Parser<? super E> parser, Factory<? extends E> factory, String delimiter)
          Creates a new collection parser based on the specified parser.
static
<E> Parser<Collection<E>>
newParser(Parser<SinglePropertyBean<E>> parser, Parser<Object> delimiterParser)
          Creates a new collection parser based on the specified parser.
protected  void parseIt(ParseReader in, Collection<E> target)
          Parses text starting at the specified position.
 String treeView()
          Returns a tree view of this parser.
protected  void writeIt(ParseWriter out, Collection<E> source)
          Formats the source object and writes it into the output stream
 
Methods inherited from class net.sf.japaki.text.AbstractParser
getLogger, handleException, parse, toString, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CollectionParser

protected CollectionParser(Parser<SinglePropertyBean<E>> parser,
                           Parser<Object> delimiterParser)
Creates a new collection parser based on the specified parser.

Parameters:
parser - element parser
delimiterParser - parser for tokens between elements
Throws:
NullPointerException - if parser is null
Method Detail

newParser

public static <E> Parser<Collection<E>> newParser(Parser<SinglePropertyBean<E>> parser,
                                                  Parser<Object> delimiterParser)
Creates a new collection parser based on the specified parser.

Parameters:
parser - element parser
delimiterParser - parser for tokens between elements
Throws:
NullPointerException - if parser is null

newParser

public static <E> Parser<Collection<E>> newParser(Parser<? super E> parser,
                                                  Factory<? extends E> factory,
                                                  Parser<Object> delimiterParser)
Creates a new collection parser based on the specified parser.

Parameters:
parser - element parser
factory - used to create a new element if it does not exist yet
delimiterParser - parser for tokens between elements
Throws:
NullPointerException - if parser or factory is null

newParser

public static <E> Parser<Collection<E>> newParser(Parser<? super E> parser,
                                                  Factory<? extends E> factory,
                                                  String delimiter)
Creates a new collection parser based on the specified parser.

Parameters:
parser - element parser
factory - used to create a new element if it does not exist yet
delimiter - a constant expected and formatted between collection elements
Throws:
NullPointerException - if any parameter is null

parseIt

protected void parseIt(ParseReader in,
                       Collection<E> target)
                throws IOException
Description copied from class: AbstractParser
Parses text starting at the specified position.

Specified by:
parseIt in class AbstractParser<Collection<E>>
Parameters:
in - the position where to start parsing
target - place where the parsed object is stored.
Throws:
NullPointerException - if in or target or one of its (sub-) properties is null and the parser cannot handle it
BeanStoreException - if the parsed value could not be stored
IOException - if an I/O error occurs

writeIt

protected void writeIt(ParseWriter out,
                       Collection<E> source)
                throws IOException,
                       FormatException
Description copied from class: AbstractParser
Formats the source object and writes it into the output stream

Specified by:
writeIt in class AbstractParser<Collection<E>>
Parameters:
out - the stream and position where to put the formatted text.
source - source object
Throws:
NullPointerException - if out is null
IOException - if an I/O error occurs
FormatException - if the source object can not be formatted with this parser.

treeView

public String treeView()
Description copied from interface: Parser
Returns a tree view of this parser.

Returns:
a tree view of this parser