|
Oracle Fusion Middleware Java API Reference for Oracle WebLogic Server 12c (12.1.3) Part Number E41849-02 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweblogic.xml.xpath.XPathStreamFactory
public final class XPathStreamFactory
Creates XMLInputStreams which perform xpath matching and notify
XPathStreamObservers of the results. One or more observers may be
registered with the factory along with a corresponding StreamXPaths
which they wish to match against; the
observers will receive event notifications from all streams
subsequently created by the factory's createStream
method.
The following code demonstrates how to create and use an XPathStreamFactory. It creates a factory, installs an observer, and then retrieves a stream from it:
XMLInputStream sourceInputStream = ... StreamXPath xpath = new StreamXPath("foo/bar/baz"); final List hits = new ArrayList(); XPathStreamFactory f = new XPathStreamFactory(); f.install(xpath, new XPathStreamObserver() { observe(XMLEvent e) { hits.add(e); } observeAttribute(XMLEvent e, Attribute a) {} // ignore observeNamespace(XMLEvent e, Attribute a) {} // ignore }); XMLInputStream mystream = f.createStream(sourceInputStream);
In this example, as events are pulled through
mystream
any events matching the xpath
foo/bar/baz
will be placed in hits
. Note
that this will include both start and end 'baz' elements.
Constructor Summary | |
---|---|
XPathStreamFactory()
Constructs an empty XPathStreamFactory. |
|
XPathStreamFactory(StreamXPath xpath,
XPathStreamObserver observer)
Convenience constructor; equivalent to calling (new
XPathStreamFactory()).install(xpath,observer)
. |
Method Summary | |
---|---|
XMLInputStream |
createStream(XMLInputStream source)
Returns an XMLInputStream which matches events in a given stream against the installed xpaths and notifies the corresponding installed observers. |
XMLOutputStream |
createStream(XMLOutputStream destination)
Returns an XMLOutputStream which matches outbound events against the installed xpaths, notifies the appropriate installed observers, and then passes the events on to a given destination stream. |
void |
install(StreamXPath xpath,
XPathStreamObserver observer)
Installs an observer that receives notifications of all events in the stream which match the given xpath. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XPathStreamFactory()
Constructs an empty XPathStreamFactory. The factory will not
be very useful until at least one xpath-observer pair is
installed using the install
method.
public XPathStreamFactory(StreamXPath xpath, XPathStreamObserver observer)
Convenience constructor; equivalent to
calling(new
XPathStreamFactory()).install(xpath,observer)
.
xpath
- An xpath to be matched against streams created by
this factory.observer
- An observer to be notified of matches against
the given xpath.
IllegalArgumentException
- if either argument is null.Method Detail |
---|
public void install(StreamXPath xpath, XPathStreamObserver observer)
Installs an observer that receives notifications of all events in the stream which match the given xpath. Note that this includes end-elements which correspond to matching start-elements.
It is legal to install more than one xpath-observer pair; each observer will receive notifications of matches for the xpath with which it was installed. It is also legal to map a single xpath to multiple observers and vice-versa.
When a matching stream event is encountered, it is guaranteed that all of the appropriate notifications (if any) concerning that event will be processed before the event is passed on to the end consumer of the stream. If multiple xpath-observer pairs are installed, they will process each XMLEvent and send notifications in installation order.
observer
- An observer to be notified of matches against
the given xpath.xpath
- An xpath to be matched against streams created by
this factory.
IllegalArgumentException
- if either argument
is null.public XMLInputStream createStream(XMLInputStream source)
Returns an XMLInputStream which matches events in a given stream against the installed xpaths and notifies the corresponding installed observers. Each event from the source stream passes through the returned stream after being evaluated against the xpaths.
source
- The XMLInputStream on which matching
should be performed.
IllegalArgumentException
- if parent
is null.public XMLOutputStream createStream(XMLOutputStream destination)
Returns an XMLOutputStream which matches outbound events
against the installed xpaths, notifies the appropriate installed
observers, and then passes the events on to a given
destination
stream.
destination
- The XMLOutputStream where events written to the
returned stream are sent after matching is performed.
IllegalArgumentException
- if parent
is null.
|
Copyright 1996, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Oracle Fusion Middleware Java API Reference for Oracle WebLogic Server 12c (12.1.3) Part Number E41849-02 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |