org.jdom
Class ProcessingInstruction


public class ProcessingInstruction
implements Cloneable, Serializable

ProcessingInstruction defines behavior for an XML processing instruction, modeled in Java. 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, and where appropriate can be retrieved as name/value pairs.

Author:
Brett McLaughlin, Jason Hunter
Version: 1.0

Constructor Summary
ProcessingInstruction(String target, Map data)
           This will create a new ProcessingInstruction with the specified target and data.
ProcessingInstruction(String target, String data)
           This will create a new ProcessingInstruction with the specified target and data.

Method Summary
 Objectclone()
           This will return a clone of this ProcessingInstruction.
 final booleanequals(Object ob)
           This tests for equality of this ProcessingInstruction to the supplied Object.
 StringgetData()
           This will return the raw data from all instructions.
 DocumentgetDocument()
           This retrieves the owning Document for this PI, or null if not a currently a member of a Document.
 ElementgetParent()
           This will return the parent of this ProcessingInstruction.
 final StringgetSerializedForm()
           This will return the Comment in XML format, usable in an XML document.
 StringgetTarget()
           This will retrieve the target of the PI.
 StringgetValue(String name)
           This will return the value for a specific name/value pair on the PI.
 final inthashCode()
           This returns the hash code for this ProcessingInstruction.
 booleanremoveValue(String name)
           This will remove the name/value pair with the specified name.
 ProcessingInstructionsetData(String data)
           This will set the raw data for the PI.
 ProcessingInstructionsetData(Map data)
           This will set the name/value pairs within the passed Map as the pairs for the data of this PI.
 ProcessingInstructionsetValue(String name, String value)
           This will set the value for the specified name/value pair.
 StringtoString()
           This returns a String representation of the ProcessingInstruction, suitable for debugging.

Constructor Detail

ProcessingInstruction

public ProcessingInstruction(String target, Map data)

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

Parameters:
target - String target of PI.
data - Map data for PI, in name/value pairs

ProcessingInstruction

public ProcessingInstruction(String target, String data)

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

Parameters:
target - String target of PI.
rawData - String data for PI.
Method Detail

clone

public Object clone()

This will return a clone of this ProcessingInstruction.

Returns: Object - clone of this ProcessingInstruction.

equals

public final boolean equals(Object ob)

This tests for equality of this ProcessingInstruction to the supplied Object.

Parameters:
ob - Object to compare to.
Returns: boolean - whether the ProcessingInstruction is equal to the supplied Object.

getData

public String getData()

This will return the raw data from all instructions.

Returns: String - data of PI.

getDocument

public Document getDocument()

This retrieves the owning Document for this PI, or null if not a currently a member of a Document.

Returns: Document owning this PI, or null.

getParent

public Element getParent()

This will return the parent of this ProcessingInstruction. If there is no parent, then this returns null.

Returns: parent of this ProcessingInstruction

getSerializedForm

public final String getSerializedForm()

This will return the Comment in XML format, usable in an XML document.

Returns: String - the serialized form of the Comment.

getTarget

public String getTarget()

This will retrieve the target of the PI.

Returns: String - target of PI.

getValue

public String getValue(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, an empty String will result.

Parameters:
name - String name of name/value pair to lookup value for.
Returns: String - value of name/value pair.

hashCode

public final int hashCode()

This returns the hash code for this ProcessingInstruction.

Returns: int - hash code.

removeValue

public boolean removeValue(String name)

This will remove the name/value pair with the specified name.

Returns: boolean - whether the requested instruction was removed.

setData

public ProcessingInstruction setData(String data)

This will set the raw data for the PI.

Parameters:
rawData - String data of PI.
Returns: ProcessingInstruction - this PI modified.

setData

public ProcessingInstruction setData(Map 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.

Returns: ProcessingInstruction - modified PI.

setValue

public ProcessingInstruction setValue(String name, String value)

This will set the value for the specified name/value pair. If no matching pair is found, the supplied pair is added to the PI data.

Parameters:
name - String name of pair.
value - String value for pair.
Returns: ProcessingInstruction this PI modified.

toString

public String toString()

This returns a String representation of the ProcessingInstruction, suitable for debugging. If the XML representation of the ProcessingInstruction is desired, getSerializedForm() should be used.

Returns: String - information about the ProcessingInstruction

Association Links

to Class java.lang.String

The target of the PI

to Class java.lang.String

The data for the PI as a String

to Class java.util.Map

The data for the PI in name/value pairs

to Class org.jdom.Element

Parent element, or null if none

to Class org.jdom.Document

Document node if PI is outside the root element, or null if none