org.mmbase.datatypes
Class AbstractLengthDataType

java.lang.Object
  extended byorg.mmbase.core.AbstractDescriptor
      extended byorg.mmbase.datatypes.BasicDataType
          extended byorg.mmbase.datatypes.AbstractLengthDataType
All Implemented Interfaces:
Cloneable, Comparable, DataType, Descriptor, LengthDataType, Serializable
Direct Known Subclasses:
BinaryDataType, ListDataType, XmlDataType

public abstract class AbstractLengthDataType
extends BasicDataType
implements LengthDataType

A LengthDataType is a datatype that defines a length for its values (getLength(Object)) , and restrictions on that (minimal an maximal length).

Since:
MMBase-1.8
Version:
$Id: AbstractLengthDataType.java,v 1.13 2006/04/10 15:23:55 michiel Exp $
Author:
Pierre van Rooden, Michiel Meeuwissen
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.mmbase.datatypes.BasicDataType
BasicDataType.AbstractRestriction, BasicDataType.EnumerationRestriction, BasicDataType.RequiredRestriction, BasicDataType.RestrictedEnumerationIterator, BasicDataType.StaticAbstractRestriction, BasicDataType.TypeRestriction, BasicDataType.UniqueRestriction
 
Nested classes inherited from class org.mmbase.datatypes.DataType
DataType.Restriction
 
Field Summary
protected  org.mmbase.datatypes.AbstractLengthDataType.MaxRestriction maxLengthRestriction
           
protected  org.mmbase.datatypes.AbstractLengthDataType.MinRestriction minLengthRestriction
           
 
Fields inherited from class org.mmbase.datatypes.BasicDataType
DATATYPE_BUNDLE, enumerationRestriction, origin, requiredRestriction, typeRestriction, uniqueRestriction
 
Fields inherited from class org.mmbase.core.AbstractDescriptor
description, guiName, key
 
Fields inherited from interface org.mmbase.datatypes.DataType
ENFORCE_ABSOLUTE, ENFORCE_ALWAYS, ENFORCE_NEVER, ENFORCE_ONCHANGE, ENFORCE_ONCREATE, PROCESS_GET, PROCESS_SET, VALID, XMLNS
 
Constructor Summary
AbstractLengthDataType(String name, Class classType)
          Constructor for big data field.
 
Method Summary
protected  void cloneRestrictions(BasicDataType origin)
          If a datatype is cloned, the restrictions of it (normally implemented as inner classes), must be reinstantiated.
abstract  long getLength(Object value)
          In this method should be implemented how to calculate such a length for a certain value of this datatype. There does not exist a generic interface for this, so the implementation will cast to the expected type (String, byte[]..)
 long getMaxLength()
          Returns the maximum length of binary values for this datatype.
 DataType.Restriction getMaxLengthRestriction()
          Returns the 'maxLength' restriction, containing the value, errormessages, and fixed status of this attribute.
 long getMinLength()
          Returns the minimum length of binary values for this datatype.
 DataType.Restriction getMinLengthRestriction()
          Returns the 'minLength' restriction, containing the value, errormessages, and fixed status of this attribute.
protected  void inheritRestrictions(BasicDataType origin)
          If a datatype inherits from another datatype all its restrictions inherit too.
 void setMaxLength(long value)
          Sets the maximum length of binary values for this datatype.
 void setMinLength(long value)
          Sets the minimum length of binary values for this datatype.
protected  StringBuffer toStringBuffer()
           
protected  Collection validateCastedValue(Collection errors, Object castedValue, Object value, Node node, Field field)
           
 
Methods inherited from class org.mmbase.datatypes.BasicDataType
cast, cast, castToValidate, checkType, clone, clone, compareTo, edit, equals, finish, finish, getBaseType, getBaseTypeIdentifier, getCloud, getCommitProcessor, getDefaultValue, getElement, getElement, getEnumerationFactory, getEnumerationRestriction, getEnumerationValue, getEnumerationValues, getOrigin, getProcessor, getProcessor, getRequiredRestriction, getTypeAsClass, getUniqueRestriction, hashCode, inherit, inheritProperties, isCorrectType, isFinished, isRequired, isUnique, preCast, preCast, preCast, rewrite, setCommitProcessor, setDefaultValue, setProcessor, setProcessor, setRequired, setUnique, setXml, toString, toXml, toXml, validate, validate
 
