Package org.exolab.castor.builder.types
Class AbstractLengthFacet
java.lang.Object
org.exolab.castor.builder.types.XSType
org.exolab.castor.builder.types.AbstractPatternFacet
org.exolab.castor.builder.types.AbstractWhiteSpaceFacet
org.exolab.castor.builder.types.AbstractLengthFacet
- Direct Known Subclasses:
XSAnyURI,XSBase64Binary,XSHexBinary,XSId,XSIdRef,XSNCName,XSNMToken,XSNormalizedString,XSQName,XSString
A base class for types which support the length, whiteSpace and pattern facets.
- Since:
- 1.1
- Version:
- $Revision: 6662 $ $Date: 2005-03-05 06:42:06 -0700 (Sat, 05 Mar 2005) $
- Author:
- Ralf Joachim
-
Field Summary
Fields inherited from class org.exolab.castor.builder.types.XSType
ANYURI_TYPE, BASE64BINARY_TYPE, BOOLEAN_TYPE, BYTE_TYPE, CLASS, COLLECTION, DATE_TYPE, DATETIME_TYPE, DECIMAL_TYPE, DOUBLE_TYPE, DURATION_TYPE, ENTITIES, ENTITY, FLOAT_TYPE, GDAY_TYPE, GMONTH_TYPE, GMONTHDAY_TYPE, GYEAR_TYPE, GYEARMONTH_TYPE, HEXBINARY_TYPE, ID_TYPE, IDREF_TYPE, IDREFS_TYPE, INT_TYPE, INTEGER_TYPE, LANGUAGE_TYPE, LONG_TYPE, NAME_TYPE, NCNAME_TYPE, NEGATIVE_INTEGER_TYPE, NMTOKEN_TYPE, NMTOKENS_TYPE, NON_NEGATIVE_INTEGER_TYPE, NON_POSITIVE_INTEGER_TYPE, NORMALIZEDSTRING_TYPE, NOTATION_TYPE, NULL, POSITIVE_INTEGER_TYPE, QNAME_TYPE, SHORT_TYPE, STRING_TYPE, TIME_TYPE, TOKEN_TYPE, UNSIGNED_BYTE_TYPE, UNSIGNED_INT_TYPE, UNSIGNED_LONG_TYPE, UNSIGNED_SHORT_TYPE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNo-arg constructor.protectedAbstractLengthFacet(boolean whiteSpaceCollapseOnly) Construct a new AbstractXSLengthFacet optionally allowing the whiteSpace facet to be set to 'replace' and 'preserve' values in addition to 'collaps'. -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidcodeLengthFacet(JSourceCode jsc, String validatorName) Generate the source code for length, maxLength or minLength facets validation.final intReturns the length that this type must have.final intReturns the maximum length occurances of this type can be.final intReturns the minimum length occurances of this type can be.final booleanReturns true if a length has been set.final booleanReturns true if a maximum length has been set.final booleanReturns true if a minimum length has been set.protected final voidSet the given facet for XSType if applicable.final voidsetLength(int length) Sets the length of this type.protected final voidsetLengthFacet(Facet facet) Transfer given facet if it is one of length, maxLength or minLength.final voidsetMaxLength(int maxLength) Sets the maximum length of this type.final voidsetMinLength(int minLength) Sets the minimum length of this XSString.Methods inherited from class org.exolab.castor.builder.types.AbstractWhiteSpaceFacet
codeWhiteSpaceFacet, getWhiteSpace, hasWhiteSpace, setWhiteSpace, setWhiteSpaceFacetMethods inherited from class org.exolab.castor.builder.types.AbstractPatternFacet
addPattern, addPatternFacet, codePatternFacet, getPatternsMethods inherited from class org.exolab.castor.builder.types.XSType
createDefaultValueWithString, createFromJavaObjectCode, createToJavaObjectCode, getJType, getName, getType, isCollection, isDateTime, isEnumerated, isPrimitive, newInstanceCode, setAsEnumerated, setFacets, validationCode
-
Constructor Details
-
AbstractLengthFacet
protected AbstractLengthFacet()No-arg constructor. By default only 'collapse' is supported for the whiteSpace facet. -
AbstractLengthFacet
protected AbstractLengthFacet(boolean whiteSpaceCollapseOnly) Construct a new AbstractXSLengthFacet optionally allowing the whiteSpace facet to be set to 'replace' and 'preserve' values in addition to 'collaps'.- Parameters:
whiteSpaceCollapseOnly- If set to true only 'collapse' is allowed for the whiteSpace facet. If set to false 'collaps', 'replace' and 'preserve' values are allowed for whiteSpace facet.
-
-
Method Details
-
hasLength
public final boolean hasLength()Returns true if a length has been set.- Returns:
- True if a length has been set.
-
getLength
public final int getLength()Returns the length that this type must have.- Returns:
- The length that this type must have.
-
setLength
public final void setLength(int length) Sets the length of this type. While setting the length, the maxLength and minLength are also set up to this length.- Parameters:
length- The length to set.
-
hasMaxLength
public final boolean hasMaxLength()Returns true if a maximum length has been set.- Returns:
- True if a maximum length has been set.
-
getMaxLength
public final int getMaxLength()Returns the maximum length occurances of this type can be. A negative value denotes no maximum length.- Returns:
- The maximum length facet.
-
setMaxLength
public final void setMaxLength(int maxLength) Sets the maximum length of this type. To remove the max length facet, use a negative value.- Parameters:
maxLength- The maximum length for occurances of this type.
-
hasMinLength
public final boolean hasMinLength()Returns true if a minimum length has been set.- Returns:
- True if a minimum length has been set.
-
getMinLength
public final int getMinLength()Returns the minimum length occurances of this type can be.- Returns:
- The minimum length facet.
-
setMinLength
public final void setMinLength(int minLength) Sets the minimum length of this XSString.- Parameters:
minLength- The minimum length for occurances of this type.
-
setFacet
Set the given facet for XSType if applicable.- Overrides:
setFacetin classAbstractWhiteSpaceFacet- Parameters:
facet- The facet to set for XSType.
-
setLengthFacet
Transfer given facet if it is one of length, maxLength or minLength.- Parameters:
facet- The facet to transfer.
-
codeLengthFacet
Generate the source code for length, maxLength or minLength facets validation.- Parameters:
jsc- The JSourceCode to fill in.validatorName- The name of the TypeValidator that the patterns should be added to.
-