nu.xom

Class ProcessingInstruction

Object
  extended by nu.xom.Node
      extended by nu.xom.ProcessingInstruction

public class ProcessingInstruction
extends Node

This class represents an XML processing instruction. Each processing instruction has two key properties:

Version:
1.0
Author:
Elliotte Rusty Harold

Constructor Summary
ProcessingInstruction(ProcessingInstruction instruction)

           Create a copy of a processing instruction.
ProcessingInstruction(String target, String data)

           Create a processing instruction with a certain target and data.
 
Method Summary
 Nodecopy()

           Returns a deep copy of this processing instruction with no parent, that can be added to this document or a different one.
 NodegetChild(int position)

           Throws IndexOutOfBoundsException because processing instructions do not have children.
 intgetChildCount()

           Returns 0 because processing instructions do not have children.
 StringgetTarget()

           Returns the processing instruction target.
 StringgetValue()

           Returns the processing instruction data.
 voidsetTarget(String target)

           Sets the target.
 voidsetValue(String data)

           Sets the data.
 StringtoString()

           Returns a String representation of this processing instruction suitable for debugging and diagnosis.
 StringtoXML()

           Returns the actual XML form of this processing instruction, such as might be copied and pasted from the original document.
 
Methods inherited from class nu.xom.Node
detach, equals, getBaseURI, getDocument, getParent, hashCode, query, query
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProcessingInstruction

public ProcessingInstruction(String target,
                             String data)

Create a processing instruction with a certain target and data.

Parameters:
target - the target of the processing instruction
data - the processing instruction data
Throws:
IllegalTargetException - if the target is not a non-colonized name or is the string "xml" in any case
IllegalDataException - if data contains "?>" or any other illegal characters

ProcessingInstruction

public ProcessingInstruction(ProcessingInstruction instruction)

Create a copy of a processing instruction.

Parameters:
instruction - the processing instruction to copy
Method Detail

getTarget

public final String getTarget()

Returns the processing instruction target.

Returns:
the target

setTarget

public void setTarget(String target)

Sets the target.

Parameters:
target - the new target
Throws:
IllegalTargetException - if the proposed target is not an XML 1.0 non-colonized name or is the string "xml" in any case

setValue

public void setValue(String data)

Sets the data.

Parameters:
data - the data to set
Throws:
IllegalDataException - if data is null or otherwise not legal XML processing instruction data

getValue

public final String getValue()

Returns the processing instruction data.

Specified by:
getValue in class Node
Returns:
the data of the processing instruction

getChild

public final Node getChild(int position)

Throws IndexOutOfBoundsException because processing instructions do not have children.

Specified by:
getChild in class Node
Parameters:
position - the index of the child node to return
Returns:
never returns because processing instructions do not have children; always throws an exception.
Throws:
IndexOutOfBoundsException - because processing instructions do not have children

getChildCount

public final int getChildCount()

Returns 0 because processing instructions do not have children.

Specified by:
getChildCount in class Node
Returns:
zero

toXML

public final String toXML()

Returns the actual XML form of this processing instruction, such as might be copied and pasted from the original document.

Specified by:
toXML in class Node
Returns:
an XML representation of this processing instruction as a String

copy

public Node copy()

Returns a deep copy of this processing instruction with no parent, that can be added to this document or a different one.

Specified by:
copy in class Node
Returns:
a copy of this ProcessingInstruction with no parent

toString

public final String toString()

Returns a String representation of this processing instruction suitable for debugging and diagnosis. This is not the XML representation of this processing instruction.

Overrides:
toString in class Object
Returns:
a non-XML string representation of this ProcessingInstruction


Copyright 2002-2010 Elliotte Rusty Harold

elharo@ibiblio.org