public class StringDataType extends ComparableDataType<String> implements LengthDataType<String>
| Modifier and Type | Class and Description |
|---|---|
protected class |
StringDataType.PatternRestriction |
ComparableDataType.MaxRestriction, ComparableDataType.MinRestrictionBasicDataType.AbstractRestriction<D extends Serializable>, BasicDataType.DataTypeComparator<D>, BasicDataType.EnumerationRestriction, BasicDataType.RequiredRestriction, BasicDataType.RestrictedEnumerationIterator, BasicDataType.StaticAbstractRestriction<D extends Serializable>, BasicDataType.TypeRestriction, BasicDataType.UniqueRestrictionDataType.Restriction<D extends Serializable>| Modifier and Type | Field and Description |
|---|---|
static Pattern |
BOOLEAN_PATTERN |
static Pattern |
DOUBLE_PATTERN |
static Pattern |
INTEGER_PATTERN |
static Pattern |
LONG_PATTERN |
protected AbstractLengthDataType.MaxRestriction |
maxLengthRestriction |
protected AbstractLengthDataType.MinRestriction |
minLengthRestriction |
static Pattern |
NON_NEGATIVE_INTEGER_PATTERN |
protected StringDataType.PatternRestriction |
patternRestriction |
maxRestriction, minRestrictionDATATYPE_BUNDLE, defaultValue, enumerationRestriction, origin, requiredRestriction, typeRestriction, uniqueRestrictiondescription, guiName, keyENFORCE_ABSOLUTE, ENFORCE_ALWAYS, ENFORCE_NEVER, ENFORCE_ONCHANGE, ENFORCE_ONCREATE, ENFORCE_ONVALIDATE, PROCESS_GET, PROCESS_SET, VALID, XMLNS| Constructor and Description |
|---|
StringDataType(String name)
Constructor for string data type.
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
castForPattern(Object v,
Node node,
Field field) |
StringDataType |
clone(String name)
Returns a cloned instance of this datatype, inheriting all validation rules.
|
protected void |
cloneRestrictions(BasicDataType origin)
If a datatype is cloned, the restrictions of it (normally implemented as inner classes), must be reinstantiated.
|
protected int |
compare(String comp1,
String comp2) |
Collator |
getCollator()
Returns the
Collator associated with string with this datatype. |
Comparator<String> |
getComparator() |
int |
getEnforceStrength()
The maximum enforce strength of all restrictions on this datatype.
|
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.
|
Pattern |
getPattern()
Returns the regular expression pattern used to validate values for this datatype.
|
DataType.Restriction |
getPatternRestriction()
Returns the 'pattern' restriction, containing the value, error messages, and fixed status of this attribute.
|
protected void |
inheritProperties(BasicDataType<String> origin)
Properties are members of the datatype that can easily be copied/clones.
|
protected void |
inheritRestrictions(BasicDataType origin)
If a datatype inherits from another datatype all its restrictions inherit too.
|
boolean |
isPassword()
Whether or not the data represents sensitive information, in which case e.g.
|
static void |
main(String[] argv) |
void |
setCollator(Collator col) |
void |
setMaxLength(long value)
Sets the maximum length of values for this datatype.
|
void |
setMinLength(long value)
Sets the minimum length of binary values for this datatype.
|
void |
setPassword(boolean pw) |
void |
setPattern(Pattern value)
Sets the regular expression pattern used to validate 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) |
getDefaultValue, getMaxRestriction, getMinRestriction, isMaxInclusive, isMinInclusive, setMax, setMinaddErrorDescription, addRestriction, addRestriction, addStyleClass, cast, cast, castAndValidate, castForSearch, castToPresent, castToValidate, checkType, clone, compareTo, edit, equals, finish, finish, getBaseType, getBaseTypeIdentifier, getCloud, getCloud, getCommitProcessor, getDefaultProcessor, getDefaultValue, getDeleteProcessor, getElement, getElement, getEnforceString, getEnumerationFactory, getEnumerationRestriction, getEnumerationValue, getEnumerationValues, getHandler, getHandlers, getOrigin, getProcessor, getProcessor, getProcessorWithoutDefault, getRequiredRestriction, getRestrictions, getStyleClasses, getTypeAsClass, getUniqueRestriction, hashCode, inherit, isCorrectType, isFinished, isRequired, isUnique, preCast, preCast, preCast, rewrite, setCommitProcessor, setDefaultProcessor, setDefaultValue, setDeleteProcessor, setProcessor, setProcessor, setRequired, setUnique, setXml, toString, toXml, validate, validate, validateRequired, xmlValuegetDefaultLocale, getDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUIName, setLocalizedDescription, setLocalizedGUINamefinalize, getClass, notify, notifyAll, wait, wait, waitcast, castAndValidate, castForSearch, checkType, 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, validategetDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUINamecompareToprotected StringDataType.PatternRestriction patternRestriction
protected AbstractLengthDataType.MinRestriction minLengthRestriction
protected AbstractLengthDataType.MaxRestriction maxLengthRestriction
public static final Pattern DOUBLE_PATTERN
public static final Pattern BOOLEAN_PATTERN
public static final Pattern INTEGER_PATTERN
public static final Pattern NON_NEGATIVE_INTEGER_PATTERN
public static final Pattern LONG_PATTERN
public StringDataType(String name)
name - the name of the data typeprotected void inheritProperties(BasicDataType<String> origin)
BasicDataTypeinheritProperties in class BasicDataType<String>protected void inheritRestrictions(BasicDataType origin)
BasicDataTypeinheritRestrictions in class ComparableDataType<String>protected void cloneRestrictions(BasicDataType origin)
BasicDataTypecloneRestrictions in class ComparableDataType<String>protected int compare(String comp1, String comp2)
compare in class ComparableDataType<String>public long getLength(Object value)
LengthDataTypegetLength in interface LengthDataType<String>public long getMinLength()
getMinLength in interface LengthDataType<String>int, or 0 if there is no minimum length.public DataType.Restriction<Long> getMinLengthRestriction()
getMinLengthRestriction in interface LengthDataType<String>DataType.Restrictionpublic void setMinLength(long value)
setMinLength in interface LengthDataType<String>value - the minimum length as an long, or 0 if there is no minimum length.public long getMaxLength()
getMaxLength in interface LengthDataType<String>long, or a very very big value
(Long.MAX_VALUE) if there is no maximum length.public DataType.Restriction<Long> getMaxLengthRestriction()
getMaxLengthRestriction in interface LengthDataType<String>DataType.Restrictionpublic void setMaxLength(long value)
setMaxLength in interface LengthDataType<String>value - see LengthDataType.getMaxLength()public Pattern getPattern()
public DataType.Restriction getPatternRestriction()
DataType.Restrictionpublic void setPattern(Pattern value)
value - the pattern as a Pattern, or null if no pattern should be applied.UnsupportedOperationException - if this datatype is read-only (i.e. defined by MMBase)public boolean isPassword()
public void setPassword(boolean pw)
public void setCollator(Collator col)
public Collator getCollator()
Collator associated with string with this datatype. Collators define how strings
should be compared and sorted. This can be language dependent. The DataType XML configuration
uses LocaleCollator.getInstance(String) to parse the string present
in datatype XML's to a Collator.public Comparator<String> getComparator()
getComparator in class ComparableDataType<String>public void toXml(Element parent)
DataTypeDataType.getOrigin(), to make one
XML, fully describing the DataType). The implementation of this method is
unfinished!public int getEnforceStrength()
DataTypeDataType.ENFORCE_ALWAYS, DataType.ENFORCE_ONCHANGE, DataType.ENFORCE_NEVER.getEnforceStrength in interface DataType<String>getEnforceStrength in class ComparableDataType<String>protected Collection<LocalizedString> validateCastValueOrNull(Collection<LocalizedString> errors, Object castValue, Object value, Node node, Field field)
validateCastValueOrNull in class BasicDataType<String>protected Collection<LocalizedString> validateCastValue(Collection<LocalizedString> errors, Object castValue, Object value, Node node, Field field)
validateCastValue in class ComparableDataType<String>protected StringBuilder toStringBuilder()
toStringBuilder in class ComparableDataType<String>protected String castForPattern(Object v, Node node, Field field)
public StringDataType clone(String name)
BasicDataTypeBasicDataType.inheritProperties(BasicDataType) and BasicDataType.cloneRestrictions(BasicDataType). A clone is not finished. See BasicDataType.isFinished().public static void main(String[] argv)
MMBase 1.9-SNAPSHOT - ${javadoctimestamp}