Top Description Fields Constructors Methods
com.ctc.wstx.dtd

public abstract Class DTDAttribute

extends Object
Class Inheritance
Known Direct Subclasses
com.ctc.wstx.dtd.DTDCdataAttr, com.ctc.wstx.dtd.DTDEntitiesAttr, com.ctc.wstx.dtd.DTDEntityAttr, com.ctc.wstx.dtd.DTDEnumAttr, com.ctc.wstx.dtd.DTDIdAttr, com.ctc.wstx.dtd.DTDIdRefsAttr, com.ctc.wstx.dtd.DTDNmTokenAttr, com.ctc.wstx.dtd.DTDNmTokensAttr, com.ctc.wstx.dtd.DTDNotationAttr, com.ctc.wstx.dtd.DTDIdRefAttr
Imports
java.util.Map, javax.xml.stream.XMLStreamException, org.codehaus.stax2.validation.ValidationContext, .XMLValidator, com.ctc.wstx.ent.EntityDecl, com.ctc.wstx.io.WstxInputData, com.ctc.wstx.sr.InputProblemReporter, com.ctc.wstx.util.PrefixedName, .StringUtil, .WordResolver

Base 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

Modifier and TypeField and Description
pack-priv static final char
protected final boolean
protected final boolean
protected final DefaultAttrValue
protected final PrefixedName
protected final int
mSpecialIndex

Index number amongst "special" attributes (required ones, attributes that have default values), if attribute is one: -1 if not.

pack-priv static final String[]
sTypes

Array that has String constants matching above mentioned value types

public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
public
DTDAttribute(PrefixedName name, DefaultAttrValue defValue, int specIndex, boolean nsAware, boolean xml11)

Method Summary

Modifier and TypeMethod and Description
protected void
public abstract DTDAttribute
cloneWith(int specIndex)

protected EntityDecl
findEntityDecl(DTDValidatorBase v, char[] ch, int start, int len)

public final String
public final PrefixedName
public final int
public int
getValueType()

Returns the value type of this attribute as an enumerated int to match type (CDATA, ...)

Note:

public String
public final boolean
public final boolean
public final boolean
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.

public final boolean
public String

Returns:

Normalized value as a String, if any changes were done; null if input was normalized
normalize
(DTDValidatorBase
Validator that invoked normalization
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.

public void
normalizeDefault()

Method called to do initial normalization of the default attribute value, without trying to verify its validity.

protected String
protected String
protected String
reportValidationProblem(InputProblemReporter rep, String msg)

Method called during parsing of DTD schema, to report a problem.

public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public boolean
public boolean
public abstract String
validate(DTDValidatorBase v, char[] cbuf, int start, int end, boolean normalize)

public String
validate(DTDValidatorBase v, String value, boolean normalize)

Note

the default implementation is not optimized, as it does a potentially unnecessary copy of the contents.

public abstract void
validateDefault(InputProblemReporter rep, boolean normalize)

Method called by the DTDValidator to ask attribute to verify that the default it has (if any) is valid for such type.

protected String
validateDefaultName(InputProblemReporter rep, boolean normalize)

protected String
protected String
public 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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

CHAR_SPACEback to summary
pack-priv static final char CHAR_SPACE
mCfgNsAwareback to summary
protected final boolean mCfgNsAware
mCfgXml11back to summary
protected final boolean mCfgXml11
mDefValueback to summary
protected final DefaultAttrValue mDefValue
mNameback to summary
protected final PrefixedName mName
mSpecialIndexback to summary
protected final int mSpecialIndex

Index number amongst "special" attributes (required ones, attributes that have default values), if attribute is one: -1 if not.

sTypesback to summary
pack-priv static final String[] sTypes

Array that has String constants matching above mentioned value types

TYPE_CDATAback to summary
public static final int TYPE_CDATA
TYPE_ENTITIESback to summary
public static final int TYPE_ENTITIES
TYPE_ENTITYback to summary
public static final int TYPE_ENTITY
TYPE_ENUMERATEDback to summary
public static final int TYPE_ENUMERATED
TYPE_IDback to summary
public static final int TYPE_ID
TYPE_IDREFback to summary
public static final int TYPE_IDREF
TYPE_IDREFSback to summary
public static final int TYPE_IDREFS
TYPE_NMTOKENback to summary
public static final int TYPE_NMTOKEN
TYPE_NMTOKENSback to summary
public static final int TYPE_NMTOKENS
TYPE_NOTATIONback to summary
public static final int TYPE_NOTATION

Constructor Detail

DTDAttributeback to summary
public DTDAttribute(PrefixedName name, DefaultAttrValue defValue, int specIndex, boolean nsAware, boolean xml11)

Method Detail

checkEntityback to summary
protected void checkEntity(InputProblemReporter rep, String id, EntityDecl ent) throws XMLStreamException
cloneWithback to summary
public abstract DTDAttribute cloneWith(int specIndex)
findEntityDeclback to summary
protected EntityDecl findEntityDecl(DTDValidatorBase v, char[] ch, int start, int len) throws XMLStreamException
getDefaultValueback to summary
public final String getDefaultValue(ValidationContext ctxt, XMLValidator dtd) throws XMLStreamException
getNameback to summary
public final PrefixedName getName()
getSpecialIndexback to summary
public final int getSpecialIndex()
getValueTypeback to summary
public int getValueType()

Returns the value type of this attribute as an enumerated int to match type (CDATA, ...)

Note:

getValueTypeStringback to summary
public String getValueTypeString()
hasDefaultValueback to summary
public final boolean hasDefaultValue()
isFixedback to summary
public final boolean isFixed()
isRequiredback to summary
public final boolean isRequired()
isSpecialback to summary
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.

needsValidationback to summary
public final boolean needsValidation()
normalizeback to summary
public 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:DTDValidatorBase

Validator that invoked normalization

Returns:String

Normalized value as a String, if any changes were done; null if input was normalized

normalizeDefaultback to summary
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.

reportInvalidCharback to summary
protected String reportInvalidChar(DTDValidatorBase v, char c, String msg) throws XMLStreamException
reportValidationProblemback to summary
protected String reportValidationProblem(DTDValidatorBase v, String msg) throws XMLStreamException
reportValidationProblemback to summary
protected String reportValidationProblem(InputProblemReporter rep, String msg) throws 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.

toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
typeIsIdback to summary
public boolean typeIsId()
typeIsNotationback to summary
public boolean typeIsNotation()
validateback to summary
public abstract String validate(DTDValidatorBase v, char[] cbuf, int start, int end, boolean normalize) throws XMLStreamException
validateback to summary
public String validate(DTDValidatorBase v, String value, boolean normalize) throws 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)

validateDefaultback to summary
public abstract void validateDefault(InputProblemReporter rep, boolean normalize) throws XMLStreamException

Method called by the DTDValidator to ask attribute to verify that the default it has (if any) is valid for such type.

validateDefaultNameback to summary
protected String validateDefaultName(InputProblemReporter rep, boolean normalize) throws XMLStreamException
validateDefaultNamesback to summary
protected String validateDefaultNames(InputProblemReporter rep, boolean normalize) throws XMLStreamException
validateDefaultNmTokenback to summary
protected String validateDefaultNmToken(InputProblemReporter rep, boolean normalize) throws XMLStreamException
validateEnumValueback to summary
public 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.