org.mmbase.datatypes
Class AbstractLengthDataType<E>

Package class diagram package AbstractLengthDataType
java.lang.Object
  extended by org.mmbase.bridge.util.AbstractDescriptor
      extended by org.mmbase.datatypes.BasicDataType<E>
          extended by org.mmbase.datatypes.AbstractLengthDataType<E>
All Implemented Interfaces:
Serializable, Cloneable, Comparable<DataType<E>>, Descriptor, DataType<E>, LengthDataType<E>, PublicCloneable<AbstractDescriptor>
Direct Known Subclasses:
BinaryDataType, ListDataType, XmlDataType

public abstract class AbstractLengthDataType<E>
extends BasicDataType<E>
implements LengthDataType<E>

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 45316 2011-02-18 20:47:28Z michiel $
Author:
Pierre van Rooden, Michiel Meeuwissen
See Also:
Serialized Form

Nested Class Summary
protected static class AbstractLengthDataType.MaxRestriction
           
protected static class AbstractLengthDataType.MinRestriction
           
 
Nested classes/interfaces inherited from class org.mmbase.datatypes.BasicDataType
BasicDataType.AbstractRestriction<D extends Serializable>, BasicDataType.DataTypeComparator<D>, BasicDataType.EnumerationRestriction, BasicDataType.RequiredRestriction, BasicDataType.RestrictedEnumerationIterator, BasicDataType.StaticAbstractRestriction<D extends Serializable>, BasicDataType.TypeRestriction, BasicDataType.UniqueRestriction
 
Nested classes/interfaces inherited from interface org.mmbase.datatypes.DataType
DataType.Restriction<D extends Serializable>
 
Field Summary
protected  AbstractLengthDataType.MaxRestriction maxLengthRestriction
           
protected  AbstractLengthDataType.MinRestriction minLengthRestriction
           
 
Fields inherited from class org.mmbase.datatypes.BasicDataType
DATATYPE_BUNDLE, defaultValue, enumerationRestriction, origin, requiredRestriction, typeRestriction, uniqueRestriction
 
Fields inherited from class org.mmbase.bridge.util.AbstractDescriptor
description, guiName, key
 
Fields inherited from interface org.mmbase.datatypes.DataType
ENFORCE_ABSOLUTE, ENFORCE_ALWAYS, ENFORCE_NEVER, ENFORCE_ONCHANGE, ENFORCE_ONCREATE, ENFORCE_ONVALIDATE, PROCESS_GET, PROCESS_SET, VALID, XMLNS
 
Constructor Summary
AbstractLengthDataType(String name, Class<E> classType)
          Constructor for big data field.
 
Method Summary
protected  void cloneRestrictions(BasicDataType<E> origin)
          If a datatype is cloned, the restrictions of it (normally implemented as inner classes), must be reinstantiated.
 int getEnforceStrength()
          The maximum enforce strength of all restrictions on this datatype.
abstract  long getLength(Object value)
          In this method should be implemented how to calculate such a length for a certain value of this datatype.
 long getMaxLength()
          Returns the maximum length of values for this datatype.
 DataType.Restriction<Long> getMaxLengthRestriction()
          Returns the 'maxLength' restriction, containing the value, errormessages, and fixed status of this attribute.
 long getMinLength()
          Returns the minimum length of values for this datatype.
 DataType.Restriction<Long> getMinLengthRestriction()
          Returns the 'minLength' restriction, containing the value, errormessages, and fixed status of this attribute.
