Overview | Package | Class | Use | Tree | Deprecated | Index | Help
|  | BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

WebLogic Server 8.1 API Reference

## weblogic.xml.xpath
Class XPathStreamFactory

    java.lang.Object
      |
      +--weblogic.xml.xpath.XPathStreamFactory

public final class XPathStreamFactory
extends java.lang.Object

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) { if (e.isStartElement()) 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.

Author:
  Copyright © 2004 BEA Systems, Inc. All Rights Reserved.

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

### XPathStreamFactory

    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.

### XPathStreamFactory

    public XPathStreamFactory(StreamXPath xpath,
                              XPathStreamObserver observer)

  Convenience constructor; equivalent to calling
  `(new XPathStreamFactory()).install(xpath,observer)` .

  Parameters:
    `xpath` - An xpath to be matched against streams created by this factory.
    `observer` - An observer to be notified of matches against the given xpath.
  Throws:
    java.lang.IllegalArgumentException - if either argument is null.

Method Detail

### install

    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.

  Parameters:
    `observer` - An observer to be notified of matches against the given xpath.
    `xpath` - An xpath to be matched against streams created by this factory.
  Throws:
    java.lang.IllegalArgumentException - if either argument is null.

### createStream

    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.

  Parameters:
    `parent` - The XMLInputStream on which matching should be performed.
  Throws:
    java.lang.IllegalArgumentException - if `parent` is null.

### createStream

    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.

  Parameters:
    `destination` - The XMLOutputStream where events written to the returned stream are sent after matching is performed.
  Throws:
    java.lang.IllegalArgumentException - if `parent` is null.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Documentation is available at http://e-docs.bea.com/wls/docs81
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD