Package org.jdom2
Class ProcessingInstruction
java.lang.Object
org.jdom2.Content
org.jdom2.ProcessingInstruction
- All Implemented Interfaces:
Serializable
,Cloneable
,NamespaceAware
- Direct Known Subclasses:
LocatedProcessingInstruction
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.
- Author:
- Brett McLaughlin, Jason Hunter, Steven Gould
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jdom2.Content
Content.CType
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Default, no-args constructor for implementations to use if needed.ProcessingInstruction
(String target) This will create a newProcessingInstruction
with the specified target.ProcessingInstruction
(String target, String data) This will create a newProcessingInstruction
with the specified target and data.ProcessingInstruction
(String target, Map<String, String> data) This will create a newProcessingInstruction
with the specified target and data. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Return a deep clone of this instance.detach()
Detaches this child from its parent or does nothing if the child has no parent.getData()
This will return the raw data from all instructions.This will return aList
containing the names of the "attribute" style pieces of name/value pairs in this PI's data.This will return the value for a specific name/value pair on the PI.This will retrieve the target of the PI.getValue()
Returns the XPath 1.0 string value of this element, which is the data of this PI.boolean
removePseudoAttribute
(String name) This will remove the pseudo attribute with the specified name.This will set the raw data for the PI.This will set the name/value pairs within the passedMap
as the pairs for the data of this PI.protected ProcessingInstruction
Sets the parent of this Content.setPseudoAttribute
(String name, String value) This will set a pseudo attribute with the given name and value.This will set the target for the PI.toString()
This returns aString
representation of theProcessingInstruction
, suitable for debugging.Methods inherited from class org.jdom2.Content
equals, getCType, getDocument, getNamespacesInherited, getNamespacesInScope, getNamespacesIntroduced, getParent, getParentElement, hashCode
-
Field Details
-
target
The target of the PI -
rawData
The data for the PI as a String -
mapData
The data for the PI in name/value pairs
-
-
Constructor Details
-
ProcessingInstruction
protected ProcessingInstruction()Default, no-args constructor for implementations to use if needed. -
ProcessingInstruction
This will create a newProcessingInstruction
with the specified target.- Parameters:
target
-String
target of PI.- Throws:
IllegalTargetException
- if the given target is illegal as a processing instruction name.
-
ProcessingInstruction
This will create a newProcessingInstruction
with the specified target and data.- Parameters:
target
-String
target of PI.data
-Map
data for PI, in name/value pairs- Throws:
IllegalTargetException
- if the given target is illegal as a processing instruction name.
-
ProcessingInstruction
This will create a newProcessingInstruction
with the specified target and data.- Parameters:
target
-String
target of PI.data
-String
data for PI.- Throws:
IllegalTargetException
- if the given target is illegal as a processing instruction name.
-
-
Method Details
-
setTarget
This will set the target for the PI.- Parameters:
newTarget
-String
new target of PI.- Returns:
ProcessingInstruction
- this PI modified.
-
getValue
Returns the XPath 1.0 string value of this element, which is the data of this PI. -
getTarget
This will retrieve the target of the PI.- Returns:
String
- target of PI.
-
getData
This will return the raw data from all instructions.- Returns:
String
- data of PI.
-
getPseudoAttributeNames
This will return aList
containing the names of the "attribute" style pieces of name/value pairs in this PI's data.- Returns:
List
- theList
containing the "attribute" names.
-
setData
This will set the raw data for the PI.- Parameters:
data
-String
data of PI.- Returns:
ProcessingInstruction
- this PI modified.
-
setData
This will set the name/value pairs within the passedMap
as 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
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
-String
name of name/value pair to lookup value for.- Returns:
String
- value of name/value pair.
-
setPseudoAttribute
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
-String
name of pair.value
-String
value for pair.- Returns:
ProcessingInstruction
this PI modified.
-
removePseudoAttribute
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
This returns aString
representation of theProcessingInstruction
, suitable for debugging. If the XML representation of theProcessingInstruction
is desired,XMLOutputter.outputString(ProcessingInstruction)
should be used. -
clone
Return a deep clone of this instance. Even if this instance has a parent, the returned clone will not.All JDOM core classes are Cloneable, and never throw CloneNotSupportedException. Additionally all Cloneable JDOM classes return the correct type of instance from this method and there is no need to cast the result (co-variant return value).
Subclasses of this should still call super.clone() in their clone method.
-
detach
Description copied from class:Content
Detaches this child from its parent or does nothing if the child has no parent.This method can be overridden by particular Content subclasses to return a specific type of Content (co-variant return type). All overriding subclasses must call
super.detach()
; -
setParent
Description copied from class:Content
Sets the parent of this Content. The caller is responsible for removing any pre-existing parentage.This method can be overridden by particular Content subclasses to return a specific type of Content (co-variant return type). All overriding subclasses must call
super.setParent(Parent)
;
-