Package com.ctc.wstx.dtd
Class DTDAttribute
- java.lang.Object
-
- com.ctc.wstx.dtd.DTDAttribute
-
- Direct Known Subclasses:
DTDCdataAttr,DTDEntitiesAttr,DTDEntityAttr,DTDEnumAttr,DTDIdAttr,DTDIdRefAttr,DTDIdRefsAttr,DTDNmTokenAttr,DTDNmTokensAttr,DTDNotationAttr
public abstract class DTDAttribute extends java.lang.ObjectBase class for objects that contain attribute definitions from DTD. Sub-classes exists for specific typed attributes (enumeration-valued, non-CDATA ones); base class itself is used for attributes of type CDATA.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static charCHAR_SPACEprotected booleanmCfgNsAwareprotected booleanmCfgXml11protected DefaultAttrValuemDefValueprotected PrefixedNamemNameprotected intmSpecialIndexIndex number amongst "special" attributes (required ones, attributes that have default values), if attribute is one: -1 if not.(package private) static java.lang.String[]sTypesArray that has String constants matching above mentioned value typesstatic intTYPE_CDATAstatic intTYPE_ENTITIESstatic intTYPE_ENTITYstatic intTYPE_ENUMERATEDstatic intTYPE_IDstatic intTYPE_IDREFstatic intTYPE_IDREFSstatic intTYPE_NMTOKENstatic intTYPE_NMTOKENSstatic intTYPE_NOTATION
-
Constructor Summary
Constructors Constructor Description DTDAttribute(PrefixedName name, DefaultAttrValue defValue, int specIndex, boolean nsAware, boolean xml11)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcheckEntity(InputProblemReporter rep, java.lang.String id, EntityDecl ent)abstract DTDAttributecloneWith(int specIndex)protected EntityDeclfindEntityDecl(DTDValidatorBase v, char[] ch, int start, int len)java.lang.StringgetDefaultValue(org.codehaus.stax2.validation.ValidationContext ctxt, org.codehaus.stax2.validation.XMLValidator dtd)PrefixedNamegetName()intgetSpecialIndex()intgetValueType()Returns the value type of this attribute as an enumerated int to match type (CDATA, ...)java.lang.StringgetValueTypeString()booleanhasDefaultValue()booleanisFixed()booleanisRequired()booleanisSpecial()Method used by the element to figure out if attribute needs "special" checking; basically if it's required, and/or has a default value.booleanneedsValidation()java.lang.Stringnormalize(DTDValidatorBase v, char[] cbuf, int start, int end)Method called when no validation is to be done, but value is still to be normalized as much as it can.voidnormalizeDefault()Method called to do initial normalization of the default attribute value, without trying to verify its validity.protected java.lang.StringreportInvalidChar(DTDValidatorBase v, char c, java.lang.String msg)protected java.lang.StringreportValidationProblem(DTDValidatorBase v, java.lang.String msg)protected java.lang.StringreportValidationProblem(InputProblemReporter rep, java.lang.String msg)Method called during parsing of DTD schema, to report a problem.java.lang.StringtoString()booleantypeIsId()booleantypeIsNotation()abstract java.lang.Stringvalidate(DTDValidatorBase v, char[] cbuf, int start, int end, boolean normalize)java.lang.Stringvalidate(DTDValidatorBase v, java.lang.String value, boolean normalize)Note: the default implementation is not optimized, as it does a potentially unnecessary copy of the contents.abstract voidvalidateDefault(InputProblemReporter rep, boolean normalize)Method called by theDTDValidatorto ask attribute to verify that the default it has (if any) is valid for such type.protected java.lang.StringvalidateDefaultName(InputProblemReporter rep, boolean normalize)protected java.lang.StringvalidateDefaultNames(InputProblemReporter rep, boolean normalize)protected java.lang.StringvalidateDefaultNmToken(InputProblemReporter rep, boolean normalize)java.lang.StringvalidateEnumValue(char[] cbuf, int start, int end, boolean normalize, WordResolver res)Method called by validation/normalization code for enumeration-valued attributes, to trim specified attribute value (full normalization not needed -- called for values that CAN NOT have spaces inside; such values can not be legal), and then check whether it is included in set of words (tokens) passed in.
-
-
-
Field Detail
-
CHAR_SPACE
static final char CHAR_SPACE
- See Also:
- Constant Field Values
-
TYPE_CDATA
public static final int TYPE_CDATA
- See Also:
- Constant Field Values
-
TYPE_ENUMERATED
public static final int TYPE_ENUMERATED
- See Also:
- Constant Field Values
-
TYPE_ID
public static final int TYPE_ID
- See Also:
- Constant Field Values
-
TYPE_IDREF
public static final int TYPE_IDREF
- See Also:
- Constant Field Values
-
TYPE_IDREFS
public static final int TYPE_IDREFS
- See Also:
- Constant Field Values
-
TYPE_ENTITY
public static final int TYPE_ENTITY
- See Also:
- Constant Field Values
-
TYPE_ENTITIES
public static final int TYPE_ENTITIES
- See Also:
- Constant Field Values
-
TYPE_NOTATION
public static final int TYPE_NOTATION
- See Also:
- Constant Field Values
-
TYPE_NMTOKEN
public static final int TYPE_NMTOKEN
- See Also:
- Constant Field Values
-
TYPE_NMTOKENS
public static final int TYPE_NMTOKENS
- See Also:
- Constant Field Values
-
sTypes
static final java.lang.String[] sTypes
Array that has String constants matching above mentioned value types
-
mName
protected final PrefixedName mName
-
mSpecialIndex
protected final int mSpecialIndex
Index number amongst "special" attributes (required ones, attributes that have default values), if attribute is one: -1 if not.
-
mDefValue
protected final DefaultAttrValue mDefValue
-
mCfgNsAware
protected final boolean mCfgNsAware
-
mCfgXml11
protected final boolean mCfgXml11
-
-
Constructor Detail
-
DTDAttribute
public DTDAttribute(PrefixedName name, DefaultAttrValue defValue, int specIndex, boolean nsAware, boolean xml11)
-
-
Method Detail
-
cloneWith
public abstract DTDAttribute cloneWith(int specIndex)
-
getName
public final PrefixedName getName()
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getDefaultValue
public final java.lang.String getDefaultValue(org.codehaus.stax2.validation.ValidationContext ctxt, org.codehaus.stax2.validation.XMLValidator dtd) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
getSpecialIndex
public final int getSpecialIndex()
-
needsValidation
public final boolean needsValidation()
-
isFixed
public final boolean isFixed()
-
isRequired
public final boolean isRequired()
-
isSpecial
public final boolean isSpecial()
Method used by the element to figure out if attribute needs "special" checking; basically if it's required, and/or has a default value. In both cases missing the attribute has specific consequences, either exception or addition of a default value.
-
hasDefaultValue
public final boolean hasDefaultValue()
-
getValueType
public int getValueType()
Returns the value type of this attribute as an enumerated int to match type (CDATA, ...)Note:
-
getValueTypeString
public java.lang.String getValueTypeString()
-
typeIsId
public boolean typeIsId()
-
typeIsNotation
public boolean typeIsNotation()
-
validate
public abstract java.lang.String validate(DTDValidatorBase v, char[] cbuf, int start, int end, boolean normalize) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
validate
public java.lang.String validate(DTDValidatorBase v, java.lang.String value, boolean normalize) throws javax.xml.stream.XMLStreamException
Note: the default implementation is not optimized, as it does a potentially unnecessary copy of the contents. It is expected that this method is seldom called (Woodstox never directly calls it; it only gets called for chained validators when one validator normalizes the value, and then following validators are passed a String, not char array)
- Throws:
javax.xml.stream.XMLStreamException
-
validateDefault
public abstract void validateDefault(InputProblemReporter rep, boolean normalize) throws javax.xml.stream.XMLStreamException
Method called by theDTDValidatorto ask attribute to verify that the default it has (if any) is valid for such type.- Throws:
javax.xml.stream.XMLStreamException
-
normalize
public java.lang.String normalize(DTDValidatorBase v, char[] cbuf, int start, int end)
Method called when no validation is to be done, but value is still to be normalized as much as it can. What this usually means is that all regular space (parser earlier on converts other white space to spaces, except for specific character entities; and these special cases are NOT to be normalized).The only exception is that CDATA will not do any normalization. But for now, let's implement basic functionality that CDTA instance will override
- Parameters:
v- Validator that invoked normalization- Returns:
- Normalized value as a String, if any changes were done; null if input was normalized
-
normalizeDefault
public void normalizeDefault()
Method called to do initial normalization of the default attribute value, without trying to verify its validity. Thus, it's called independent of whether we are fully validating the document.
-
validateDefaultName
protected java.lang.String validateDefaultName(InputProblemReporter rep, boolean normalize) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
validateDefaultNames
protected java.lang.String validateDefaultNames(InputProblemReporter rep, boolean normalize) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
validateDefaultNmToken
protected java.lang.String validateDefaultNmToken(InputProblemReporter rep, boolean normalize) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
validateEnumValue
public java.lang.String validateEnumValue(char[] cbuf, int start, int end, boolean normalize, WordResolver res)Method called by validation/normalization code for enumeration-valued attributes, to trim specified attribute value (full normalization not needed -- called for values that CAN NOT have spaces inside; such values can not be legal), and then check whether it is included in set of words (tokens) passed in. If actual value was included, will return the normalized word (as well as store shared String locally); otherwise will return null.
-
findEntityDecl
protected EntityDecl findEntityDecl(DTDValidatorBase v, char[] ch, int start, int len) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
checkEntity
protected void checkEntity(InputProblemReporter rep, java.lang.String id, EntityDecl ent) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
reportInvalidChar
protected java.lang.String reportInvalidChar(DTDValidatorBase v, char c, java.lang.String msg) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
reportValidationProblem
protected java.lang.String reportValidationProblem(DTDValidatorBase v, java.lang.String msg) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
reportValidationProblem
protected java.lang.String reportValidationProblem(InputProblemReporter rep, java.lang.String msg) throws javax.xml.stream.XMLStreamException
Method called during parsing of DTD schema, to report a problem. Note that unlike during actual validation, we have no option of just gracefully listing problems and ignoring them; an exception is always thrown.- Throws:
javax.xml.stream.XMLStreamException
-
-