flattree.tree
Class DelimitedLeaf

java.lang.Object
  extended by flattree.tree.AbstractLeaf
      extended by flattree.tree.ValueLeaf
          extended by flattree.tree.DelimitedLeaf
All Implemented Interfaces:
Leaf
Direct Known Subclasses:
EscapedDelimitedLeaf, QuotedDelimitedLeaf

public class DelimitedLeaf
extends ValueLeaf

A Leaf which writes and reads characters bounded by a delimiter. The delimiter can be configured to be optional or required.

See Also:
setDelimiter(char)

Field Summary
static char DEFAULT_DELIMITER
          The default delimiter (if none is configured) is set to ReadLine.END.
 
Fields inherited from interface flattree.tree.Leaf
REQUIRED
 
Constructor Summary
DelimitedLeaf()
           
DelimitedLeaf(String name, char delimiter)
           
DelimitedLeaf(String name, char delimiter, boolean delimiterRequired)
           
 
Method Summary
 char getDelimiter()
           
 boolean getDelimiterRequired()
           
protected  boolean isDelimiter(char character)
           
 String readValue(ReadLine line)
          Read this leaf's value from the given line.
 void setDelimiter(char delimiter)
          Set the delimiter.
 void setDelimiterRequired(boolean required)
          Does reading fail if no delimiter is found.
protected  void writeDelimiter(WriteLine line)
           
 void writeValue(WriteLine line, String value)
           
 
Methods inherited from class flattree.tree.ValueLeaf
getName, readImpl, setName, writeImpl
 
Methods inherited from class flattree.tree.AbstractLeaf
getThrowOnRead, read, setThrowOnRead, throwOnRead, throwOnRead, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DELIMITER

public static final char DEFAULT_DELIMITER
The default delimiter (if none is configured) is set to ReadLine.END.

See Also:
getDelimiter(), Constant Field Values
Constructor Detail

DelimitedLeaf

public DelimitedLeaf()

DelimitedLeaf

public DelimitedLeaf(String name,
                     char delimiter)

DelimitedLeaf

public DelimitedLeaf(String name,
                     char delimiter,
                     boolean delimiterRequired)
Method Detail

getDelimiter

public char getDelimiter()

setDelimiter

public void setDelimiter(char delimiter)
Set the delimiter.

Parameters:
delimiter - any character to be used as delimiter, a ReadLine.END will not be written

getDelimiterRequired

public boolean getDelimiterRequired()

setDelimiterRequired

public void setDelimiterRequired(boolean required)
Does reading fail if no delimiter is found.

Parameters:
required - is the delimiter required
See Also:
AbstractLeaf.throwOnRead(String, ReadLine)

isDelimiter

protected boolean isDelimiter(char character)

writeValue

public void writeValue(WriteLine line,
                       String value)
Specified by:
writeValue in class ValueLeaf

writeDelimiter

protected void writeDelimiter(WriteLine line)

readValue

public String readValue(ReadLine line)
Description copied from class: ValueLeaf
Read this leaf's value from the given line.

Specified by:
readValue in class ValueLeaf
Parameters:
line - line to read from
Returns:
value or null if this leaf cannot be read from the given line
See Also:
AbstractLeaf.setThrowOnRead(boolean)


Copyright © 2011. All Rights Reserved.