public class RAPPElement extends Object
Element
.
It provides simple set/get methods for the basic attribute types such an Element can have.
This class should be used to create and manipulate the
document structure instead of directly using Element
,
Node
and Document
. This is due to
the Namespace usage in the XML document and also future
XML schema implementation in the RAPP API.
Constructor and Description |
---|
RAPPElement(Element element,
RAPPNameSpaceItem nsItem)
Creates the RAPPElement from an existing Element.
|
Modifier and Type | Method and Description |
---|---|
void |
appendChild(Node node)
Appends a child node to this element.
|
RAPPElement |
createAppendedChild(String name)
Creates a new instance of the RAPPElement that is
already added to this instance Element as a child.
|
RAPPElement |
createAppendedChild(String name,
RAPPNameSpaceItem item)
Creates a new instance of the RAPPElement that is
already added to this instance Element as a child.
|
Element |
createElement(Document document,
String name)
Creates the element in the specified document with the
specified name.
|
String |
getAttribute(String name)
Gets a String attribute for an element.
|
String |
getAttribute(String name,
String defaultValue)
Gets a String attribute for an element.
|
boolean |
getBooleanAttribute(String name)
Gets a boolean value for an attribute of an element.
|
boolean |
getBooleanAttribute(String name,
boolean defaultValue)
Gets a boolean value for an attribute of an element.
|
Document |
getDocument()
Gets the document for the action, null if no document is
being created or this class instance (or extending classes)
is creating the document.
|
Element |
getElement()
Gets the element for the action, null if no document is
being created or this class instance (or extending classes)
is creating the document.
|
static String |
getElementString(Element e)
Returns a string for an Element.
|
Element |
getFirstChildElement()
Gets the first child element.
|
static Element |
getFirstChildElement(Element element)
Gets the first child element.
|
static Element |
getFirstChildElement(Element element,
String tagName,
RAPPNameSpaceItem nsItem)
Gets the first child element with the specified tag name and namespace.
|
Element |
getFirstChildElement(String tagName)
Gets the first child element with the specified tag name.
|
int |
getIntegerAttribute(String name)
Gets an integer value for an attribute of an element.
|
int |
getIntegerAttribute(String name,
int defaultValue)
Gets an integer value for an attribute of an element.
|
RAPPNameSpaceItem |
getNameSpaceItem()
Get namespace item or null if not initiated.
|
Element |
getNextSiblingElement()
Gets the next sibling element with the specified tag name.
|
static Element |
getNextSiblingElement(Element element)
Gets the next sibling element.
|
static Element |
getNextSiblingElement(Element element,
String tagName,
RAPPNameSpaceItem nsItem)
Gets the next sibling element with the specified tag name and namespace.
|
Element |
getNextSiblingElement(String tagName)
Gets the next sibling element with the specified tag name.
|
static String |
getNodeAttributesString(Node n)
Returns a string with all attributes of a node.
|
Element |
getParentElement()
Gets the parent Element.
|
int |
getStarAttribute(String name)
Gets a positive integer value for an attribute of an element
that can contain the value "*" (-2).
|
boolean |
hasAttribute(String name)
Checks if an attribute for the element exists.
|
void |
removeAttribute(String name)
Removes an attribute from the element.
|
void |
removeChild(Node node)
Removes the child node from this element.
|
void |
removeChild(RAPPElement child)
Removes the child node from this element.
|
void |
setAttribute(String name,
boolean value)
Sets the boolean value as an attribute ("true" or "false").
|
void |
setAttribute(String name,
int value)
Sets the integer value as an attribute for the action element.
|
void |
setAttribute(String name,
String value)
Sets the string value as an attribute for the action element.
|
void |
setStarAttribute(String name,
int value)
Sets the "star" integer value as an attribute for the action
element.
|
String |
toString()
Converts this class into a string for testing purposes.
|
public RAPPElement(Element element, RAPPNameSpaceItem nsItem)
public static Element getFirstChildElement(Element element)
public static Element getNextSiblingElement(Element element)
public static Element getFirstChildElement(Element element, String tagName, RAPPNameSpaceItem nsItem)
public static Element getNextSiblingElement(Element element, String tagName, RAPPNameSpaceItem nsItem)
public Element createElement(Document document, String name)
public RAPPElement createAppendedChild(String name)
public RAPPElement createAppendedChild(String name, RAPPNameSpaceItem item)
public void appendChild(Node node)
public void removeChild(Node node)
public void removeChild(RAPPElement child)
public RAPPNameSpaceItem getNameSpaceItem()
public Document getDocument()
public Element getElement()
public Element getParentElement()
public Element getFirstChildElement()
public Element getFirstChildElement(String tagName)
public Element getNextSiblingElement()
public Element getNextSiblingElement(String tagName)
public String getAttribute(String name) throws SAXException
SAXException
- if the attribute is not found.public String getAttribute(String name, String defaultValue)
public int getIntegerAttribute(String name) throws SAXException
SAXException
- if the attribute is not found.public int getIntegerAttribute(String name, int defaultValue)
public int getStarAttribute(String name) throws SAXException
If the attribute is not present or the value is not found, -1 is returned.
If the attribute is the special value "*", -2 is returned.
If the value is negative or invalid, a SAXException is trown.
SAXException
- if the attribute is not found.public boolean getBooleanAttribute(String name) throws SAXException
Valid boolean values are "true", "false", "1", "0" (case insensitive).
SAXException
- if the attribute is not found.public boolean getBooleanAttribute(String name, boolean defaultValue)
Valid boolean values are "true", "false", "1", "0" (case insensitive).
public void setAttribute(String name, String value)
public void setAttribute(String name, int value)
public void setStarAttribute(String name, int value)
public void setAttribute(String name, boolean value)
public boolean hasAttribute(String name)
public void removeAttribute(String name)
public String toString()
public static String getElementString(Element e)
Phantom® and NetPhantom® are registered trademarks of Mindus SARL.
© © Mindus SARL, 2024. All rights reserved.