org.apache.commons.flatfile
Class EntityCollectionSupport

java.lang.Object
  extended by org.apache.commons.flatfile.EntitySupport
      extended by org.apache.commons.flatfile.EntityCollectionSupport
All Implemented Interfaces:
Serializable, Cloneable, Entity, EntityCollection
Direct Known Subclasses:
EntityArray, EntityMap

public abstract class EntityCollectionSupport
extends EntitySupport
implements EntityCollection

Implementation of common operations for an EntityCollection.

Version:
$Revision: 758023 $ $Date: 2009-03-24 16:09:19 -0500 (Tue, 24 Mar 2009) $
See Also:
Serialized Form

Constructor Summary
EntityCollectionSupport()
           
 
Method Summary
 EntityCollectionSupport clone()
          Clone oneself.
 byte[] getDelim()
          Get the delimiter to use between children.
 byte[] getValue()
          Get the value of this Entity.
 boolean isDelimAfter()
          Learn whether a trailing delimiter will be added when a delimiter is being used.
 boolean isSuppressEmptyChildren()
          Get the boolean suppressEmptyChildren.
 int length()
          Get the length of this Entity.
 void readFrom(InputStream is)
          Read value from an InputStream.
 void setDelim(byte[] delim)
          Set the delimiter to use between children.
 void setDelimAfter(boolean delimAfter)
          Set whether to add a trailing delimiter when a delimiter is being used.
 void setSuppressEmptyChildren(boolean suppressEmptyChildren)
          Set the boolean suppressEmptyChildren.
 void setValue(byte[] b)
          Set this Entity's value.
 void setValue(byte[] b, int offset, int length)
          Set this Entity's value to a subset of the specified byte[].
protected  boolean shouldSuppress(Entity child)
          Learn whether the specified child should be suppressed.
 void writeTo(OutputStream os)
          Write value to an OutputStream.
 
Methods inherited from class org.apache.commons.flatfile.EntitySupport
fill, getValue
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.flatfile.EntityCollection
getChildren
 
Methods inherited from interface org.apache.commons.flatfile.Entity
fill, getValue
 

Constructor Detail

EntityCollectionSupport

public EntityCollectionSupport()
Method Detail

length

public final int length()
Get the length of this Entity.

Specified by:
length in interface Entity
Returns:
int

readFrom

public final void readFrom(InputStream is)
                    throws IOException
Read value from an InputStream.

Specified by:
readFrom in interface Entity
Parameters:
is - to read
Throws:
IOException - on error

writeTo

public final void writeTo(OutputStream os)
                   throws IOException
Write value to an OutputStream.

Specified by:
writeTo in interface Entity
Parameters:
os - to write to
Throws:
IOException - on error

getValue

public final byte[] getValue()
Get the value of this Entity.

Specified by:
getValue in interface Entity
Returns:
byte[]

setValue

public final void setValue(byte[] b)
Set this Entity's value.

Specified by:
setValue in interface Entity
Parameters:
b - byte[]

setValue

public final void setValue(byte[] b,
                           int offset,
                           int length)
Set this Entity's value to a subset of the specified byte[].

Specified by:
setValue in interface Entity
Overrides:
setValue in class EntitySupport
Parameters:
b - byte[]
offset - int
length - int

isDelimAfter

public boolean isDelimAfter()
Learn whether a trailing delimiter will be added when a delimiter is being used.

Returns:
boolean.

setDelimAfter

public void setDelimAfter(boolean delimAfter)
Set whether to add a trailing delimiter when a delimiter is being used. Default is true.

Parameters:
delimAfter - The boolean delimAfter to set.

getDelim

public byte[] getDelim()
Get the delimiter to use between children.

Returns:
byte[].

setDelim

public void setDelim(byte[] delim)
Set the delimiter to use between children.

Parameters:
delim - The byte[] delimiter to set.

isSuppressEmptyChildren

public boolean isSuppressEmptyChildren()
Get the boolean suppressEmptyChildren.

Returns:
boolean

setSuppressEmptyChildren

public void setSuppressEmptyChildren(boolean suppressEmptyChildren)
Set the boolean suppressEmptyChildren.

Parameters:
suppressEmptyChildren - boolean

clone

public EntityCollectionSupport clone()
Clone oneself.

Specified by:
clone in interface Entity
Overrides:
clone in class EntitySupport
Returns:
a deep (or otherwise "safe") copy of this Entity.

shouldSuppress

protected boolean shouldSuppress(Entity child)
Learn whether the specified child should be suppressed.

Parameters:
child - to check
Returns:
boolean


Copyright © 2008-2009 The Apache Software Foundation. All Rights Reserved.