Package javanet.staxutils.helpers
Class EventMatcher
java.lang.Object
javanet.staxutils.helpers.EventMatcher
Provides utility methods useful for comparing two
XMLEvent
instances.
These methods compare only location/type-independent information, and thus don't
perform strict equality testing, which would include the event's location,
schema-type and dtd-type.- Version:
- $Revision: 1.2 $
- Author:
- Christian Niles
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
eventsMatch
(Attribute a, Attribute b) Compares twoAttribute
s, returningtrue
if their names and values are the same.static boolean
eventsMatch
(Characters a, Characters b) Compares twoCharacters
s.static boolean
eventsMatch
(Comment a, Comment b) Compares twoComment
s.static boolean
eventsMatch
(DTD a, DTD b) Compares twoDTD
s.static boolean
Compares twoEndDocument
s.static boolean
eventsMatch
(EndElement a, EndElement b) Compares twoEndElement
s.static boolean
Compares twoEntityDeclaration
s.static boolean
Compares twoEntityReference
s.static boolean
eventsMatch
(Namespace a, Namespace b) Compares twoNamespace
s.static boolean
Compares twoNotationDeclaration
s.static boolean
Compares twoProcessingInstruction
s.static boolean
Compares twoStartDocument
s.static boolean
Compares twoStartElement
s.static boolean
eventsMatch
(XMLEvent a, XMLEvent b) Compares twoXMLEvent
instances.static boolean
matchAttributes
(Iterator a, Iterator b) Iterates over two sets ofAttribute
s and determines if both contain matching attributes.static boolean
matchNamespaces
(Iterator a, Iterator b) Iterates over two sets ofNamespace
s and determines if both contain matching namespaces.
-
Method Details
-
eventsMatch
Compares twoXMLEvent
instances. This method delegates actual matching to the appropriate overloaded method.- Parameters:
a
- The first event.b
- The second event.- Returns:
true
if the events match,false
otherwise.
-
eventsMatch
Compares twoAttribute
s, returningtrue
if their names and values are the same.- Parameters:
a
- The first event.b
- The second event.- Returns:
true
if the events match,false
otherwise.
-
eventsMatch
Compares twoCharacters
s. This method will returntrue
only if they have the same event type (XMLStreamConstants.CHARACTERS
,XMLStreamConstants.CDATA
, orXMLStreamConstants.SPACE
), and their text content matches.- Parameters:
a
- The first event.b
- The second event.- Returns:
true
if the events match,false
otherwise.
-
eventsMatch
Compares twoComment
s. This method will returntrue
only if their text content matches.- Parameters:
a
- The first event.b
- The second event.- Returns:
true
if the events match,false
otherwise.
-
eventsMatch
Compares twoDTD
s. This method will returntrue
only if their declarations are identical.- Parameters:
a
- The first event.b
- The second event.- Returns:
true
if the events match,false
otherwise.
-
eventsMatch
Compares twoEndDocument
s. BecauseEndDocument
events have no real state, two instances always match.- Parameters:
a
- The first event.b
- The second event.- Returns:
true
if the events match,false
otherwise.
-
eventsMatch
Compares twoEndElement
s. This method will returntrue
only if their names match.- Parameters:
a
- The first event.b
- The second event.- Returns:
true
if the events match,false
otherwise.
-
eventsMatch
Compares twoEntityDeclaration
s. This method will returntrue
only if the two events' names, replacement text, public IDs, system IDs, and notations are the same.- Parameters:
a
- The first event.b
- The second event.- Returns:
true
if the events match,false
otherwise.
-
eventsMatch
Compares twoEntityReference
s. This method will returntrue
only if the two references have the same name, and their declarations also match.- Parameters:
a
- The first event.b
- The second event.- Returns:
true
if the events match,false
otherwise.
-
eventsMatch
Compares twoNamespace
s. This method will returntrue
only if the two namespaces have identical prefixes and namespace URIs.- Parameters:
a
- The first event.b
- The second event.- Returns:
true
if the events match,false
otherwise.
-
eventsMatch
Compares twoNotationDeclaration
s. This method will returntrue
only if the two namespaces have identical names, public IDs, and system IDs.- Parameters:
a
- The first event.b
- The second event.- Returns:
true
if the events match,false
otherwise.
-
eventsMatch
Compares twoProcessingInstruction
s. This method will returntrue
only if the two events have identical targets and data.- Parameters:
a
- The first event.b
- The second event.- Returns:
true
if the events match,false
otherwise.
-
eventsMatch
Compares twoStartDocument
s. This method will returntrue
only if the two events have identical encodings, versions, and have the same standalone setting.- Parameters:
a
- The first event.b
- The second event.- Returns:
true
if the events match,false
otherwise.
-
eventsMatch
Compares twoStartElement
s. This method will returntrue
only if the two events have identical names, attributes, and namespaces.- Parameters:
a
- The first event.b
- The second event.- Returns:
true
if the events match,false
otherwise.
-
matchAttributes
Iterates over two sets ofAttribute
s and determines if both contain matching attributes. -
matchNamespaces
Iterates over two sets ofNamespace
s and determines if both contain matching namespaces.
-