Skip navigation links

Oracle Security Developer Tools XML Security Java API Reference
11g (11.1.1)

E10680-02


oracle.security.xmlsec.util
Class XMLContainer

java.lang.Object
  extended by oracle.security.xmlsec.util.XMLContainer


public class XMLContainer
extends java.lang.Object

Internal use only. Container for node set or octet stream XML data. For example, a XMLContainer instance may be used as input or output for a XSTransformer.


Constructor Summary
XMLContainer()
          Create a new instance of XMLContainer with no transformation input set.
XMLContainer(byte[] bytes)
          Create a new instance of XMLContainer with the given byte array.
XMLContainer(java.util.Collection nodeSet)
          Create a new instance of XMLContainer with the given node-set.
XMLContainer(java.io.InputStream octetStream)
          Create a new instance of XMLContainer with the given octet stream.
XMLContainer(org.w3c.dom.Node subTree)
          Create a new instance of XMLContainer with the given document sub-tree.
XMLContainer(org.w3c.dom.Node subTree, boolean withComments)
          Create a new instance of XMLContainer with the given document sub-tree.
XMLContainer(org.w3c.dom.NodeList nodes)
          Create a new instance of XMLContainer with the given node-set.
XMLContainer(java.lang.String systemId)
          Create a new instance of XMLContainer with the given system ID.

 

Method Summary
 java.util.Set getNodeSet()
          Returns the nodes in this container.
 java.io.InputStream getOctetStream()
          Returns the octet stream to be used for this container.
 org.w3c.dom.Node getSubTree()
          Returns the root node of the document sub-tree in this container.
 java.lang.String getSystemId()
          Returns the base ID (URL or system ID) from where URLs will be resolved.
 java.lang.Object getUserData()
          Get the userdata associated with this container.
 boolean getWithComments()
          Returns whether conversion to a node-set from a stream or sub-tree will include comment nodes.
 boolean nodeSetAvailable()
          Returns true if the contained XML is available as DOM nodes without parsing or transforming an octet stream, otherwise returns false.
 boolean octetsAvailable()
          Returns true if the contained XML is available as octets without transforming any DOM nodes or opening a connection to a system ID, otherwise returns false.
 void setSystemId(java.lang.String systemId)
          Sets the base ID (URL or system ID) from where URLs will be resolved.
 void setUserData(java.lang.Object userData)
          Set userdata associated with this container.
 void setWithComments(boolean value)
          Sets whether conversion to a node-set from a stream or sub-tree will include comment nodes.
 boolean subTreeAvailable()
          Returns true if the contained XML is available as a a DOM document subtree.
static java.util.ArrayList subtreeToNodeList(org.w3c.dom.Node node, boolean withComments, boolean sortAttribs)
          Create a node-list containing the given node and all its children, attributes and namespaces.
static java.util.Set subtreeToNodeSet(org.w3c.dom.Node node, boolean withComments)
          Create a node-set containing the given node and all its children, attributes and namespaces.
 byte[] toByteArray()
          Returns the octets contained in this XMLContainer, or null if it does not contain any data.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

XMLContainer

public XMLContainer()
Create a new instance of XMLContainer with no transformation input set.

XMLContainer

public XMLContainer(org.w3c.dom.NodeList nodes)
Create a new instance of XMLContainer with the given node-set.
Parameters:
nodes - The nodes to be contained.

XMLContainer

public XMLContainer(java.util.Collection nodeSet)
Create a new instance of XMLContainer with the given node-set.
Parameters:
nodeSet - The node-set to be contained.
Since:
2.0

XMLContainer

public XMLContainer(org.w3c.dom.Node subTree)
Create a new instance of XMLContainer with the given document sub-tree. By default, the getNodeSet() method will expand the sub-tree to include comments.
Parameters:
subTree - The root node of the sub-tree to be contained.
Since:
2.0
See Also:
XMLContainer(Node subTree, boolean withComments), getNodeSet(), setWithComments(boolean)

XMLContainer

public XMLContainer(org.w3c.dom.Node subTree,
                    boolean withComments)
Create a new instance of XMLContainer with the given document sub-tree.
Parameters:
subTree - The root node of the sub-tree to be contained.
withComments - If true, the getNodeSet() method will expand the sub-tree to include comments; if false, expansion will exclude comments.
Since:
2.0
See Also:
getNodeSet(), setWithComments(boolean)

XMLContainer

public XMLContainer(java.io.InputStream octetStream)
             throws java.io.IOException
Create a new instance of XMLContainer with the given octet stream.
Parameters:
octetStream - The InputStream to be contained.
Throws:
java.io.IOException

XMLContainer

public XMLContainer(byte[] bytes)
             throws java.io.IOException
Create a new instance of XMLContainer with the given byte array.
Parameters:
bytes - The byte array to be contained.
Throws:
java.io.IOException

XMLContainer

public XMLContainer(java.lang.String systemId)
Create a new instance of XMLContainer with the given system ID.
Parameters:
systemId - Specifies the base URI associated with the octet stream.

Method Detail

setSystemId

