Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.jdom
Class ProcessingInstruction  view ProcessingInstruction download ProcessingInstruction.java

java.lang.Object
  extended byorg.jdom.Content
      extended byorg.jdom.ProcessingInstruction
All Implemented Interfaces:
java.lang.Cloneable, java.io.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.

Version:
$Revision: 1.46 $, $Date: 2004/02/27 11:32:57 $

Field Summary
private static java.lang.String CVS_ID
           
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
 
Fields inherited from class org.jdom.Content
parent
 
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.
private static int[] extractQuotedString(java.lang.String rawData)
          This is a helper routine, only used by parseData, to extract a quoted String from the input parameter, rawData.
 java.lang.String getData()
          This will return the raw data from all instructions.
 java.util.List getPseudoAttributeNames()
          This will return a List containing the names of the "attribute" style pieces of name/value pairs in this PI's data.
 java.lang.String getPseudoAttributeValue(java.lang.String name)
          This will return the value for a specific name/value pair on the PI.
 java.lang.String getTarget()
          This will retrieve the target of the PI.
 java.lang.String getValue()
          Returns the XPath 1.0 string value of this element, which is the data of this PI.
private  java.util.Map parseData(java.lang.String rawData)
          This will parse and load the instructions for the PI.
 boolean removePseudoAttribute(java.lang.String name)
          This will remove the pseudo attribute 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 setPseudoAttribute(java.lang.String name, java.lang.String value)
          This will set a pseudo attribute with the given name and value.
 ProcessingInstruction setTarget(java.lang.String newTarget)
          This will set the target for the PI.
 java.lang.String toString()
          This returns a String representation of the ProcessingInstruction, suitable for debugging.
private  java.lang.String toString(java.util.Map mapData)
          This will convert the Map to a string representation.
 
Methods inherited from class org.jdom.Content
detach, equals, getDocument, getParent, getParentElement, hashCode, setParent
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CVS_ID

private static final java.lang.String CVS_ID
See Also:
Constant Field Values

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.


ProcessingInstruction

public ProcessingInstruction(java.lang.String target,
                             java.lang.String data)
This will create a new ProcessingInstruction with the specified target and data.

Method Detail

setTarget

public ProcessingInstruction setTarget(java.lang.String newTarget)
This will set the target for the PI.


getValue

public java.lang.String getValue()
Returns the XPath 1.0 string value of this element, which is the data of this PI.

Specified by:
getValue in class Content

getTarget

public java.lang.String getTarget()
This will retrieve the target of the PI.


getData

public java.lang.String getData()
This will return the raw data from all instructions.


getPseudoAttributeNames

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


setData

public ProcessingInstruction setData(java.lang.String data)
This will set the raw data for the PI.


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.


getPseudoAttributeValue

public java.lang.String getPseudoAttributeValue(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, null is returned.


setPseudoAttribute

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


removePseudoAttribute

public boolean removePseudoAttribute(java.lang.String name)
This will remove the pseudo attribute with the specified name.


toString

private java.lang.String toString(java.util.Map mapData)
This will convert the Map to a string representation.


parseData

private java.util.Map parseData(java.lang.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.


extractQuotedString

private static int[] extractQuotedString(java.lang.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'.


toString

public java.lang.String 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.


clone

public java.lang.Object clone()
This will return a clone of this ProcessingInstruction.

Overrides:
clone in class Content