Package com.ctc.wstx.dtd
Class DTDTypingNonValidator
- java.lang.Object
-
- org.codehaus.stax2.validation.XMLValidator
-
- com.ctc.wstx.dtd.DTDValidatorBase
-
- com.ctc.wstx.dtd.DTDTypingNonValidator
-
- All Implemented Interfaces:
NsDefaultProvider
public class DTDTypingNonValidator extends DTDValidatorBase
This class is a "non-validating validator"; a validator-like object that handles DTD-based non-validation functionality: determining type information and default values. This instance does NOT implement any actual DTD-validation, and is to be used in DTD-aware non-validating mode.
-
-
Field Summary
Fields Modifier and Type Field Description protected BitSetmCurrDefaultAttrsBitset used for keeping track of defaulted attributes for which values have been found.protected booleanmHasAttrDefaultsFlag that indicates if current element has any attributes that have default values.protected booleanmHasNormalizableAttrsFlag that indicates whether any of the attributes is potentially normalizable, and we are in attribute-normalizing mode.-
Fields inherited from class com.ctc.wstx.dtd.DTDValidatorBase
EMPTY_MAP, mAttrCount, mAttrSpecs, mCurrAttrDefs, mCurrElem, mElemCount, mElems, mIdAttrIndex, mNormAttrs, mTmpKey, NO_ATTRS
-
Fields inherited from class org.codehaus.stax2.validation.XMLValidator
CONTENT_ALLOW_ANY_TEXT, CONTENT_ALLOW_NONE, CONTENT_ALLOW_UNDEFINED, CONTENT_ALLOW_VALIDATABLE_TEXT, CONTENT_ALLOW_WS, CONTENT_ALLOW_WS_NONSTRICT
-
-
Constructor Summary
Constructors Constructor Description DTDTypingNonValidator(DTDSubset schema, ValidationContext ctxt, boolean hasNsDefaults, Map<PrefixedName,DTDElement> elemSpecs, Map<String,EntityDecl> genEntities)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ElementIdMapgetIdMap()booleanreallyValidating()voidsetAttrValueNormalization(boolean state)This 'validator' will not normalize any attributes, so let's implement this as no-op.StringvalidateAttribute(String localName, String uri, String prefix, char[] valueChars, int valueStart, int valueEnd)Callback method called on validator to give it a chance to validate the value of an attribute, as well as to normalize its value if appropriate (remove leading/trailing/intervening white space for certain token types etc.).StringvalidateAttribute(String localName, String uri, String prefix, String value)Callback method called on validator to give it a chance to validate the value of an attribute, as well as to normalize its value if appropriate (remove leading/trailing/intervening white space for certain token types etc.).intvalidateElementAndAttributes()Method called after callingXMLValidator.validateAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String)on all attributes (if any), but before starting to handle element content.intvalidateElementEnd(String localName, String uri, String prefix)Method called right after encountering an element close tag.voidvalidateElementStart(String localName, String uri, String prefix)Method called to update information about the newly encountered (start) element.voidvalidationCompleted(boolean eod)Method called when the validation is completed; either due to the input stream ending, or due to an explicit 'stop validation' request by the application (via context object).-
Methods inherited from class com.ctc.wstx.dtd.DTDValidatorBase
checkNsDefaults, doAddDefaultValue, doReportValidationProblem, getAttributeType, getIdAttrIndex, getNotationAttrIndex, getSchema, hasNsDefaults, mayHaveNsDefaults, validateText, validateText
-
Methods inherited from class org.codehaus.stax2.validation.XMLValidator
getSchemaType
-
-
-
-
Field Detail
-
mHasAttrDefaults
protected boolean mHasAttrDefaults
Flag that indicates if current element has any attributes that have default values.
-
mCurrDefaultAttrs
protected BitSet mCurrDefaultAttrs
Bitset used for keeping track of defaulted attributes for which values have been found. Only non-null when current element does have such attributes
-
mHasNormalizableAttrs
protected boolean mHasNormalizableAttrs
Flag that indicates whether any of the attributes is potentially normalizable, and we are in attribute-normalizing mode.
-
-
Constructor Detail
-
DTDTypingNonValidator
public DTDTypingNonValidator(DTDSubset schema, ValidationContext ctxt, boolean hasNsDefaults, Map<PrefixedName,DTDElement> elemSpecs, Map<String,EntityDecl> genEntities)
-
-
Method Detail
-
reallyValidating
public final boolean reallyValidating()
- Specified by:
reallyValidatingin classDTDValidatorBase- Returns:
- False, since this is not a real validator
-
setAttrValueNormalization
public void setAttrValueNormalization(boolean state)
This 'validator' will not normalize any attributes, so let's implement this as no-op.- Overrides:
setAttrValueNormalizationin classDTDValidatorBase
-
validateElementStart
public void validateElementStart(String localName, String uri, String prefix) throws XMLStreamException
Description copied from class:DTDValidatorBaseMethod called to update information about the newly encountered (start) element. At this point namespace information has been resolved, but no DTD validation has been done. Validator is to do these validations, including checking for attribute value (and existence) compatibility.- Specified by:
validateElementStartin classDTDValidatorBase- Throws:
XMLStreamException
-
validateAttribute
public String validateAttribute(String localName, String uri, String prefix, String value) throws XMLStreamException
Description copied from class:XMLValidatorCallback method called on validator to give it a chance to validate the value of an attribute, as well as to normalize its value if appropriate (remove leading/trailing/intervening white space for certain token types etc.).- Specified by:
validateAttributein classDTDValidatorBase- Returns:
- Null, if the passed value is fine as is; or a String, if it needs to be replaced. In latter case, caller will replace the value before passing it to other validators. Also, if the attribute value is accessible via caller (as is the case for stream readers), caller should return this value, instead of the original one.
- Throws:
XMLStreamException
-
validateAttribute
public String validateAttribute(String localName, String uri, String prefix, char[] valueChars, int valueStart, int valueEnd) throws XMLStreamException
Description copied from class:XMLValidatorCallback method called on validator to give it a chance to validate the value of an attribute, as well as to normalize its value if appropriate (remove leading/trailing/intervening white space for certain token types etc.).- Specified by:
validateAttributein classDTDValidatorBasevalueChars- Character array that contains value (possibly along with some other text)valueStart- Index of the first character of the value in invalueCharsarrayvalueEnd- Index of the character AFTER the last character; so that the length of the value String isvalueEnd - valueStart- Returns:
- Null, if the passed value is fine as is; or a String, if it needs to be replaced. In latter case, caller will replace the value before passing it to other validators. Also, if the attribute value is accessible via caller (as is the case for stream readers), caller should return this value, instead of the original one.
- Throws:
XMLStreamException
-
validateElementAndAttributes
public int validateElementAndAttributes() throws XMLStreamExceptionDescription copied from class:XMLValidatorMethod called after callingXMLValidator.validateAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String)on all attributes (if any), but before starting to handle element content.- Specified by:
validateElementAndAttributesin classDTDValidatorBase- Returns:
- One of
CONTENT_ALLOW_constants, to indicate what kind of textual content is allowed at the scope returned to after the element has closed. - Throws:
XMLStreamException
-
validateElementEnd
public int validateElementEnd(String localName, String uri, String prefix) throws XMLStreamException
Description copied from class:XMLValidatorMethod called right after encountering an element close tag.- Specified by:
validateElementEndin classDTDValidatorBase- Returns:
- Validation state that should be effective for the parent element state
- Throws:
XMLStreamException
-
validationCompleted
public void validationCompleted(boolean eod)
Description copied from class:XMLValidatorMethod called when the validation is completed; either due to the input stream ending, or due to an explicit 'stop validation' request by the application (via context object).- Specified by:
validationCompletedin classDTDValidatorBase- Parameters:
eod- Flag that indicates whether this method was called by the context due to the end of the stream (true); or by an application requesting end of validation (false).
-
getIdMap
protected ElementIdMap getIdMap()
- Specified by:
getIdMapin classDTDValidatorBase
-
-