Oracle9i Supplied Java Packages Reference Release 2 (9.2) Part Number A96609-01 |
|
This chapter describes package oracle.xml.async, which encapsulates the XML Parser for Java DOMParser
class with a bean interface and extends its functionality to enable asynchronous parsing. It is part of Oracle XML Transviewer Beans that are provided as part of XDK for Java Beans. XML Transviewer Beans facilitate the addition of graphical or visual interfaces to your XML applications.
This chaper contains these sections:
Package oracle.xml.async implements a non-visual bean, DOMBuilder bean, which builds a DOM tree from an XML document.
The DOMBuilder bean encapsulates the XML Parser for Java DOMParser
class with a bean interface and extends its functionality to enable asynchronous parsing. By registering a listener, Java applications can parse large documents or successive instances of documents and then allow control to return immediately to the caller.
It enables asynchronous DOM parsing in separate threads in the background. It utilizes the EventHandler interface to notify the calling class when the job is complete.
Information about developing applications using Oracle XML Transviewer Java Beans is available in Oracle9i XML Developer's Kits Guide - XDK.
public class DOMBuilder extends java.lang.Object implements java.io.Serializable, oracle.xml.async.DOMBuilderConstants, java.lang.Runnable java.lang.Object | +--oracle.xml.async.DOMBuilder
oracle.xml.async.DOMBuilderConstants, java.lang.Runnable, java.io.Serializable
This class encapsulates an eXtensible Markup Language (XML) 1.0 parser to parse an XML document and build a DOM tree. The parsing is done in a separate thread and DOMBuilderListener interface must be used for notification when the tree is built.
protected org.xml.sax.InputSource inSource
InputSource containing XML data to parse
protected java.io.InputStream inStream
InputStream containing XML data to parse
protected java.lang.String inString
String containing the URL to parse XML data from
protected int methodToCall
XML Parser method to call based on input types
protected java.io.Reader reader
java.io.Reader containing XML data to be parsed
protected oracle.xml.async.XMLDocument result
XML Document being parsed
protected java.lang.String rootName
Name of the XML element to be treated as root
protected java.net.URL url
URL to parse XML data from
public DOMBuilder()
Creates a new parser object.
public DOMBuilder(int id)
Creates a new parser object with a given id.
id
- The DOMBuilder id.
public void addDOMBuilderErrorListener(DOMBuilderErrorListener p0)
Adds DOMBuilderErrorListener
p1 - The DOMBuilderErrorListener to add
public void addDOMBuilderListener(DOMBuilderListener p0)
Adds DOMBuilderListener
p1
- The DOMBuilderListener to add
public synchronized oracle.xml.async.DTD getDoctype()
Get the DTD
The DTD
public synchronized oracle.xml.async.XMLDocument getDocument()
Gets the document
The document being parsed
public int getId()
Returns the parser object id.
The DOMBuilder id
public synchronized java.lang.String getReleaseVersion()
Returns the release version of the Oracle XML Parser
the release version string
public synchronized org.w3c.dom.Document getResult()
Gets the document
The document being parsed
public synchronized boolean getValidationMode()
Returns the validation mode
true if the XML parser is validating false if not
public final synchronized void parse(org.xml.sax.InputSource in)
Parses the XML from given input source
in - the org.xml.sax.InputSouce to parse
XMLParseException - if syntax or other error encountered.
SAXException - Any SAX exception, possibly wrapping another exception.
IOException - IO Error.
public final synchronized void parse(java.io.InputStream in)
Parses the XML from given input stream. The base URL should be set for resolving external entities and DTD.
in
- the InputStream
containing XML data to parse.
XMLParseException
- if syntax or other error encountered.
SAXException
- Any SAX exception, possibly wrapping another exception.
IOException
- IO Error.
oracle.xml.parser.v2.XMLParser
public final synchronized void parse(java.io.Reader r)
Parses the XML from given input stream. The base URL should be set for resolving external entities and DTD.
r
- the Reader
containing XML data to parse.
XMLParseException
- if syntax or other error encountered.
SAXException
- Any SAX exception, possibly wrapping another exception.
IOException
- IO Error.
oracle.xml.parser.v2.XMLParser
public final synchronized void parse(java.lang.String in)
Parses the XML from the URL indicated
in
- the String
containing the URL to parse from
XMLParseException
- if syntax or other error encountered.
SAXException
- Any SAX exception, possibly wrapping another exception.
IOException
- IO Error.
public final synchronized void parse(java.net.URL url)
Parses the XML document pointed to by the given URL and creates the corresponding XML document hierarchy.
url
- the url points to the XML document to parse.
XMLParseException
- if syntax or other error encountered.
SAXException
- Any SAX exception, possibly wrapping another exception.
IOException
- IO Error.
public final synchronized void parseDTD(org.xml.sax.InputSource in, java.lang.String rootName)
Parses the XML External DTD from given input source
in
- the org.xml.sax.InputSouce
to parse
rootName
- the element to be used as root Element
XMLParseException
- if syntax or other error encountered.
SAXException
- Any SAX exception, possibly wrapping another exception.
IOException
- IO Error.
public final synchronized void parseDTD(java.io.InputStream in, java.lang.String rootName)
Parses the XML External DTD from given input stream. The base URL should be set for resolving external entities and DTD.
in
- the InputStream
containing XML data to parse.
rootName
- the element to be used as root Element
XMLParseException
- if syntax or other error encountered.
SAXException
- Any SAX exception, possibly wrapping another exception.
IOException
- IO Error.
oracle.xml.parser.v2.XMLParser
public final synchronized void parseDTD(java.io.Reader r, java.lang.String rootName)
Parses the XML External DTD from given input stream. The base URL should be set for resolving external entities and DTD.
r
- the Reader
containing XML data to parse.
rootName
- the element to be used as root Element
XMLParseException
- if syntax or other error encountered.
SAXException
- Any SAX exception, possibly wrapping another exception.
IOException
- IO Error.
oracle.xml.parser.v2.XMLParser
public final synchronized void parseDTD(java.lang.String in, java.lang.String rootName)
Parses the XML External DTD from the URL indicated
in
- the String
containing the URL to parse from
rootName
- the element to be used as root Element
XMLParseException
- if syntax or other error encountered.
SAXException
- Any SAX exception, possibly wrapping another exception.
IOException
- IO Error.
public final synchronized void parseDTD(java.net.URL url, java.lang.String rootName)
Parses the XML External DTD document pointed to by the given URL and creates the corresponding XML document hierarchy.
url
- the url points to the XML document to parse.
rootName
- the element to be used as root Element
XMLParseException
- if syntax or other error encountered.
SAXException
- Any SAX exception, possibly wrapping another exception.
IOException
- IO Error.
public synchronized void removeDOMBuilderErrorListener(DOMBuilderErrorListener p0)
Remove DOMBuilderErrorListener
p1
- The DOMBuilderErrorListener
to remove
public synchronized void removeDOMBuilderListener(DOMBuilderListener p0)
Remove DOMBuilderListener
p1
- The DOMBuilderListener
to remove
public void run()
This method runs in a thread
java.lang.Runnable.run() in interface java.lang.Runnable
public synchronized void setBaseURL(java.net.URL url)
Set the base URL for loading external enitites and DTDs. This method should to be called if the parse(InputStream) is used to parse the XML Document
url
- The base URL
public void setDebugMode(boolean flag)
Sets a flag to turn on debug information in the document
flag
- determines whether debug info is stored
public synchronized void setDoctype(oracle.xml.async.DTD dtd)
Set the DTD
dtd
- DTD
to set and used while parsing
public final synchronized void setErrorStream(java.io.OutputStream out)
Creates an output stream for the output of errors and warnings. If an output stream for errors is not specified, the parser will use the standard error output stream System.err
for outputting errors and warnings.
out
- The output stream to use for errors and warnings
public final synchronized void setErrorStream(java.io.OutputStream out, java.lang.String enc)
Creates an output stream for the output of errors and warnings. If an output stream for errors is not specified, the parser will use the standard error output stream System.err
for outputting errors and warnings. Additionally, an .exception is thrown if the encoding specified is unsupported.
out
- The output stream to use for errors and warnings
enc
- the encoding to use
IOException
- if an unsupported encoding is specified
public final synchronized void setErrorStream(java.io.PrintWriter out)
Creates an output stream for the output of errors and warnings. If an output stream for errors is not specified, the parser will use the standard error output stream System.err
for outputting errors and warnings.
out
- The PrintWriter
to use for errors and warnings
public synchronized void setNodeFactory(oracle.xml.async.NodeFactory factory)
Set the node factory. Applications can extend the NodeFactory and register it through this method. The parser will then use the user supplied NodeFactory to create nodes of the DOM tree.
factory
- The NodeFactory
to set
XMLParseException
- if an invalid factory is set
NodeFactory
public synchronized void setPreserveWhitespace(boolean flag)
Set the white space preserving mode
flag
- preserving mode
public synchronized void setValidationMode(boolean yes)
Set the validation mode
yes
- determines whether the XML parser should be validating
public synchronized void showWarnings(boolean yes)
Switch to determine whether to print warnings
yes
- determines whether warnings should be shown
public class DOMBuilderBeanInfo extends java.beans.SimpleBeanInfo java.lang.Object | +--java.beans.SimpleBeanInfo | +--oracle.xml.async.DOMBuilderBeanInfo
java.beans.BeanInfo
This class provides information about the DOMBuilder Bean.
public DOMBuilderBeanInfo()
The default Constructor
public java.awt.Image getIcon(int iconKind)
Gets an image object that can be used to represent DOMBuilder
bean in toolbars, toolboxes, etc.
java.beans.SimpleBeanInfo.getIcon(int) in class java.beans.SimpleBeanInfo
iconKind
- The kind of icon requested.
An image object representing the requested icon type for DOMBuilder
bean.
public java.beans.PropertyDescriptor[] getPropertyDescriptors()
Gets the DOMBuilder
bean's PropertyDescriptors
java.beans.SimpleBeanInfo.getPropertyDescriptors() in class java.beans.SimpleBeanInfo
An array of PropertyDescriptors describing the editable properties supported by DOMBuilder
bean.
public class DOMBuilderErrorEvent extends java.util.EventObject java.lang.Object | +--java.util.EventObject | +--oracle.xml.async.DOMBuilderErrorEvent
java.io.Serializable
This class defines the error event which is sent when parse exception occurs.
protected java.lang.Exception e
The exception being raised.
public DOMBuilderErrorEvent(java.lang.Object p0, java.lang.Exception e)
Constructor for DOMBuilderErrorEvent.
p0
- The Object
that created this event.
e
- The Exception
raised.
public java.lang.Exception getException()
Gets the Exception
The Exception beind raised
public java.lang.String getMessage()
Returns the error message generated by the parser
The error message string
public interface DOMBuilderErrorListener extends java.util.EventListener
java.util.EventListener
This interface must be implemented in order to receive notifications when error is found during parsing. The class implementing this interface must be added to the DOMBuilder using addDOMBuilderErrorListener method.
public void domBuilderErrorCalled(DOMBuilderErrorEvent p0)
This method is called when a parse error occurs.
p0
- The DOMBuilderErrorEvent object produced by the DOMBuilder as result of parsing error
public class DOMBuilderEvent extends java.util.EventObject java.lang.Object | +--java.util.EventObject | +--oracle.xml.async.DOMBuilderEvent
java.io.Serializable
The event object that DOMBuilder uses to notify all registered listeners about parse events.
protected int id
ID of the source DOMBuilder object
public DOMBuilderEvent(java.lang.Object p0, int p1)
Creates a new DOMBuilderEvent
p0
- The Object
creating this event.
p1
- Id of the DOMBuilder
creating this event.
public int getID()
Returns unique id of the DOMBuilder object which can be used to identify which instance of the DOMBuilder generated this event in cases where multiple instances of DOMBuilder may be working in background.
The unique id
of the source DOMBuilder for this event.
public interface DOMBuilderListener extends java.util.EventListener
java.util.EventListener
This interface must be implemented in order to receive notifications about events during the asyncronous parsing. The class implementing this interface must be added to the DOMBuilder using addDOMBuilderListener method.
public void domBuilderError(DOMBuilderEvent p0)
This method is called when parse error occur.
p0
- - The DOMBuilderEvent object produced by the DOMBuilder
public void domBuilderOver(DOMBuilderEvent p0)
This method is called when the parse is complete
p0
- - The DOMBuilderEvent object produced by the DOMBuilder
public void domBuilderStarted(DOMBuilderEvent p0)
This method is called when parse starts
p0
- - The DOMBuilderEvent object produced by the DOMBuilder
public class ResourceManager extends java.lang.Object java.lang.Object | +--oracle.xml.async.ResourceManager
public ResourceManager(int i)
The ResourceManager constructor
i
- - the number of resources to manage
public boolean activeFound()
Checks if any of the logical resources being managed are in active use
true
- if one or more resource is in use false
- if none of the resources are in use
public synchronized void getResource()
If the number of resources available for use is nonzero, the method decreases the number of resources by one. Otherwise, it waits until a resource is released & it becomes available for use.
public void releaseResource()
Releases a resource. When this method is called, the number of resources avialable is increased by one.
public void sleep(int i)
Allows usage of Thread.sleep() without try/catch
public class XSLTransformer extends java.lang.Object implements java.io.Serializable, oracle.xml.async.XSLTransformerConstants, java.lang.Runnable java.lang.Object | +--oracle.xml.async.XSLTransformer
java.lang.Runnable, java.io.Serializable, oracle.xml.async.XSLTransformerConstants
Applies XSL transformation in a background thread.
protected int methodToCall
The XSL transformation method to call based on input types.
protected oracle.xml.async.DocumentFragment result
Transformation result document.
public XSLTransformer()
XSLTransformer constructor
public XSLTransformer(int id)
XSLTransformer constructor accepting an identifier
id
- - A unique integer that can be used to identify the XSLTransformer instance during event processing
public void addXSLTransformerErrorListener(XSLTransformerErrorListener p0)
Adds an XSLTransformer error event listener
p0
- XSLTransformerErrorListener to be added
public void addXSLTransformerListener(XSLTransformerListener p0)
Adds a XSLTransformer listener
p0
- XSLTransformerListener to be added
public int getId()
Returns the unique XSLTransformer id
The id of this XSLTransformer.
public synchronized oracle.xml.async.DocumentFragment getResult()
Returns the document fragment for the resulting document. Call this method only after receiving notification that the transformation is complete. Since the transformation occurs in background and asyncronously, calling this method immediately after processXSL will result in holding the control until the result is avialable.
The resulting document fragment of the XSL transformation.
public void processXSL(oracle.xml.async.XSLStylesheet xsl, java.io.InputStream xml, java.net.URL ref)
Initiates XSL Transformation in the background. The control is returned immediately.
xsl
- The stylesheet to be used for XSL transformation
xml
- The XML document to be used (as a java.io.InputStream)
ref
- Reference URL to resolve external entities in input XML
XSLException
- if an error occurs during XSL transformation
public void processXSL(oracle.xml.async.XSLStylesheet xsl, java.io.Reader xml, java.net.URL ref)
Initiates XSL Transformation in the background. The control is returned immediately.
xsl
- The stylesheet to be used for XSL transformation
xml
- The XML document to be used (as a java.io.Reader)
ref
- Reference URL to resolve external entities in input XML
XSLException
- if an error occurs during XSL transformation
public void processXSL(oracle.xml.async.XSLStylesheet xsl, java.net.URL xml, java.net.URL ref)
Initiates XSL Transformation in the background. The control is returned immediately.
xsl
- The stylesheet to be used for XSL transformation
xml
- The XML document to be used (as a java.net.URL)
ref
- Reference URL to resolve external entities in input XML
XSLException
- if an error occurs during XSL transformation
public void processXSL(oracle.xml.async.XSLStylesheet xsl, oracle.xml.async.XMLDocument xml)
Initiates XSL Transformation in the background. The control is returned immediately.
xsl
- The stylesheet to be used for XSL transformation
xml
- The XML document to be used (as a DOM Tree)
XSLException
- if an error occurs during XSL transformation
public void processXSL(oracle.xml.async.XSLStylesheet xsl, oracle.xml.async.XMLDocument xml, java.io.OutputStream os)
Initiates XSL Transformation in the background. The control is returned immediately.
xsl
- The stylesheet to be used for XSL transformation
xml
- The XML document to be used (as a DOM Tree)
os
- Outputstream to which the XSL transformation result is written
XSLException
- if an error occurs during XSL transformation
public synchronized void removeDOMTransformerErrorListener(XSLTransformerErrorListener p0)
Removes an XSLTransformer error event listener
p0
- XSLTransformerErrorListener to be removed
public synchronized void removeXSLTransformerListener(XSLTransformerListener p0)
Removes a XSLTransformer listener
p0
- XSLTransformerListener to be removed
public void run()
Starts a separate thread to do the XSL Transformation.
java.lang.Runnable.run() in interface java.lang.Runnable
public final void setErrorStream(java.io.OutputStream out)
Sets the error stream used by the XSL processor
out
- The error output stream for the XSL processor
public final void showWarnings(boolean yes)
Sets the showWarnings flag used by the XSL processor
yes
- Boolean indicating if XSL processor warnings to be shown or not.
public class XSLTransformerBeanInfo extends java.beans.SimpleBeanInfo java.lang.Object | +--java.beans.SimpleBeanInfo | +--oracle.xml.async.XSLTransformerBeanInfo
java.beans.BeanInfo
This class provides information about the XSLTransformer Bean.
public XSLTransformerBeanInfo()
The default Constructor
public java.awt.Image getIcon(int iconKind)
Gets an image object that can be used to represent XSLTransformer
bean in toolbars, toolboxes, etc.
java.beans.SimpleBeanInfo.getIcon(int) in class java.beans.SimpleBeanInfo
iconKind
- The kind of icon requested.
An image object representing the requested icon type for XSLTransformer
bean.
public java.beans.PropertyDescriptor[] getPropertyDescriptors()
Gets the XSLTransformer
bean's PropertyDescriptors
java.beans.SimpleBeanInfo.getPropertyDescriptors() in class java.beans.SimpleBeanInfo
An array of PropertyDescriptors describing the editable properties supported by XSLTransformer
bean.
public class XSLTransformerErrorEvent extends java.util.EventObject java.lang.Object | +--java.util.EventObject | +--oracle.xml.async.XSLTransformerErrorEvent
java.io.Serializable
The error event object that XSLTransformer uses to notify all registered listeners about transformation error events.
protected java.lang.Exception e
The exception being raised.
public XSLTransformerErrorEvent(java.lang.Object p0, java.lang.Exception e)
Constructor for XSLTransformerErrorEvent.
p0
- The Object
that created this event
e
- The Exception
raised.
public java.lang.Exception getException()
Returns the exception that XSLTransformer encountered object unique id. Can be used to
The transformation exception
public java.lang.String getMessage()
Returns the error message that describes the error that XSLTransformer encountered
The error message
public interface XSLTransformerErrorListener extends java.util.EventListener
java.util.EventListener
This interface must be implemented in order to receive notifications about error events during the asynchronous transformation. The class implementing this interface must be added to the XSLTransformer using addXSLTransformerListener method.
public void xslTransformerErrorCalled(XSLTransformerErrorEvent p0)
This method is called when parse or transformation error occurs.
p0
- - The XSLTransformerErrorEvent object produced by the XSLTransformer
public class XSLTransformerEvent extends java.util.EventObject java.lang.Object | +--java.util.EventObject | +--oracle.xml.async.XSLTransformerEvent
java.io.Serializable
protected int id
ID of the source XSLTransformer object
public XSLTransformerEvent(java.lang.Object p0, int p1)
Constructs the XSLTransformerEvent object using the XSLTransformer source object and its unique id.
p0
- The source XSLTransformer object that will fire the events
p1
- Unique id identifying the source object
public int getID()
Returns unique id of the XSLTransformer object which can be used to identify which instance of the XSLTransformer generated this event in cases where multiple instances of XSLTransformer may be working in background.
The unique id
of the source XSLTransformer object for this event object.
public interface XSLTransformerListener extends java.util.EventListener
java.util.EventListener
This interface must be implemented in order to receive notifications about events during the asynchronous transformation. The class implementing this interface must be added to the XSLTransformer using addXSLTransformerListener method.
public void xslTransformerError(XSLTransformerEvent p0)
This method is called when parse or transformation error occur.
p0
- - The XSLTransformerEvent object produced by the XSLTransformer
public void xslTransformerOver(XSLTransformerEvent p0)
This method is called when the transformation is complete
p0
- - The XSLTransformerEvent object produced by the XSLTransformer
public void xslTransformerStarted(XSLTransformerEvent p0)
This method is called when the transformation starts
p0 - - The XSLTransformerEvent object produced by the XSLTransformer.
|
Copyright © 1996, 2002 Oracle Corporation. All Rights Reserved. |
|