org.tridas.io.defaults
Class AbstractDefaultValue<E>

java.lang.Object
  extended by org.tridas.io.defaults.AbstractDefaultValue<E>
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
BooleanDefaultValue, DateTimeDefaultValue, DoubleDefaultValue, GenericDefaultValue, IntegerDefaultValue, SafeIntYearDefaultValue, SheffieldStringDefaultValue, StringDefaultValue

public abstract class AbstractDefaultValue<E>
extends Object
implements Cloneable

Author:
Daniel

Constructor Summary
AbstractDefaultValue()
           
AbstractDefaultValue(int argMaxLength, int argMinLength)
           
 
Method Summary
 Object clone()
           
 Enum<?> getKey()
          The enum key that this object is mapped from
 int getMaxLength()
          The maximum string length
 int getMinLength()
          The minimum string length
 IMetadataFieldSet getParent()
           
 String getStringValue()
          Gets the string representation of the value.
abstract  E getValue()
          Gets the value.
 boolean isOverriding()
          If the value in this object is overriding.
 boolean isPadRight()
          If we pad the string from the right if it's too short.
protected  void setKey(Enum<?> argKey)
           
 void setMaxLength(int argMaxLength)
          Sets the maximum string length.
 void setMinLength(int argMinLength)
          Sets the minimum string length.
 void setOverriding(boolean argOverriding)
          If the value in this object is overriding.
 boolean setOverridingValue(E argValue)
          Sets the value that will override other calls to setValue(Object).
 void setPadRight(boolean padRight)
          Sets if we pad from the right if the string is too short.
protected  void setParent(IMetadataFieldSet argParent)
           
 boolean setValue(E argValue)
          Sets the value of this field.
protected abstract  boolean validateAndSetValue(E argValue)
          Validate and set the value.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDefaultValue

public AbstractDefaultValue()

AbstractDefaultValue

public AbstractDefaultValue(int argMaxLength,
                            int argMinLength)
Parameters:
argMaxLength - maximum length of returned string. -1 disables
argMinLength - minimum length of returned string. -1 disables
Method Detail

setKey

protected void setKey(Enum<?> argKey)

getKey

public Enum<?> getKey()
The enum key that this object is mapped from

Returns:

setParent

protected void setParent(IMetadataFieldSet argParent)

getParent

public IMetadataFieldSet getParent()
Returns:
the parent

setValue

public boolean setValue(E argValue)
Sets the value of this field.

Parameters:
argValue -
Returns:
if the value is set. If false, that means the value wasn't valid, or it's being overridden (see setOverridingValue(Object) and setOverriding(boolean)).

validateAndSetValue

protected abstract boolean validateAndSetValue(E argValue)
Validate and set the value.

Parameters:
argValue - the value, can be null.
Returns:
true if valid and set, false if not set and invalid

setOverridingValue

public boolean setOverridingValue(E argValue)
Sets the value that will override other calls to setValue(Object). To turn overriding off call setOverriding(boolean). if the value isn't valid, then overriding is not turned on.

Parameters:
argValue -
Returns:
if the value was set. if false, that means it wasn't valid

getValue

public abstract E getValue()
Gets the value.

Returns:
the value. can be null

getStringValue

public String getStringValue()
Gets the string representation of the value. If setMinLength(int) is set, then the string will be padded. If getValue() is null, an empty string is returned (if minLength is set, then it is padded as well).

Returns:

isOverriding

public boolean isOverriding()
If the value in this object is overriding. If this is true, values set with setOverridingValue(Object) do not change the value. Default of false.

Returns:

setOverriding

public void setOverriding(boolean argOverriding)
If the value in this object is overriding. If this is true, values set with setOverridingValue(Object) do not change the value. Default of false.

Parameters:
argOverriding -

setMaxLength

public void setMaxLength(int argMaxLength)
Sets the maximum string length. Use '-1' to not enforce this

Parameters:
maxLength - the maxLength to set

getMaxLength

public int getMaxLength()
The maximum string length

Returns:
the maxLength

setMinLength

public void setMinLength(int argMinLength)
Sets the minimum string length. Use '-1' to not enforce this

Parameters:
minLength - the minLength to set

getMinLength

public int getMinLength()
The minimum string length

Returns:
the minLength

setPadRight

public void setPadRight(boolean padRight)
Sets if we pad from the right if the string is too short. If false, we pad from the left

Parameters:
padRight - the padRight to set

isPadRight

public boolean isPadRight()
If we pad the string from the right if it's too short.

Returns:
the padRight

clone

public Object clone()
Overrides:
clone in class Object


Copyright © 2011. All Rights Reserved.