org.jdom
Class ProcessingInstruction

java.lang.Object
  |
  +--org.jdom.ProcessingInstruction

public class ProcessingInstruction
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

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.

Version:
1.0
Author:
Brett McLaughlin, Jason Hunter
See Also:
Serialized Form

Field Summary
protected  java.util.Map mapData
          The data for the PI in name/value pairs
protected  java.lang.String rawData
          The data for the PI as a String
protected  java.lang.String target
          The target of the PI
 
Constructor Summary
protected ProcessingInstruction()
           Default, no-args constructor for implementations to use if needed.
  ProcessingInstruction(java.lang.String target, java.util.Map data)
           This will create a new ProcessingInstruction with the specified target and data.
  ProcessingInstruction(java.lang.String target, java.lang.String data)
           This will create a new ProcessingInstruction with the specified target and data.
 
Method Summary
 java.lang.Object clone()
           This will return a clone of this ProcessingInstruction.
 boolean equals(java.lang.Object ob)
           This tests for equality of this ProcessingInstruction to the supplied Object.
 java.lang.String getData()
           This will return the raw data from all instructions.
 java.lang.String getSerializedForm()
           This will return the Comment in XML format, usable in an XML document.
 java.lang.String getTarget()
           This will retrieve the target of the PI.
 java.lang.String getValue(java.lang.String name)
           This will return the value for a specific name/value pair on the PI.
 int hashCode()
           This returns the hash code for this ProcessingInstruction.
 boolean removeValue(java.lang.String name)
           This will remove the name/value pair with the specified name.
 ProcessingInstruction setData(java.util.Map data)
           This will set the name/value pairs within the passed Map as the pairs for the data of this PI.
 ProcessingInstruction setData(java.lang.String data)
           This will set the raw data for the PI.
 ProcessingInstruction setValue(java.lang.String name, java.lang.String value)
           This will set the value for the specified name/value pair.
 java.lang.String toString()
           This returns a String representation of the ProcessingInstruction, suitable for debugging.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

target

protected java.lang.String target
The target of the PI

rawData

protected java.lang.String rawData
The data for the PI as a String

mapData

protected java.util.Map mapData
The data for the PI in name/value pairs
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 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(java.lang.String target,
                             java.lang.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

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.

setData

public ProcessingInstruction setData(java.lang.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(java.util.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.

getValue

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

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

setValue

public ProcessingInstruction setValue(java.lang.String name,
                                      java.lang.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.

removeValue

public boolean removeValue(java.lang.String name)

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

Returns:
boolean - whether the requested instruction was removed.

toString

public final java.lang.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
Overrides:
toString in class java.lang.Object

getSerializedForm

public final java.lang.String getSerializedForm()

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

Returns:
String - the serialized form of the Comment.

equals

public final boolean equals(java.lang.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.
Overrides:
equals in class java.lang.Object

hashCode

public final int hashCode()

This returns the hash code for this ProcessingInstruction.

Returns:
int - hash code.
Overrides:
hashCode in class java.lang.Object

clone

public final java.lang.Object clone()

This will return a clone of this ProcessingInstruction.

Returns:
Object - clone of this ProcessingInstruction.
Overrides:
clone in class java.lang.Object


Copyright © 2000 Brett McLaughlin, Jason Hunter. All Rights Reserved.