org.apache.commons.flatfile
Class DynamicField

java.lang.Object
  extended by org.apache.commons.flatfile.EntitySupport
      extended by org.apache.commons.flatfile.FieldSupport
          extended by org.apache.commons.flatfile.PadJustifyFieldSupport
              extended by org.apache.commons.flatfile.DynamicField
All Implemented Interfaces:
Serializable, Cloneable, Entity
Direct Known Subclasses:
InputFilteringDynamicField

public class DynamicField
extends PadJustifyFieldSupport

Dynamically-resizable field. Supports pad/justify, but only relevant when an assigned value is too small for the field AND underflow == IGNORE.

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

Nested Class Summary
static class DynamicField.Bounds
          Bounds
 
Nested classes/interfaces inherited from class org.apache.commons.flatfile.PadJustifyFieldSupport
PadJustifyFieldSupport.Justify
 
Nested classes/interfaces inherited from class org.apache.commons.flatfile.FieldSupport
FieldSupport.Overflow, FieldSupport.Underflow
 
Constructor Summary
DynamicField()
          Create a new DynamicField.
DynamicField(DynamicField.Bounds bounds)
          Create a new DynamicField.
 
Method Summary
 DynamicField clone()
          Clone oneself.
 boolean equals(Object other)
          
 DynamicField.Bounds getBounds()
          Get the bounds.
 FieldSupport.Overflow getOverflow()
          Get the overflow.
protected  int getPadJustifyLength()
          Provide the desired target length for padding/justification actions.
 FieldSupport.Underflow getUnderflow()
          Get the underflow.
 byte[] getValue()
          Get the value of this Entity.
 int hashCode()
          
protected  void iSetValue(byte[] value)
          Protected inner setValue
 int length()
          Get the length of this Entity.
 void readFrom(InputStream is)
          Read up to maximumLength bytes from the specified InputStream or stop at EOF.
 void setBounds(DynamicField.Bounds bounds)
          Set the bounds.
 void setOverflow(FieldSupport.Overflow overflow)
          Set the overflow.
 void setUnderflow(FieldSupport.Underflow underflow)
          Set the underflow.
 void setValue(byte[] b)
          Implement pad/justify.
 void writeTo(OutputStream os)
          Write value to an OutputStream.
 
Methods inherited from class org.apache.commons.flatfile.PadJustifyFieldSupport
getJustify, getPad, setJustify, setPad
 
Methods inherited from class org.apache.commons.flatfile.FieldSupport
dieOnExceptionRead
 
Methods inherited from class org.apache.commons.flatfile.EntitySupport
fill, getValue, setValue
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicField

public DynamicField()
Create a new DynamicField.


DynamicField

public DynamicField(DynamicField.Bounds bounds)
Create a new DynamicField.

Parameters:
bounds - bounds
Method Detail

getValue

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

Returns:
byte[]

length

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

Returns:
int

readFrom

public void readFrom(InputStream is)
              throws IOException
Read up to maximumLength bytes from the specified InputStream or stop at EOF. This will rarely be what you want. Instead, consider using InputFilteringDynamicField. In the case that < minimumLength bytes are available from is the justify and pad options come into play.

Parameters:
is - the InputStream from which to read data.
Throws:
IOException - on problems with I/O, duh...

setValue

public void setValue(byte[] b)
Implement pad/justify.

Specified by:
setValue in interface Entity
Overrides:
setValue in class PadJustifyFieldSupport
Parameters:
b - value set

writeTo

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

Parameters:
os - to write to
Throws:
IOException - on error

getOverflow

public FieldSupport.Overflow getOverflow()
Get the overflow.

Returns:
Overflow

setOverflow

public void setOverflow(FieldSupport.Overflow overflow)
Set the overflow.

Parameters:
overflow - Overflow

getUnderflow

public FieldSupport.Underflow getUnderflow()
Get the underflow.

Returns:
Underflow

setUnderflow

public void setUnderflow(FieldSupport.Underflow underflow)
Set the underflow.

Parameters:
underflow - Underflow

hashCode

public int hashCode()

Overrides:
hashCode in class Object

equals

public boolean equals(Object other)

Overrides:
equals in class Object

getPadJustifyLength

protected int getPadJustifyLength()
Provide the desired target length for padding/justification actions.

Specified by:
getPadJustifyLength in class PadJustifyFieldSupport
Returns:
int

iSetValue

protected void iSetValue(byte[] value)
Protected inner setValue

Parameters:
value - byte[]

clone

public DynamicField clone()
Clone oneself.

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

getBounds

public DynamicField.Bounds getBounds()
Get the bounds.

Returns:
Bounds

setBounds

public void setBounds(DynamicField.Bounds bounds)
Set the bounds.

Parameters:
bounds - Bounds


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