Top Description Fields Constructors Methods
org.jdom2

public Class ProcessingInstruction

extends Content
Class Inheritance
Known Direct Subclasses
org.jdom2.located.LocatedProcessingInstruction
Imports
java.util.*

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.
Authors
Brett McLaughlin, Jason Hunter, Steven Gould

Field Summary

Modifier and TypeField and Description
protected transient Map<String, String>
mapData

The data for the PI in name/value pairs

protected String
rawData

The data for the PI as a String

private static final long
protected String
target

The target of the PI

Inherited from org.jdom2.Content:
ctypeparent

Constructor Summary

AccessConstructor and Description
protected
ProcessingInstruction()

Default, no-args constructor for implementations to use if needed.

public
ProcessingInstruction(String
String target of PI.
target
)

This will create a new ProcessingInstruction with the specified target.

public
ProcessingInstruction(String
String target of PI.
target
,
Map<String, String>
Map data for PI, in name/value pairs
data
)

This will create a new ProcessingInstruction with the specified target and data.

public
ProcessingInstruction(String
String target of PI.
target
,
String
String data for PI.
data
)

This will create a new ProcessingInstruction with the specified target and data.

Method Summary

Modifier and TypeMethod and Description
public ProcessingInstruction
clone()

Overrides org.jdom2.Content.clone.

Return a deep clone of this instance.
public ProcessingInstruction
detach()

Overrides org.jdom2.Content.detach.

Detaches this child from its parent or does nothing if the child has no parent.
private static int[]

Returns:

the first quoted string encountered in the input data. If no quoted string is found, then the empty string, "", is returned.
extractQuotedString
(String
the input string from which a quoted string is to be extracted.
rawData
)

This is a helper routine, only used by parseData, to extract a quoted String from the input parameter, rawData.

public String

Returns:

String - data of PI.
getData
()

This will return the raw data from all instructions.

public List<String>

Returns:

List - the List containing the "attribute" names.
getPseudoAttributeNames
()

This will return a List containing the names of the "attribute" style pieces of name/value pairs in this PI's data.

public String

Returns:

String - value of name/value pair.
getPseudoAttributeValue
(String
String name of name/value pair to lookup value for.
name
)

This will return the value for a specific name/value pair on the PI.

public String

Returns:

String - target of PI.
getTarget
()

This will retrieve the target of the PI.

public String

Returns:

the data of this PI
getValue
()

Implements abstract org.jdom2.Content.getValue.

Returns the XPath 1.0 string value of this element, which is the data of this PI.
private Map<String, String>
parseData(String prawData)

This will parse and load the instructions for the PI.

public boolean

Returns:

boolean - whether the requested instruction was removed.
removePseudoAttribute
(String
name of pseudo attribute to remove
name
)

This will remove the pseudo attribute with the specified name.

public ProcessingInstruction

Returns:

ProcessingInstruction - this PI modified.
setData
(String
String data of PI.
data
)

This will set the raw data for the PI.

public ProcessingInstruction

Returns:

ProcessingInstruction - modified PI.
setData
(Map<String, String>
new map data to use
data
)

This will set the name/value pairs within the passed Map as the pairs for the data of this PI.

protected ProcessingInstruction
setParent(Parent
new parent element
parent
)

Overrides org.jdom2.Content.setParent.

Sets the parent of this Content.
public ProcessingInstruction

Returns:

ProcessingInstruction this PI modified.
setPseudoAttribute
(String
String name of pair.
name
,
String
String value for pair.
value
)

This will set a pseudo attribute with the given name and value.

public ProcessingInstruction

Returns:

ProcessingInstruction - this PI modified.
setTarget
(String
String new target of PI.
newTarget
)

This will set the target for the PI.

private static final String

Returns:

a string representation of the Map as appropriate for a PI
toString
(Map<String, String>
Map PI data to convert
pmapData
)

This will convert the Map to a string representation.

public String

Returns:

String - information about the ProcessingInstruction
toString
()

Overrides java.lang.Object.toString.

This returns a String representation of the ProcessingInstruction, suitable for debugging.
Inherited from org.jdom2.Content:
equalsgetCTypegetDocumentgetNamespacesInheritedgetNamespacesInScopegetNamespacesIntroducedgetParentgetParentElementhashCode

Field Detail

mapDataback to summary
protected transient Map<String, String> mapData

The data for the PI in name/value pairs

rawDataback to summary
protected String rawData

The data for the PI as a String

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.jdom2.Content.serialVersionUID.

JDOM2 Serialization. In this case, ProcessingInstruction is simple.

targetback to summary
protected String target

The target of the PI

Constructor Detail

ProcessingInstructionback to summary
protected ProcessingInstruction()

Default, no-args constructor for implementations to use if needed.

ProcessingInstructionback to summary
public ProcessingInstruction(String target)

