Module org.htmlunit

Class DomProcessingInstruction

java.lang.Object
org.htmlunit.html.DomNode
org.htmlunit.html.DomProcessingInstruction
All Implemented Interfaces:
Serializable, Cloneable, Node, ProcessingInstruction

public class DomProcessingInstruction extends DomNode implements ProcessingInstruction
Wrapper for the DOM node ProcessingInstruction.

Note: There is an architectural difference between the Java DOM layer and the JavaScript host layer: This Java class extends DomNode directly rather than a character data class, whereas the corresponding JavaScript host class inherits from CharacterData to match browser behavior.

Author:
Ahmed Ashour, Ronald Brill
See Also:
  • Constructor Details

    • DomProcessingInstruction

      public DomProcessingInstruction(SgmlPage page, String target, String data)
      Creates a new instance.
      Parameters:
      page - the Page that contains this element
      target - the target
      data - the data
  • Method Details

    • getNodeType

      public short getNodeType()
      Specified by:
      getNodeType in interface Node
      Returns:
      the node type constant, in this case Node.PROCESSING_INSTRUCTION_NODE
    • getNodeName

      public String getNodeName()
      Specified by:
      getNodeName in interface Node
    • getTarget

      public String getTarget()
      Specified by:
      getTarget in interface ProcessingInstruction
    • getData

      public String getData()
      Specified by:
      getData in interface ProcessingInstruction
    • setData

      public void setData(String data) throws DOMException
      Specified by:
      setData in interface ProcessingInstruction
      Throws:
      DOMException
    • getLength

      public int getLength()
      Returns the number of characters in the character data.
      Returns:
      the number of characters
    • appendData

      public void appendData(String newData)
      Appends a string to character data.
      Parameters:
      newData - the string to be appended to the character data
    • deleteData

      public void deleteData(int offset, int count)
      Deletes characters from character data.
      Parameters:
      offset - the position of the first character to be deleted (can't be less than zero)
      count - the number of characters to be deleted, if less than zero leaves the first offset chars
    • insertData

      public void insertData(int offset, String arg)
      Inserts a string into character data.
      Parameters:
      offset - the position within the first character at which the string is to be inserted
      arg - the string to insert
    • replaceData

      public void replaceData(int offset, int count, String arg)
      Replaces characters of character data with a string.
      Parameters:
      offset - the position within the first character at which the string is to be replaced
      count - the number of characters to be replaced
      arg - the string that replaces the count characters beginning at the character at offset
    • substringData

      public String substringData(int offset, int count)
      Extracts a substring from character data.
      Parameters:
      offset - the position of the first character to be extracted
      count - the number of characters to be extracted
      Returns:
      a string that consists of the count characters of the character data starting from the character at position offset
    • setNodeValue

      public void setNodeValue(String value)
      Specified by:
      setNodeValue in interface Node
    • getNodeValue

      public String getNodeValue()
      Specified by:
      getNodeValue in interface Node
      Overrides:
      getNodeValue in class DomNode
    • setTextContent

      public void setTextContent(String textContent)
      Specified by:
      setTextContent in interface Node
      Overrides:
      setTextContent in class DomNode
    • printXml

      protected boolean printXml(String indent, boolean indentBefore, PrintWriter printWriter)
      Recursively writes the XML data for the node tree starting at node.
      Overrides:
      printXml in class DomNode
      Parameters:
      indent - white space to indent child nodes
      indentBefore - if true start a new line before outputting
      printWriter - writer where child nodes are written
      Returns:
      true if the last thing printed was a tag
    • setPrefix

      public void setPrefix(String prefix)
      Specified by:
      setPrefix in interface Node