Class ProcessingInstruction
- java.lang.Object
-
- nu.xom.Node
-
- nu.xom.ProcessingInstruction
-
public class ProcessingInstruction extends Node
This class represents an XML processing instruction. Each processing instruction has two key properties:
- The target, a non-colonized name
- The data, a string which does not contain the two character
sequence
?>. The syntax of the data depends completely on the processing instruction. Other than forbidding?>, XML defines no rules for processing instruction data.
- Version:
- 1.3.0
- Author:
- Elliotte Rusty Harold
-
-
Constructor Summary
Constructors Constructor Description ProcessingInstruction(java.lang.String target, java.lang.String data)Create a processing instruction with a certain target and data.ProcessingInstruction(ProcessingInstruction instruction)Create a copy of a processing instruction.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ProcessingInstructioncopy()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)ThrowsIndexOutOfBoundsExceptionbecause processing instructions do not have children.intgetChildCount()Returns 0 because processing instructions do not have children.java.lang.StringgetTarget()Returns the processing instruction target.java.lang.StringgetValue()Returns the processing instruction data.voidsetTarget(java.lang.String target)Sets the target.voidsetValue(java.lang.String data)Sets the data.java.lang.StringtoString()Returns aStringrepresentation of this processing instruction suitable for debugging and diagnosis.java.lang.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
-
-
-
-
Constructor Detail
-
ProcessingInstruction
public ProcessingInstruction(java.lang.String target, java.lang.String data)Create a processing instruction with a certain target and data.
- Parameters:
target- the target of the processing instructiondata- the processing instruction data- Throws:
IllegalTargetException- if the target is not a non-colonized name or is the string "xml" in any caseIllegalDataException- 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 java.lang.String getTarget()
Returns the processing instruction target.
- Returns:
- the target
-
setTarget
public void setTarget(java.lang.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(java.lang.String data)
Sets the data.
- Parameters:
data- the data to set- Throws:
IllegalDataException- ifdatais null or otherwise not legal XML processing instruction data
-
getValue
public final java.lang.String getValue()
Returns the processing instruction data.
-
getChild
public final Node getChild(int position)
Throws
IndexOutOfBoundsExceptionbecause processing instructions do not have children.- Specified by:
getChildin classNode- 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:
java.lang.IndexOutOfBoundsException- because processing instructions do not have children
-
getChildCount
public final int getChildCount()
Returns 0 because processing instructions do not have children.
- Specified by:
getChildCountin classNode- Returns:
- zero
-
toXML
public final java.lang.String toXML()
Returns the actual XML form of this processing instruction, such as might be copied and pasted from the original document.
-
copy
public ProcessingInstruction copy()
Returns a deep copy of this processing instruction with no parent, that can be added to this document or a different one.
-
toString
public final java.lang.String toString()
Returns a
Stringrepresentation of this processing instruction suitable for debugging and diagnosis. This is not the XML representation of this processing instruction.- Overrides:
toStringin classjava.lang.Object- Returns:
- a non-XML string representation of this
ProcessingInstruction
-
-