|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object sk.baka.xml.schematic.msv.ValidatorImpl
public final class ValidatorImpl
Implements functionality of validator. Validates one 'island' only - only elements from selected namespace.
Constructor Summary | |
---|---|
ValidatorImpl(SchemaImpl schema)
Constructs new instance of validator. |
Method Summary | |
---|---|
com.sun.msv.verifier.regexp.ExpressionAcceptor |
createAcceptor(com.sun.msv.grammar.Expression exp)
Creates acceptor for given expression. |
Attributes |
createAttributes(Element element)
Creates an instance of SAX Attributes interface from given
element's attributes. |
com.sun.msv.util.StartTagInfo |
createSTI(Element e)
Creates a StartTagInfo instance for given element. |
com.sun.msv.util.StartTagInfo |
createSTI(Element e,
String namespace)
Creates a StartTagInfo instance for given element. |
com.sun.msv.util.StartTagInfo |
createSTI(Element e,
String namespace,
Attributes attrs)
Creates a StartTagInfo instance for given element. |
void |
feedAttributes(com.sun.msv.verifier.Acceptor acc,
Element element,
boolean checkForeign,
boolean finish)
Helper function, feeds the acceptor with all attributes. |
boolean |
stepForward(com.sun.msv.verifier.regexp.ExpressionAcceptor acc,
ContentInfo dpi,
boolean deep,
boolean throughNamespaces)
Tries to step with given acceptor over given content. |
boolean |
stepForward(com.sun.msv.verifier.regexp.ExpressionAcceptor acc,
Element e,
String text,
Node parent)
Tries to step with given acceptor over given content. |
boolean |
stepForward(com.sun.msv.verifier.regexp.ExpressionAcceptor acc,
String uri,
String name,
Node parent)
Tries to step forward with given acceptor over given element name. |
void |
validate(Element element,
com.sun.msv.verifier.regexp.ExpressionAcceptor acc,
boolean deep,
boolean throughNamespaces)
Tries to validate element with given acceptor. |
void |
validate(Element element,
com.sun.msv.grammar.Expression exp,
boolean deep,
boolean throughNamespaces)
Tries to validate element with given expression. |
void |
validate(Element element,
String namespace,
com.sun.msv.verifier.regexp.ExpressionAcceptor acc,
boolean deep,
boolean throughNamespaces,
SchemaLevelNodeIterator contextIterator)
Tries to validate element with given acceptor. |
void |
validateIterator(com.sun.msv.verifier.regexp.ExpressionAcceptor acc,
SchemaLevelNodeIterator ipIterator,
boolean deep,
boolean throughNamespaces,
int stepOver)
Validates contents, that are given to us by iterator. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
ValidatorImpl(SchemaImpl schema)
schema
- SchemaImpl instance.Method Detail |
---|
public void validate(Element element, com.sun.msv.grammar.Expression exp, boolean deep, boolean throughNamespaces) throws SchemaException
element
- element to validate.exp
- expression, defining element and its content. It may not be
ElementExp
of this element, of course :-).throughNamespaces
- if the validation must validate element from
another namespace - if it must ask EuromathSchemaProvider
to do so. This has higher priority than parameter deep - even if
deep
is true, this parameter can forbid walking through
namespaces.deep
- if validator must perform deep check, that is, verify
complete tree rooted in element
. If not, then each
element, that is context-free, is just validated itself, no validation is
performed over its contents. That allows faster validation.
The idea beyond is this: if deep==false, then we take for granted, that
document is valid, and we are just curious, whether this expression is
the right one to generate given element. When element is context-free and
acceptor.createChildAcceptor()
goes OK, we don't need to
validate content - they can be described by only one rule in whole
schema, and we know that the content is valid. But if element is not
context-free, then there are multiple rules generating element's content.
This content may be valid for one rule, but invalid for other rules. So,
we must check, whether our rule is the valid one. That is done by
validating the content.
If deep==false, we know that document is valid, and this schema doesn't describe correct content for element from another namespace. So, even when rule for this element is not context-free, we cannot tell whether our rule is the correct one. Thus, there is no point in walking through namespaces even when throughNamespaces==true.
SchemaException
- when validity error occurs.public void validate(Element element, com.sun.msv.verifier.regexp.ExpressionAcceptor acc, boolean deep, boolean throughNamespaces) throws SchemaException
element
- element to validate.acc
- Acceptor. On succesfull validation this acceptor has eaten
this element and is ready to eat next. If validation was unsuccesfull
(exception was thrown), then this acceptor is in undefined state and
should not be used.deep
- if validator must perform deep check, that is, verify
complete tree rooted in element
. If not, then each
element with context-free rule is skipped to allow fast validation. For
further description, see the other validate method.throughNamespaces
- if the validation must validate element from
another namespace - if it must ask EuromathSchemaProvider
to do so. This has higher priority than parameter deep - even if
deep
is true, this parameter can forbid walking through
namespaces.
SchemaException
- signalizes a validity or schema error.validate(Element, Expression, boolean, boolean)
public void validate(Element element, String namespace, com.sun.msv.verifier.regexp.ExpressionAcceptor acc, boolean deep, boolean throughNamespaces, SchemaLevelNodeIterator contextIterator) throws SchemaException
element
- element to validate.namespace
- If null
, then do a normal processing. If
not null
, then pretend, that given element has this
namespace. This is used for selecting elements. So in this case, we take
given element as element from our namespace. We even don't go through
namespaces (regardless of the throughNamespaces
value.acc
- Acceptor. When method is finished, this acceptor had eaten
this element and is ready to eat next. If validation was unsuccesfull
(exception was thrown), then this acceptor is in undefined state and
should not be used.deep
- if validator must perform deep check, that is, verify
complete tree rooted in element
. If not, then each
element with context-free rule is skipped to allow fast validation. For
further description, see the other validate method.throughNamespaces
- if the validation must validate element from
another namespace. If so, then we must ask
EuromathSchemaProvider
to do so. This has higher priority
than parameter deep - even if deep
is true, this parameter
can forbid walking through namespaces.contextIterator
- iterates the 'siblings' of given element (the
parent element of given element). If null
then default
iterator is used.
SchemaException
- when an validity mismatch had been found.validate(Element, Expression, boolean, boolean)
public void validateIterator(com.sun.msv.verifier.regexp.ExpressionAcceptor acc, SchemaLevelNodeIterator ipIterator, boolean deep, boolean throughNamespaces, int stepOver) throws SchemaException
acc
- acceptor, that will accept this iterator sequence. If function
succeeds, then acceptor had eaten last item of iterator. If function
fails, then contents of acceptor are undefined.ipIterator
- iterator, that describes contents, that will be
validated. Validation starts from actual position of iterator.deep
- if validator must perform deep check, that is, verify
complete tree rooted in element
. If not, then each
element with context-free rule is skipped to allow fast validation. For
further description, see the other validate method.throughNamespaces
- if the validation must validate element from
another namespace. If so, then we must ask
EuromathSchemaProvider
to do so. This has higher priority
than parameter deep - even if deep
is true, this parameter
can forbid walking through namespaces.stepOver
- the number of items of iterator that shall be stepped
over. If -1
is given then all items are processed.
SchemaException
- when an validity mismatch had been found.public void feedAttributes(com.sun.msv.verifier.Acceptor acc, Element element, boolean checkForeign, boolean finish) throws SchemaException
acc
- acceptor to feed.element
- element, which attributes have to be given to acceptor.checkForeign
- if check validity of foreign attributes thoroughly -
with the EuromathSchemaProvider.validate()
function.finish
- if true, then announce end of attributes after succesfull
attribute feeding.
SchemaException
- if acceptor finds an validity mismatch.public Attributes createAttributes(Element element)
Attributes
interface from given
element's attributes.
element
- return attributes from this element.
Attributes
interface.public boolean stepForward(com.sun.msv.verifier.regexp.ExpressionAcceptor acc, String uri, String name, Node parent)
acc
- acceptor, which will step forward. When true is returned, then
acceptor is ready to step over next node. When false, acceptor state is
undefined.uri
- namespace of an element.name
- local name of an element.parent
- the parent node, used to provide correct context.
public boolean stepForward(com.sun.msv.verifier.regexp.ExpressionAcceptor acc, Element e, String text, Node parent)
acc
- acceptor, which will step forward. When true is returned, then
acceptor is ready to step over next node. When false, acceptor state is
undefined.e
- reference to element. When not null, then acceptor will step
over this element. When null, acceptor will step over given text.text
- reference to text.parent
- the parent node, used to provide a context to the acceptor when e is null
.
public boolean stepForward(com.sun.msv.verifier.regexp.ExpressionAcceptor acc, ContentInfo dpi, boolean deep, boolean throughNamespaces)
acc
- acceptor, which will step forward. When true is returned, then
acceptor is ready to step over next node. When false, acceptor state is
undefined.dpi
- the next contents that the acceptor will eat.deep
- if validator must perform deep check, that is, verify
complete tree rooted in element
. If not, then each
element with context-free rule is skipped to allow fast validation. For
further description, see the other validate method.throughNamespaces
- if the validation must validate element from
another namespace. If so, then we must ask
EuromathSchemaProvider
to do so. This has higher priority
than parameter deep - even if deep
is true, this parameter
can forbid walking through namespaces.
public com.sun.msv.verifier.regexp.ExpressionAcceptor createAcceptor(com.sun.msv.grammar.Expression exp)
exp
- expression, that the acceptor will work with.
public com.sun.msv.util.StartTagInfo createSTI(Element e)
StartTagInfo
instance for given element.
e
- the element
public com.sun.msv.util.StartTagInfo createSTI(Element e, String namespace)
StartTagInfo
instance for given element. It pretends,
that this element has the namespace
namespace.
e
- the elementnamespace
- overrides elements' namespace with this value.
public com.sun.msv.util.StartTagInfo createSTI(Element e, String namespace, Attributes attrs)
StartTagInfo
instance for given element. It pretends,
that this element has the namespace
namespace.
e
- the elementnamespace
- overrides elements' namespace with this value.attrs
- attributes of this element.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |