org.jdom

Class ProcessingInstruction

Implemented Interfaces:
Cloneable, Serializable

public class ProcessingInstruction
extends Content

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.
See Also:
Serialized Form

Field Summary

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

Fields inherited from class org.jdom.Content

parent

Constructor Summary

ProcessingInstruction()
Default, no-args constructor for implementations to use if needed.
ProcessingInstruction(String target, String data)
This will create a new ProcessingInstruction with the specified target and data.
ProcessingInstruction(String target, Map<K,V> data)
This will create a new ProcessingInstruction with the specified target and data.

Method Summary

Object
clone()
This will return a clone of this ProcessingInstruction.
String
getData()
This will return the raw data from all instructions.
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.
String
getPseudoAttributeValue(String name)
This will return the value for a specific name/value pair on the PI.
String
getTarget()
This will retrieve the target of the PI.
String
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.
ProcessingInstruction
setData(String data)
This will set the raw data for the PI.
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.
ProcessingInstruction
setPseudoAttribute(String name, String value)
This will set a pseudo attribute with the given name and value.
ProcessingInstruction
setTarget(String newTarget)
This will set the target for the PI.
String
toString()
This returns a String representation of the ProcessingInstruction, suitable for debugging.

Methods inherited from class org.jdom.Content

clone, detach, equals, getDocument, getParent, getParentElement, getValue, hashCode, setParent

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

mapData

protected Map<K,V> mapData
The data for the PI in name/value pairs

rawData

protected String rawData
The data for the PI as a String

target

protected String target
The target of the PI

Constructor Details

ProcessingInstruction

protected ProcessingInstruction()
Default, no-args constructor for implementations to use if needed.

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.
data - String data for PI.
Throws:
IllegalTargetException - if the given target is illegal as a processing instruction name.
Usages and Demos :

View More Examples of ProcessingInstruction(String target,String data)
   1:     {
   2:         addElement( new ProcessingInstruction(Result.PI_DISABLE_OUTPUT_ESCAPING, "") );
   3:     }
   4:     
   5:     private Element handleHyperlinks( String link, int pos )

View Full Code Here

ProcessingInstruction

public ProcessingInstruction(String target,
                             Map<K,V> 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
Throws:
IllegalTargetException - if the given target is illegal as a processing instruction name.
Usages and Demos :

View More Examples of ProcessingInstruction(String target,Map data)
   1:     {
   2:         addElement( new ProcessingInstruction(Result.PI_DISABLE_OUTPUT_ESCAPING, "") );
   3:     }
   4:     
   5:     private Element handleHyperlinks( String link, int pos )

View Full Code Here

Method Details

clone

public Object clone()
This will return a clone of this ProcessingInstruction.
Overrides:
clone in interface Content
Returns:
Object - clone of this ProcessingInstruction.

getData

public String getData()
This will return the raw data from all instructions.
Returns:
String - data of PI.
Usages and Demos :

View More Examples of getData()
   1: import org.jdom.Namespace;
   2: import org.jdom.ProcessingInstruction;
   3: 
   4:         ...
   5:             }
   6:             else if (x instanceof ProcessingInstruction) {
   7:                 content.remove(i);
   8:         ...
   9:                 content.add(i, wrapPI((ProcessingInstruction)x));
  10:             }
  11:         ...
  12:         pi.setAttribute("Target", procInst.getTarget());
  13:         pi.setAttribute("Data", procInst.getData());

View Full Code Here

getPseudoAttributeNames

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 - the List containing the "attribute" names.

getPseudoAttributeValue

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 name of name/value pair to lookup value for.
Returns:
String - value of name/value pair.

getTarget

public String getTarget()
This will retrieve the target of the PI.
Returns:
String - target of PI.
Usages and Demos :

View More Examples of getTarget()
   1: import org.jdom.Namespace;
   2: import org.jdom.ProcessingInstruction;
   3: 
   4:         ...
   5:             }
   6:             else if (x instanceof ProcessingInstruction) {
   7:                 content.remove(i);
   8:         ...
   9:                 content.add(i, wrapPI((ProcessingInstruction)x));
  10:             }
  11:         ...
  12:         Element pi = new Element("ProcessingInstruction");
  13:         pi.setAttribute("Target", procInst.getTarget());

View Full Code Here
   1: import org.jdom.Namespace;
   2: import org.jdom.ProcessingInstruction;
   3: import org.jdom.Text;
   4:         ...
   5:     
   6:         public static boolean equivalent(ProcessingInstruction p1,
   7:         ...
   8:                                   ProcessingInstruction p2) {
   9:         ...
  10:             String t1 = p1.getTarget();

View Full Code Here

getValue

public String getValue()
Returns the XPath 1.0 string value of this element, which is the data of this PI.
Overrides:
getValue in interface Content
Returns:
the data of this PI

removePseudoAttribute

public boolean removePseudoAttribute(String name)
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.

setData

public ProcessingInstruction setData(String data)
This will set the raw data for the PI.
Parameters:
data - String data of PI.
Returns:
ProcessingInstruction - this PI modified.

setData

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 - new map data to use
Returns:
ProcessingInstruction - modified PI.

setPseudoAttribute

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 name of pair.
value - String value for pair.
Returns:
ProcessingInstruction this PI modified.

setTarget

public ProcessingInstruction setTarget(String newTarget)
This will set the target for the PI.
Parameters:
newTarget - String new target of PI.
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, XMLOutputter.outputString(ProcessingInstruction) should be used.
Overrides:
toString in interface Object
Returns:
String - information about the ProcessingInstruction