|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
com.oxygenxml.validate.nvdl.ValidatorImpl
class ValidatorImpl
Implementation of a validator of XML documents against NVDL scripts.
Nested Class Summary | |
---|---|
private static class |
ValidatorImpl.PrefixMapping
Namespace context. |
private static class |
ValidatorImpl.Program
A program is a pair of mode usage and handler. |
private class |
ValidatorImpl.Section
Store section information. |
Field Summary | |
---|---|
private Vector |
activeHandlersAttributeIndexSets
Sores the index sets for attributes for each active handler. |
private Hashtable |
attributeNamespaceIndexSets
Stores index sets for attributed for each namespace. |
private boolean |
attributeNamespaceRejected
Flag indicating if we had a reject action on attributes from this namespace. |
private Hashset |
attributeSchemas
Attribute schemas for a namespace. |
private ValidatorImpl.Section |
currentSection
Points to the current section. |
private ErrorHandler |
eh
The error handler. |
private Stack |
elementsLocalNameStack
Stores the element full names. |
private Attributes |
filteredAttributes
Ee use this to compute only once the filtered attributes for a namespace, laysily when we will need them for the first time. |
private Localizer |
localizer
Message localizer to report error messages from keys. |
private Locator |
locator
Source locator. |
protected static org.apache.log4j.Logger |
logger
Logger |
private static String |
NO_NS
A value for really no namespace, that is different than any other value for any possible namespace including no namespace which is an empty string. |
private Hashset |
noResultActions
keeps the no result actions for a section to avoid duplicating them as the same action can be specified by multiple programs in a section. |
private ValidatorImpl.PrefixMapping |
prefixMapping
The current namespace context, points to the last prefix mapping the previous can be found on getParent and so on. |
private PropertyMap |
properties
Properties. |
private Mode |
startMode
The start mode for this NVDL script. |
private Triggers |
triggers
Triggers. |
private Hashtable |
validatorHandlerCache
A hashtable that keeps a stack of validators for schemas. |
private static String |
VIRTUAL_ELEMENT_LOCAL_NAME
The name for the dummy element that we use for attribute section validation. |
private static String |
VIRTUAL_ELEMENT_URI
The namespace for the virtual element that we use for attribute section validation. |
Constructor Summary | |
---|---|
ValidatorImpl(Mode mode,
Triggers triggers,
PropertyMap properties)
Creates a NVDL validator. |
Method Summary | |
---|---|
void |
characters(char[] ch,
int start,
int length)
characters callback. |
private void |
cleanupHandler(ContentHandler vh)
Cleanup a handler. |
private Validator |
createValidator(Schema schema)
Get a validator for a schema. |
void |
endDocument()
endDocument callback We should be in the initial section now so no op is required. |
void |
endElement(String uri,
String localName,
String qName)
endElement callback |
void |
endPrefixMapping(String prefix)
end prefix mapping callback |
private void |
endSection()
End a section, its depth reached zero. |
private static Attributes |
filterAttributes(IntSet indexSet,
Attributes attributes)
Get the filtered attributes. |
ContentHandler |
getContentHandler()
Get the content handler for this NVDL validator. |
DTDHandler |
getDTDHandler()
Get the DTD handler for this NVDL validator. |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
ignorable whitespace callback. |
private void |
initCurrentSection()
Initializes the current session. |
private void |
initHandler(ContentHandler ch)
Initialize a content handler. |
private boolean |
processAttributes(Attributes attributes)
Processes the element attributes. |
private AttributeActionSet |
processAttributeSection(ModeUsage modeUsage,
String ns,
IntSet indexSet,
Attributes attributes)
Process an attributes section in a specific mode usage. |
private void |
releaseValidator(Schema schema,
Validator vh)
Releases a validator for a given schema. |
void |
reset()
Reset the NVDL validator so it can be used further on other sources. |
void |
setDocumentLocator(Locator locator)
Set document locator callback. |
void |
startElement(String uri,
String localName,
String qName,
Attributes attributes)
startElement callback. |
void |
startPrefixMapping(String prefix,
String uri)
start prefix mapping callback |
private void |
startSection(String uri)
Start a new section on a given namespace. |
private void |
validateAttributes(Schema schema,
Attributes attributes)
Validates a set of attributes with an attribute schema. |
Methods inherited from class org.xml.sax.helpers.DefaultHandler |
---|
error, fatalError, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, unparsedEntityDecl, warning |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static org.apache.log4j.Logger logger
private static final String VIRTUAL_ELEMENT_URI
private static final String VIRTUAL_ELEMENT_LOCAL_NAME
private static final String NO_NS
private final ErrorHandler eh
private final PropertyMap properties
private final Triggers triggers
private Locator locator
private ValidatorImpl.Section currentSection
private ValidatorImpl.PrefixMapping prefixMapping
private final Hashtable validatorHandlerCache
private final Localizer localizer
private final Hashset noResultActions
private final Hashtable attributeNamespaceIndexSets
private final Vector activeHandlersAttributeIndexSets
private final Hashset attributeSchemas
private boolean attributeNamespaceRejected
private Attributes filteredAttributes
private final Mode startMode
private final Stack elementsLocalNameStack
Constructor Detail |
---|
ValidatorImpl(Mode mode, Triggers triggers, PropertyMap properties)
mode
- The start mode.properties
- Validation properties.Method Detail |
---|
private void initCurrentSection()
public void setDocumentLocator(Locator locator)
setDocumentLocator
in interface ContentHandler
setDocumentLocator
in class DefaultHandler
locator
- The document locator.public void characters(char[] ch, int start, int length) throws SAXException
characters
in interface ContentHandler
characters
in class DefaultHandler
SAXException
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
ignorableWhitespace
in interface ContentHandler
ignorableWhitespace
in class DefaultHandler
SAXException
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
startElement
in interface ContentHandler
startElement
in class DefaultHandler
uri
- The element namespace.localName
- The element local name.qName
- The element qualified name.attributes
- The attributes for this element.
SAXException
private static Attributes filterAttributes(IntSet indexSet, Attributes attributes)
indexSet
- The set with the indexes of the attributes we want to keep.attributes
- The list of attributes
private boolean processAttributes(Attributes attributes) throws SAXException
attributes
- The element attributes
SAXException
private AttributeActionSet processAttributeSection(ModeUsage modeUsage, String ns, IntSet indexSet, Attributes attributes) throws SAXException
modeUsage
- The mode usagens
- The attribute section namespaceindexSet
- The indexes of the attributes in the given namespaceattributes
- All the attributes
SAXException
private void validateAttributes(Schema schema, Attributes attributes) throws SAXException
schema
- The attributes schema.attributes
- The attributes to be validated
SAXException
private void startSection(String uri) throws SAXException
uri
- The new namespace.
SAXException
private void initHandler(ContentHandler ch) throws SAXException
ch
- The content handler.
SAXException
public void endElement(String uri, String localName, String qName) throws SAXException
endElement
in interface ContentHandler
endElement
in class DefaultHandler
uri
- The namespace urilocalName
- The element local nameqName
- The element qualified name
SAXException
private void endSection() throws SAXException
SAXException
private void cleanupHandler(ContentHandler vh) throws SAXException
vh
- The validator content handler to clean up.
SAXException
public void endDocument() throws SAXException
endDocument
in interface ContentHandler
endDocument
in class DefaultHandler
SAXException
public void startPrefixMapping(String prefix, String uri) throws SAXException
startPrefixMapping
in interface ContentHandler
startPrefixMapping
in class DefaultHandler
SAXException
public void endPrefixMapping(String prefix) throws SAXException
endPrefixMapping
in interface ContentHandler
endPrefixMapping
in class DefaultHandler
SAXException
private Validator createValidator(Schema schema)
schema
- The schema we need a validaor for.
private void releaseValidator(Schema schema, Validator vh)
schema
- The schema the validator validates againstvh
- The validator.public void reset()
reset
in interface Validator
public ContentHandler getContentHandler()
getContentHandler
in interface Validator
null
Validator.reset()
public DTDHandler getDTDHandler()
getDTDHandler
in interface Validator
null
if DTD information is
not significant to the Validator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |