org.apache.crimson.tree
Class PINode

java.lang.Object
  extended byorg.apache.crimson.tree.NodeBase
      extended byorg.apache.crimson.tree.PINode
All Implemented Interfaces:
org.w3c.dom.Node, NodeEx, org.w3c.dom.NodeList, org.w3c.dom.ProcessingInstruction, XmlWritable

final class PINode
extends NodeBase
implements org.w3c.dom.ProcessingInstruction

Node representing an XML processing instruction.

Functionality to restore in some other way: As a convenience function, the instruction data may optionally be parsed as element attributes are parsed. There is no requirement to use this particular syntax for instruction data.

Author:
David Brownell

Field Summary
private  char[] data
           
(package private)  XmlDocument ownerDocument
           
(package private)  boolean readonly
           
private  String target
           
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
  PINode()
          Constructs a processing instruction node.
(package private) PINode(String target, char[] buf, int offset, int len)
           
  PINode(String target, String text)
          Constructs a processing instruction node.
 
Method Summary
 org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
          DOM: Throws a HIERARCHY_REQUEST_ERR DOMException.
 org.w3c.dom.Node cloneNode(boolean deep)
          Returns a new processing instruction with the same content as this.
 org.w3c.dom.NamedNodeMap getAttributes()
          DOM: returns null.
 org.w3c.dom.NodeList getChildNodes()
          DOM: Returns an object which permits "live" access to all this node's children.
 String getData()
          DOM: Returns the text data as a string.
 org.w3c.dom.Node getFirstChild()
          DOM: Returns null.
 int getIndexOf(org.w3c.dom.Node maybeChild)
          Returns the index of the node in the list of children, such that item() will return that child.
 String getInheritedAttribute(String name)
          Returns the value of a given attribute, tracing up through ancestors if needed.
 String getLanguage()
          Returns the language id (value of xml:lang attribute) applicable to this node, if known.
 org.w3c.dom.Node getLastChild()
          DOM: returns null.
 int getLength()
          DOM: Returns zero.
 String getLocalName()
          DOM2: returns null.
(package private)  String getMessage(String messageId)
           
(package private)  String getMessage(String messageId, Object[] parameters)
           
 String getNamespaceURI()
          DOM2: returns null.
 org.w3c.dom.Node getNextSibling()
          DOM: Returns the node immediately following this node in a breadth first traversal of the tree, or null if there is no such sibling.
 String getNodeName()
          Returns the PI target name.
 short getNodeType()
          DOM: Returns the PROCESSING_INSTRUCTION_NODE node type.
 String getNodeValue()
          DOM: Returns the text data as a string.
 org.w3c.dom.Document getOwnerDocument()
          DOM: Returns the document to which this node belongs.
(package private)  ParentNode getParentImpl()
           
 org.w3c.dom.Node getParentNode()
          DOM: Returns the node's parent.
 String getPrefix()
          DOM2: returns null.
 org.w3c.dom.Node getPreviousSibling()
          DOM: Returns the node immediately preceding this node in a breadth first traversal of the tree, or null if there is no such sibling.
 String getTarget()
          DOM: Returns the processor the instruction is directed to.
 boolean hasAttributes()
          Returns whether this node (if it is an element) has any attributes.
 boolean hasChildNodes()
          DOM: Returns false.
 org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
          DOM: Throws a HIERARCHY_REQUEST_ERR DOMException.
 boolean isReadonly()
          Method to allow easy determination of whether a node is read only.
 boolean isSupported(String feature, String version)
          DOM2:
 org.w3c.dom.Node item(int i)
          DOM: Returns null.
 void normalize()
          DOM2: noop.
 org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
          DOM: Throws a HIERARCHY_REQUEST_ERR DOMException.
 org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
          DOM: Throws a HIERARCHY_REQUEST_ERR DOMException.
 void setData(String data)
          DOM: Assigns the text data.
 void setNodeValue(String data)
          DOM: Assigns the text data.
protected  void setOwnerDocument(XmlDocument doc)
           
(package private)  void setParentNode(ParentNode arg, int index)
           
 void setPrefix(String prefix)
          DOM2: throws DOMException.NAMESPACE_ERR Overridden by subclasses that support namespaces.
 void setReadonly(boolean deep)
          Sets the node to be readonly; applies recursively to the children of this node if the parameter is true.
 void setTarget(String target)
          DOM: Assigns the processor the instruction is directed to.
 void writeChildrenXml(XmlWriteContext context)
          Does nothing; this type of node has no children.
 void writeXml(XmlWriteContext context)
          Writes the processing instruction as well formed XML text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setPrefix
 

Field Detail

target

private String target

data

private char[] data

ownerDocument

XmlDocument ownerDocument

readonly

boolean readonly
Constructor Detail

PINode

public PINode()
Constructs a processing instruction node.


PINode

public PINode(String target,
              String text)
Constructs a processing instruction node.


PINode

PINode(String target,
       char[] buf,
       int offset,
       int len)
Method Detail

getNodeType

public short getNodeType()
DOM: Returns the PROCESSING_INSTRUCTION_NODE node type.

Specified by:
getNodeType in interface org.w3c.dom.Node

getTarget

public String getTarget()
DOM: Returns the processor the instruction is directed to.

Specified by:
getTarget in interface org.w3c.dom.ProcessingInstruction

setTarget

public void setTarget(String target)
DOM: Assigns the processor the instruction is directed to.


getData

public String getData()
DOM: Returns the text data as a string.

Specified by:
getData in interface org.w3c.dom.ProcessingInstruction

setData

public void setData(String data)
DOM: Assigns the text data.

Specified by:
setData in interface org.w3c.dom.ProcessingInstruction

getNodeValue

public String getNodeValue()
DOM: Returns the text data as a string.

Specified by:
getNodeValue in interface org.w3c.dom.Node
Overrides:
getNodeValue in class NodeBase

setNodeValue

public void setNodeValue(String data)
DOM: Assigns the text data.

Specified by:
setNodeValue in interface org.w3c.dom.Node
Overrides:
setNodeValue in class NodeBase

writeXml

public void writeXml(XmlWriteContext context)
              throws IOException
Writes the processing instruction as well formed XML text.

Doesn't currently check for the ?> substrings in PI data, which are illegal

Specified by:
writeXml in interface XmlWritable
Throws:
IOException

cloneNode

public org.w3c.dom.Node cloneNode(boolean deep)
Returns a new processing instruction with the same content as this.

Specified by:
cloneNode in interface org.w3c.dom.Node

getNodeName

public String getNodeName()
Returns the PI target name.

Specified by:
getNodeName in interface org.w3c.dom.Node

getParentImpl

ParentNode getParentImpl()

isReadonly

public boolean isReadonly()
Description copied from interface: NodeEx
Method to allow easy determination of whether a node is read only.

Specified by:
isReadonly in interface NodeEx
Returns:
true if the node is read only

setReadonly

public void setReadonly(boolean deep)
Description copied from interface: NodeEx
Sets the node to be readonly; applies recursively to the children of this node if the parameter is true.

Specified by:
setReadonly in interface NodeEx
Parameters:
deep - If true recursively set the nodes in the subtree under the current node to be read only. If false then set only the current node to be readonly

getLanguage

public String getLanguage()
Returns the language id (value of xml:lang attribute) applicable to this node, if known. Traces up through ancestors as needed.

Specified by:
getLanguage in interface NodeEx
Returns:
the value of the xml:lang attribute, or null if no such attribute is found.

getInheritedAttribute

public String getInheritedAttribute(String name)
Returns the value of a given attribute, tracing up through ancestors if needed. In the XML standard, two attributes are inherited: xml:lang and xml:space. This mechanism can also be involved with Cascading Style Sheets (CSS). The current version of XML Namespaces also uses inheritance.

Specified by:
getInheritedAttribute in interface NodeEx
Parameters:
name - identifies the attribute; colons may be included, but namespace prefixes are not interpreted
Returns:
the value of the inherited attribute, or null if no value was inherited.

writeChildrenXml

public void writeChildrenXml(XmlWriteContext context)
                      throws IOException
Does nothing; this type of node has no children.

Specified by:
writeChildrenXml in interface XmlWritable
Throws:
IOException

getParentNode

public org.w3c.dom.Node getParentNode()
DOM: Returns the node's parent. This will be null in cases such as newly created or removed nodes, and for attributes, fragments, and documents.

Specified by:
getParentNode in interface org.w3c.dom.Node

setParentNode

void setParentNode(ParentNode arg,
                   int index)
             throws org.w3c.dom.DOMException
Throws:
org.w3c.dom.DOMException

setOwnerDocument

protected void setOwnerDocument(XmlDocument doc)

getOwnerDocument

public org.w3c.dom.Document getOwnerDocument()
DOM: Returns the document to which this node belongs.

Specified by:
getOwnerDocument in interface org.w3c.dom.Node

hasChildNodes

public boolean hasChildNodes()
DOM: Returns false. Overridden by subclasses which support children.

Specified by:
hasChildNodes in interface org.w3c.dom.Node

getFirstChild

public org.w3c.dom.Node getFirstChild()
DOM: Returns null. Overridden by subclasses which support children.

Specified by:
getFirstChild in interface org.w3c.dom.Node

getLength

public int getLength()
DOM: Returns zero. Overridden by subclasses which support children.

Specified by:
getLength in interface org.w3c.dom.NodeList

item

public org.w3c.dom.Node item(int i)
DOM: Returns null. Overridden by subclasses which support children.

Specified by:
item in interface org.w3c.dom.NodeList

getChildNodes

public org.w3c.dom.NodeList getChildNodes()
DOM: Returns an object which permits "live" access to all this node's children.

In this implementation, nodes provide such access without needing another node as an intermediary; "this" is returned.

Specified by:
getChildNodes in interface org.w3c.dom.Node

getLastChild

public org.w3c.dom.Node getLastChild()
DOM: returns null. Overridden by subclasses which support children.

Specified by:
getLastChild in interface org.w3c.dom.Node

appendChild

public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
                             throws org.w3c.dom.DOMException
DOM: Throws a HIERARCHY_REQUEST_ERR DOMException. Overridden by subclasses which support children.

Specified by:
appendChild in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException - thrown always.

insertBefore

public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node refChild)
                              throws org.w3c.dom.DOMException
DOM: Throws a HIERARCHY_REQUEST_ERR DOMException. Overridden by subclasses which support children.

Specified by:
insertBefore in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException - thrown always.

replaceChild

public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node refChild)
                              throws org.w3c.dom.DOMException
DOM: Throws a HIERARCHY_REQUEST_ERR DOMException. Overridden by subclasses which support children.

Specified by:
replaceChild in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException - thrown always.

removeChild

public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
                             throws org.w3c.dom.DOMException
DOM: Throws a HIERARCHY_REQUEST_ERR DOMException. Overridden by subclasses which support children.

Specified by:
removeChild in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException - thrown always.

getNextSibling

public org.w3c.dom.Node getNextSibling()
DOM: Returns the node immediately following this node in a breadth first traversal of the tree, or null if there is no such sibling. In this implementation, sibling access from a node is slower than indexed access from its parent.

Specified by:
getNextSibling in interface org.w3c.dom.Node

getPreviousSibling

public org.w3c.dom.Node getPreviousSibling()
DOM: Returns the node immediately preceding this node in a breadth first traversal of the tree, or null if there is no such sibling. In this implementation, sibling access from a node is slower than indexed access from its parent.

Specified by:
getPreviousSibling in interface org.w3c.dom.Node

getAttributes

public org.w3c.dom.NamedNodeMap getAttributes()
DOM: returns null. Overridden by the ElementNode2 subclass.

Specified by:
getAttributes in interface org.w3c.dom.Node

normalize

public void normalize()
DOM2: noop.

Specified by:
normalize in interface org.w3c.dom.Node
Since:
DOM Level 2 Overridden by subclasses that need to support normalization.

isSupported

public boolean isSupported(String feature,
                           String version)
DOM2:

Specified by:
isSupported in interface org.w3c.dom.Node
Since:
DOM Level 2

getNamespaceURI

public String getNamespaceURI()
DOM2: returns null. Overridden by subclasses that support namespaces, ie. ElementNode2 and AttributeNode.

Specified by:
getNamespaceURI in interface org.w3c.dom.Node

getPrefix

public String getPrefix()
DOM2: returns null. Overridden by subclasses that support namespaces.

Specified by:
getPrefix in interface org.w3c.dom.Node

setPrefix

public void setPrefix(String prefix)
               throws org.w3c.dom.DOMException
DOM2: throws DOMException.NAMESPACE_ERR Overridden by subclasses that support namespaces.

Specified by:
setPrefix in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

getLocalName

public String getLocalName()
DOM2: returns null. Overridden by subclasses that support namespaces.

Specified by:
getLocalName in interface org.w3c.dom.Node

hasAttributes

public boolean hasAttributes()
Returns whether this node (if it is an element) has any attributes. Overridden by Element implementations

Specified by:
hasAttributes in interface org.w3c.dom.Node
Since:
DOM Level 2

getIndexOf

public int getIndexOf(org.w3c.dom.Node maybeChild)
Description copied from interface: NodeEx
Returns the index of the node in the list of children, such that item() will return that child.

Specified by:
getIndexOf in interface NodeEx
Parameters:
maybeChild - the node which may be a child of this one
Returns:
the index of the node in the set of children, or else -1 if that node is not a child of this node.

getMessage

String getMessage(String messageId)

getMessage

String getMessage(String messageId,
                  Object[] parameters)