Methods inherited from class org.mmbase.core.AbstractDescriptor
getDefaultLocale, getDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUIName, setLocalizedDescription, setLocalizedGUIName
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mmbase.datatypes.DataType
cast, checkType, clone, clone, finish, getBaseType, getBaseTypeIdentifier, getCommitProcessor, getDefaultValue, getEnumerationFactory, getEnumerationRestriction, getEnumerationValue, getEnumerationValues, getOrigin, getProcessor, getProcessor, getRequiredRestriction, getTypeAsClass, getUniqueRestriction, inherit, isFinished, isRequired, isUnique, preCast, rewrite, setCommitProcessor, setDefaultValue, setProcessor, setProcessor, setRequired, setUnique, toXml, toXml, validate, validate
 
Methods inherited from interface org.mmbase.bridge.Descriptor
getDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUIName
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

minLengthRestriction

protected org.mmbase.datatypes.AbstractLengthDataType.MinRestriction minLengthRestriction

maxLengthRestriction

protected org.mmbase.datatypes.AbstractLengthDataType.MaxRestriction maxLengthRestriction
Constructor Detail

AbstractLengthDataType

public AbstractLengthDataType(String name,
                              Class classType)
Constructor for big data field.

Parameters:
name - the name of the data type
classType - the class of the data type's possible value
Method Detail

cloneRestrictions

protected void cloneRestrictions(BasicDataType origin)
Description copied from class: BasicDataType
If a datatype is cloned, the restrictions of it (normally implemented as inner classes), must be reinstantiated.

Overrides:
cloneRestrictions in class BasicDataType

inheritRestrictions

protected void inheritRestrictions(BasicDataType origin)
Description copied from class: BasicDataType
If a datatype inherits from another datatype all its restrictions inherit too.

Overrides:
inheritRestrictions in class BasicDataType

getLength

public abstract long getLength(Object value)
In this method should be implemented how to calculate such a length for a certain value of this datatype. There does not exist a generic interface for this, so the implementation will cast to the expected type (String, byte[]..)

Specified by:
getLength in interface LengthDataType

getMinLength

public long getMinLength()
Returns the minimum length of binary values for this datatype.

Specified by:
getMinLength in interface LengthDataType
Returns:
the minimum length as an int, or 0 if there is no minimum length.

getMinLengthRestriction

public DataType.Restriction getMinLengthRestriction()
Returns the 'minLength' restriction, containing the value, errormessages, and fixed status of this attribute.

Specified by:
getMinLengthRestriction in interface LengthDataType
Returns:
the restriction as a DataType.Restriction

setMinLength

public void setMinLength(long value)
Sets the minimum length of binary values for this datatype.

Specified by:
setMinLength in interface LengthDataType
Parameters:
value - the minimum length as an long, or 0 if there is no minimum length.

getMaxLength

public long getMaxLength()
Returns the maximum length of binary values for this datatype.

Specified by:
getMaxLength in interface LengthDataType
Returns:
the maximum length as an long, or a very very big value (Long.MAX_VALUE) if there is no maximum length.

getMaxLengthRestriction

public DataType.Restriction getMaxLengthRestriction()
Returns the 'maxLength' restriction, containing the value, errormessages, and fixed status of this attribute.

Specified by:
getMaxLengthRestriction in interface LengthDataType
Returns:
the restriction as a DataType.Restriction

setMaxLength

public void setMaxLength(long value)
Sets the maximum length of binary values for this datatype.

Specified by:
setMaxLength in interface LengthDataType
Parameters:
value - the maximum length as an int, or -1 if there is no maximum length.
Throws:
Class - Identifier: java.lang.UnsupportedOperationException if this datatype is finished

validateCastedValue

protected Collection validateCastedValue(Collection errors,
                                         Object castedValue,
                                         Object value,
                                         Node node,
                                         Field field)
Overrides:
validateCastedValue in class BasicDataType

toStringBuffer

protected StringBuffer toStringBuffer()
Overrides:
toStringBuffer in class BasicDataType


MMBase build 1.8.1.20060716