public void setSystemId(java.lang.String systemId)
Sets the base ID (URL or system ID) from where URLs will be resolved.
Parameters:
systemId - Base URL for the node list.

getSystemId

public java.lang.String getSystemId()
Returns the base ID (URL or system ID) from where URLs will be resolved.
Returns:
Base URL for the node list.

setWithComments

public void setWithComments(boolean value)
Sets whether conversion to a node-set from a stream or sub-tree will include comment nodes.
Parameters:
value - If true, comments will be included; if false, comments will be excluded.
Since:
2.0
See Also:
getNodeSet(), getWithComments(), XMLContainer(Node subTree, boolean withComments)

getWithComments

public boolean getWithComments()
Returns whether conversion to a node-set from a stream or sub-tree will include comment nodes.
Returns:
true if comments will be included; returns false if comments will be excluded.
Since:
2.0
See Also:
getNodeSet(), setWithComments(boolean), XMLContainer(Node subTree, boolean withComments)

getSubTree

public org.w3c.dom.Node getSubTree()
                            throws java.io.IOException,
                                   org.xml.sax.SAXException
Returns the root node of the document sub-tree in this container. If only an octet stream is available, the octets are parsed and the document node returned.
Returns:
An org.w3c.dom.Node that is the root of the DOM tree or sub-tree, or null if only a node-set (or no data) is available.
Throws:
java.io.IOException - If an error occurs reading data from the octet stream.
org.xml.sax.SAXException - If an error occurs parsing the XML data.
Since:
2.0
See Also:
subTreeAvailable()

getNodeSet

public java.util.Set getNodeSet()
                         throws java.io.IOException,
                                org.xml.sax.SAXException,
                                XPathException
Returns the nodes in this container. If only an octet stream is available, nodes are obtained by parsing the octets. If only a sub-tree is available, nodes are obtained by sub-tree expansion, including comments.

Note: The resulting node-set may contain instances of org.jaxen.dom.NamespaceNode.

Returns:
A java.util.Set of nodes, or null if no data is available.
Throws:
java.io.IOException - If an error occurs reading data from the octet stream.
org.xml.sax.SAXException - If an error occurs parsing the XML data.
XPathException - If an error occurs constructing the node-set.
Since:
2.0
See Also:
nodeSetAvailable()

getOctetStream

public java.io.InputStream getOctetStream()
                                   throws java.io.IOException
Returns the octet stream to be used for this container. If only nodes are available, an octet stream is obtained by applying XML-C14N. If no data is available, returns null. If only a system ID is available, a URL connection is opened and the input stream returned.
Throws:
java.io.IOException
See Also:
octetsAvailable()

toByteArray

public byte[] toByteArray()
                   throws java.io.IOException
Returns the octets contained in this XMLContainer, or null if it does not contain any data.

Note: When this method returns, the underlying input stream will be positioned at the end of input. Therefore, subsequent calls to toByteArray may result in an IOException being thrown.

Throws:
java.io.IOException
See Also:
getOctetStream(), octetsAvailable()

octetsAvailable

public boolean octetsAvailable()
Returns true if the contained XML is available as octets without transforming any DOM nodes or opening a connection to a system ID, otherwise returns false.
Since:
2.0
See Also:
getOctetStream(), toByteArray()

nodeSetAvailable

public boolean nodeSetAvailable()
Returns true if the contained XML is available as DOM nodes without parsing or transforming an octet stream, otherwise returns false.

This method returns true if subTreeAvailable() returns true. In this case, a call to getNodeSet() will result in sub-tree expansion using XPath.

Since:
2.0
See Also:
getNodeSet()

subTreeAvailable

public boolean subTreeAvailable()
Returns true if the contained XML is available as a a DOM document subtree.
Since:
2.0
See Also:
getSubTree()

subtreeToNodeSet

public static java.util.Set subtreeToNodeSet(org.w3c.dom.Node node,
                                             boolean withComments)
                                      throws XPathException
Create a node-set containing the given node and all its children, attributes and namespaces.

Note: The resulting node-set may contain instances of org.jaxen.dom.NamespaceNode.

Throws:
XPathException
Since:
2.0

subtreeToNodeList

public static java.util.ArrayList subtreeToNodeList(org.w3c.dom.Node node,
                                                    boolean withComments,
                                                    boolean sortAttribs)
Create a node-list containing the given node and all its children, attributes and namespaces. Similar to @link #subtreeToNodeSet(Node, boolean) except that the list is sorted by document order

Note: The resulting node-set may contain instances of org.jaxen.dom.NamespaceNode.

Parameters:
node -
withComments -
sortAttribs -
Throws:
XPathException

setUserData

public void setUserData(java.lang.Object userData)
Set userdata associated with this container. For example this can be used for storing a reference to an AttachmentPart
Parameters:
userData -

getUserData

public java.lang.Object getUserData()
Get the userdata associated with this container. For example this can be used for storing a reference to an AttachmentPart
Returns:

Skip navigation links

Oracle Security Developer Tools XML Security Java API Reference
11g (11.1.1)

E10680-02


Copyright © 2005, 2009, Oracle. All rights reserved.