flattree.tree
Class FixedLengthLeaf

java.lang.Object
  extended by flattree.tree.AbstractLeaf
      extended by flattree.tree.ValueLeaf
          extended by flattree.tree.FixedLengthLeaf
All Implemented Interfaces:
Leaf
Direct Known Subclasses:
PaddedFixedLengthLeaf

public class FixedLengthLeaf
extends ValueLeaf

An Leaf which writes and reads characters bounded by a fixed length.

See Also:
setLength(int)

Field Summary
 
Fields inherited from interface flattree.tree.Leaf
REQUIRED
 
Constructor Summary
FixedLengthLeaf()
           
FixedLengthLeaf(String name, int length)
           
FixedLengthLeaf(String name, int length, boolean lengthRequired)
           
 
Method Summary
 int getLength()
           
 boolean getLengthRequired()
           
protected  String read(StringBuilder builder)
           
 String readValue(ReadLine line)
          Read this leaf's value from the given line.
 void setLength(int length)
          Set the length.
 void setLengthRequired(boolean required)
           
 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
 

Constructor Detail

FixedLengthLeaf

public FixedLengthLeaf()

FixedLengthLeaf

public FixedLengthLeaf(String name,
                       int length)

FixedLengthLeaf

public FixedLengthLeaf(String name,
                       int length,
                       boolean lengthRequired)
Method Detail

getLength

public int getLength()

setLength

public void setLength(int length)
Set the length.

Parameters:
length - length
Throws:
IllegalArgumentException - if length is less than 0

getLengthRequired

public boolean getLengthRequired()

setLengthRequired

public void setLengthRequired(boolean required)

writeValue

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

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)

read

protected String read(StringBuilder builder)


Copyright © 2011. All Rights Reserved.