This will create a new ProcessingInstruction with the specified target.

Parameters
target:String

String target of PI.

Exceptions
IllegalTargetException:
if the given target is illegal as a processing instruction name.
ProcessingInstructionback to summary
public ProcessingInstruction(String target, Map<String, String> data)

This will create a new ProcessingInstruction with the specified target and data.

Parameters
target:String

String target of PI.

data:Map<String, String>

Map data for PI, in name/value pairs

Exceptions
IllegalTargetException:
if the given target is illegal as a processing instruction name.
ProcessingInstructionback to summary
public ProcessingInstruction(String target, String data)

This will create a new ProcessingInstruction with the specified target and data.

Parameters
target:String

String target of PI.

data:String

String data for PI.

Exceptions
IllegalTargetException:
if the given target is illegal as a processing instruction name.

Method Detail

cloneback to summary
public ProcessingInstruction clone()

Overrides org.jdom2.Content.clone.

Doc from org.jdom2.CloneBase.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.

Returns:ProcessingInstruction

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
detachback to summary
public ProcessingInstruction detach()

Overrides org.jdom2.Content.detach.

Doc from org.jdom2.Content.detach.

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();

Returns:ProcessingInstruction

this child detached

Annotations
@Override
extractQuotedStringback to summary
private static int[] extractQuotedString(String rawData)

This is a helper routine, only used by parseData, to extract a quoted String from the input parameter, rawData. A quoted string can use either single or double quotes, but they must match up. A singly quoted string can contain an unbalanced amount of double quotes, or vice versa. For example, the String "JDOM's the best" is legal as is 'JDOM"s the best'.

Parameters
rawData:String

the input string from which a quoted string is to be extracted.

Returns:int[]

the first quoted string encountered in the input data. If no quoted string is found, then the empty string, "", is returned.

See Also
parseData
getDataback to summary
public String getData()

This will return the raw data from all instructions.

Returns:String

String - data of PI.

getPseudoAttributeNamesback to summary
public List<String> getPseudoAttributeNames()

This will return a List containing the names of the "attribute" style pieces of name/value pairs in this PI's data.

Returns:List<String>

List - the List containing the "attribute" names.

getPseudoAttributeValueback to summary
public String getPseudoAttributeValue(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:String

String name of name/value pair to lookup value for.

Returns:String

String - value of name/value pair.

getTargetback to summary
public String getTarget()

This will retrieve the target of the PI.

Returns:String

String - target of PI.

getValueback to summary
public String getValue()

Implements abstract org.jdom2.Content.getValue.

Returns the XPath 1.0 string value of this element, which is the data of this PI.

Returns:String

the data of this PI

Annotations
@Override
parseDataback to summary
private Map<String, String> parseData(String prawData)

This will parse and load the instructions for the PI. This is separated to allow it to occur once and then be reused.

removePseudoAttributeback to summary
public boolean removePseudoAttribute(String name)

This will remove the pseudo attribute with the specified name.

Parameters
name:String

name of pseudo attribute to remove

Returns:boolean

boolean - whether the requested instruction was removed.

setDataback to summary
public ProcessingInstruction setData(String data)

This will set the raw data for the PI.

Parameters
data:String

String data of PI.

Returns:ProcessingInstruction

ProcessingInstruction - this PI modified.

setDataback to summary
public ProcessingInstruction setData(Map<String, String> data)

This will set the name/value pairs within the passed Map 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:Map<String, String>

new map data to use

Returns:ProcessingInstruction

ProcessingInstruction - modified PI.

setParentback to summary
protected ProcessingInstruction setParent(Parent parent)

Overrides org.jdom2.Content.setParent.

Doc from org.jdom2.Content.setParent.

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);

Parameters
parent:Parent

new parent element

Returns:ProcessingInstruction

the target element

Annotations
@Override
setPseudoAttributeback to summary
public ProcessingInstruction setPseudoAttribute(String name, 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:String

String name of pair.

value:String

String value for pair.

Returns:ProcessingInstruction

ProcessingInstruction this PI modified.

setTargetback to summary
public ProcessingInstruction setTarget(String newTarget)

This will set the target for the PI.

Parameters
newTarget:String

String new target of PI.

Returns:ProcessingInstruction

ProcessingInstruction - this PI modified.

toStringback to summary
private static final String toString(Map<String, String> pmapData)

This will convert the Map to a string representation.

Parameters
pmapData:Map<String, String>

Map PI data to convert

Returns:String

a string representation of the Map as appropriate for a PI

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

This returns a String representation of the ProcessingInstruction, suitable for debugging. If the XML representation of the ProcessingInstruction is desired, org.jdom2.output.XMLOutputter#outputString(ProcessingInstruction) should be used.

Returns:String

String - information about the ProcessingInstruction

Annotations
@Override