Package org.jdom
Class ProcessingInstruction
- java.lang.Object
-
- org.jdom.Content
-
- org.jdom.ProcessingInstruction
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public class ProcessingInstruction extends Content
An XML processing instruction. Methods allow the user to obtain the target of the PI as well as its data. The data can always be accessed as a String or, if the data appears akin to an attribute list, can be retrieved as name/value pairs.- Version:
- $Revision: 1.47 $, $Date: 2007/11/10 05:28:59 $
- Author:
- Brett McLaughlin, Jason Hunter, Steven Gould
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedProcessingInstruction()Default, no-args constructor for implementations to use if needed.ProcessingInstruction(java.lang.String target, java.lang.String data)This will create a newProcessingInstructionwith the specified target and data.ProcessingInstruction(java.lang.String target, java.util.Map data)This will create a newProcessingInstructionwith the specified target and data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()This will return a clone of thisProcessingInstruction.java.lang.StringgetData()This will return the raw data from all instructions.java.util.ListgetPseudoAttributeNames()This will return aListcontaining the names of the "attribute" style pieces of name/value pairs in this PI's data.java.lang.StringgetPseudoAttributeValue(java.lang.String name)This will return the value for a specific name/value pair on the PI.java.lang.StringgetTarget()This will retrieve the target of the PI.java.lang.StringgetValue()Returns the XPath 1.0 string value of this element, which is the data of this PI.booleanremovePseudoAttribute(java.lang.String name)This will remove the pseudo attribute with the specified name.ProcessingInstructionsetData(java.lang.String data)This will set the raw data for the PI.ProcessingInstructionsetData(java.util.Map data)This will set the name/value pairs within the passedMapas the pairs for the data of this PI.ProcessingInstructionsetPseudoAttribute(java.lang.String name, java.lang.String value)This will set a pseudo attribute with the given name and value.ProcessingInstructionsetTarget(java.lang.String newTarget)This will set the target for the PI.java.lang.StringtoString()This returns aStringrepresentation of theProcessingInstruction, suitable for debugging.-
Methods inherited from class org.jdom.Content
detach, equals, getDocument, getParent, getParentElement, hashCode, setParent
-
-
-
-
Constructor Detail
-
ProcessingInstruction
protected ProcessingInstruction()
Default, no-args constructor for implementations to use if needed.
-
ProcessingInstruction
public ProcessingInstruction(java.lang.String target, java.util.Map data)This will create a newProcessingInstructionwith the specified target and data.- Parameters:
target-Stringtarget of PI.data-Mapdata for PI, in name/value pairs- Throws:
IllegalTargetException- if the given target is illegal as a processing instruction name.
-
ProcessingInstruction
public ProcessingInstruction(java.lang.String target, java.lang.String data)This will create a newProcessingInstructionwith the specified target and data.- Parameters:
target-Stringtarget of PI.data-Stringdata for PI.- Throws:
IllegalTargetException- if the given target is illegal as a processing instruction name.
-
-
Method Detail
-
setTarget
public ProcessingInstruction setTarget(java.lang.String newTarget)
This will set the target for the PI.- Parameters:
newTarget-Stringnew target of PI.- Returns:
ProcessingInstruction- this PI modified.
-
getValue
public java.lang.String getValue()
Returns the XPath 1.0 string value of this element, which is the data of this PI.
-
getTarget
public java.lang.String getTarget()
This will retrieve the target of the PI.- Returns:
String- target of PI.
-
getData
public java.lang.String getData()
This will return the raw data from all instructions.- Returns:
String- data of PI.
-
getPseudoAttributeNames
public java.util.List getPseudoAttributeNames()
This will return aListcontaining the names of the "attribute" style pieces of name/value pairs in this PI's data.- Returns:
List- theListcontaining the "attribute" names.
-
setData
public ProcessingInstruction setData(java.lang.String data)
This will set the raw data for the PI.- Parameters:
data-Stringdata of PI.- Returns:
ProcessingInstruction- this PI modified.
-
setData
public ProcessingInstruction setData(java.util.Map data)
This will set the name/value pairs within the passedMapas the pairs for the data of this PI. The keys should be the pair name and the values should be the pair values.- Parameters:
data- new map data to use- Returns:
ProcessingInstruction- modified PI.
-
getPseudoAttributeValue
public java.lang.String getPseudoAttributeValue(java.lang.String name)
This will return the value for a specific name/value pair on the PI. If no such pair is found for this PI, null is returned.- Parameters:
name-Stringname of name/value pair to lookup value for.- Returns:
String- value of name/value pair.
-
setPseudoAttribute
public ProcessingInstruction setPseudoAttribute(java.lang.String name, java.lang.String value)
This will set a pseudo attribute with the given name and value. If the PI data is not already in a pseudo-attribute format, this will replace the existing data.- Parameters:
name-Stringname of pair.value-Stringvalue for pair.- Returns:
ProcessingInstructionthis PI modified.
-
removePseudoAttribute
public boolean removePseudoAttribute(java.lang.String name)
This will remove the pseudo attribute with the specified name.- Parameters:
name- name of pseudo attribute to remove- Returns:
boolean- whether the requested instruction was removed.
-
toString
public java.lang.String toString()
This returns aStringrepresentation of theProcessingInstruction, suitable for debugging. If the XML representation of theProcessingInstructionis desired,XMLOutputter.outputString(ProcessingInstruction)should be used.- Overrides:
toStringin classjava.lang.Object- Returns:
String- information about theProcessingInstruction
-
-