protected  void inheritRestrictions(BasicDataType<E> 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  StringBuilder toStringBuilder()
           
 void toXml(Element parent)
          Fills this datatype in another XML (for example in the xml of DataType.getOrigin(), to make one XML, fully describing the DataType).
protected  Collection<LocalizedString> validateCastValue(Collection<LocalizedString> errors, Object castValue, Object value, Node node, Field field)
           
protected  Collection<LocalizedString> validateCastValueOrNull(Collection<LocalizedString> errors, Object castValue, Object value, Node node, Field field)
           
 
Methods inherited from class org.mmbase.datatypes.BasicDataType
addErrorDescription, addRestriction, addRestriction, addStyleClass, cast, cast, castAndValidate, castForSearch, castOrException, castToPresent, castToValidate, checkType, clone, clone, compareTo, edit, equals, finish, finish, getBaseType, getBaseTypeIdentifier, getCloud, getCloud, getCommitProcessor, getComparator, getDefaultProcessor, getDefaultValue, getDefaultValue, getDeleteProcessor, getElement, getElement, getEnforceString, getEnumerationFactory, getEnumerationRestriction, getEnumerationValue, getEnumerationValues, getHandler, getHandlers, getOrigin, getProcessor, getProcessor, getProcessorWithoutDefault, getRequiredRestriction, getRestrictions, getStyleClasses, getTypeAsClass, getUniqueRestriction, hashCode, inherit, inheritProperties, isCorrectType, isFinished, isRequired, isUnique, preCast, preCast, preCast, rewrite, setCommitProcessor, setDefaultProcessor, setDefaultValue, setDeleteProcessor, setProcessor, setProcessor, setRequired, setUnique, setXml, toString, toXml, validate, validate, validateRequired, xmlValue
 
Methods inherited from class org.mmbase.bridge.util.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, castAndValidate, castForSearch, castOrException, checkType, clone, clone, finish, getBaseType, getBaseTypeIdentifier, getCommitProcessor, getDefaultValue, getDefaultValue, getDeleteProcessor, getEnumerationFactory, getEnumerationRestriction, getEnumerationValue, getEnumerationValues, getHandler, getHandlers, getOrigin, getProcessor, getProcessor, getRequiredRestriction, getStyleClasses, getTypeAsClass, getUniqueRestriction, isFinished, isRequired, isUnique, preCast, rewrite, setCommitProcessor, setDefaultValue, setProcessor, setProcessor, setRequired, setUnique, 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 AbstractLengthDataType.MinRestriction minLengthRestriction

maxLengthRestriction

protected AbstractLengthDataType.MaxRestriction maxLengthRestriction
Constructor Detail

AbstractLengthDataType

public AbstractLengthDataType(String name,
                              Class<E> 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<E> 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<E>

inheritRestrictions

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

Overrides:
inheritRestrictions in class BasicDataType<E>

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<E>

getMinLength

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

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

getMinLengthRestriction

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

Specified by:
getMinLengthRestriction in interface LengthDataType<E>
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<E>
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 values for this datatype.

Specified by:
getMaxLength in interface LengthDataType<E>
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<Long> getMaxLengthRestriction()
Returns the 'maxLength' restriction, containing the value, errormessages, and fixed status of this attribute.

Specified by:
getMaxLengthRestriction in interface LengthDataType<E>
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<E>
Parameters:
value - the maximum length as an int, or -1 if there is no maximum length.
Throws:
Class<T> - Identifier: java.lang.UnsupportedOperationException if this datatype is finished

getEnforceStrength

public int getEnforceStrength()
Description copied from interface: DataType
The maximum enforce strength of all restrictions on this datatype. See DataType.ENFORCE_ALWAYS, DataType.ENFORCE_ONCHANGE, DataType.ENFORCE_NEVER.

Specified by:
getEnforceStrength in interface DataType<E>
Overrides:
getEnforceStrength in class BasicDataType<E>
Returns:
maximum enforce strength

validateCastValueOrNull

protected Collection<LocalizedString> validateCastValueOrNull(Collection<LocalizedString> errors,
                                                              Object castValue,
                                                              Object value,
                                                              Node node,
                                                              Field field)
Overrides:
validateCastValueOrNull in class BasicDataType<E>

validateCastValue

protected Collection<LocalizedString> validateCastValue(Collection<LocalizedString> errors,
                                                        Object castValue,
                                                        Object value,
                                                        Node node,
                                                        Field field)
Overrides:
validateCastValue in class BasicDataType<E>

toXml

public void toXml(Element parent)
Description copied from interface: DataType
Fills this datatype in another XML (for example in the xml of DataType.getOrigin(), to make one XML, fully describing the DataType). The implementation of this method is unfinished!

Specified by:
toXml in interface DataType<E>
Overrides:
toXml in class BasicDataType<E>
Parameters:
parent - a 'datatype' element.

toStringBuilder

protected StringBuilder toStringBuilder()
Overrides:
toStringBuilder in class BasicDataType<E>


MMBase2 Bridge 2.0-SNAPSHOT - 2014-09-22T23:05