Top Description Fields Constructors Methods
org.jdom

public Class ProcessingInstruction

extends Content
Class Inheritance
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
Version
$Revision: 1.47 $, $Date: 2007/11/10 05:28:59 $

Field Summary

Modifier and TypeField and Description
private static final String
protected Map<K, V>
mapData

The data for the PI in name/value pairs

protected String
rawData

The data for the PI as a String

protected String
target

The target of the PI

Inherited from org.jdom.Content:
parent

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
,
Map<K, V>
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 Object

Returns:

Object - clone of this ProcessingInstruction.
clone
()

Overrides org.jdom.Content.clone.

This will return a clone of this ProcessingInstruction.
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<E>

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.jdom.Content.getValue.

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

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<K, V>
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.

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 String

Returns:

a string representation of the Map as appropriate for a PI
toString
(Map<K, V>
Map PI data to convert
mapData
)

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.jdom.Content:
detachequalsgetDocumentgetParentgetParentElementhashCodesetParent

Field Detail

CVS_IDback to summary
private static final String CVS_ID
mapDataback to summary
protected Map<K, V> mapData

The data for the PI in name/value pairs

rawDataback to summary
protected String rawData

The data for the PI as a String

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, Map<K, V> data)

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

Parameters
target:String

String target of PI.

data:Map<K, V>

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 Object clone()

Overrides org.jdom.Content.clone.

This will return a clone of this ProcessingInstruction.

Returns:Object

Object - clone of this ProcessingInstruction.

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<E> 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<E>

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.jdom.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

parseDataback to summary
private Map<K, V> parseData(String rawData)

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<K, V> 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<K, V>

new map data to use

Returns:ProcessingInstruction

ProcessingInstruction - modified PI.

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 String toString(Map<K, V> mapData)

This will convert the Map to a string representation.

Parameters
mapData:Map<K, V>

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.jdom.output.XMLOutputter#outputString(ProcessingInstruction) should be used.

Returns:String

String - information about the ProcessingInstruction