public class PsXmlNode
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
PsXmlNode(java.lang.String type)
Create a new node with given elmenent type.
|
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(java.lang.String key,
java.lang.String value)
Add an attribute with given key and value to this node.
|
PsXmlNode |
addChild(PsXmlNode child) |
PsXmlNode |
addChild(java.lang.String type) |
PsXmlNode |
addChild(java.lang.String type,
boolean content) |
PsXmlNode |
addChild(java.lang.String type,
double content) |
PsXmlNode |
addChild(java.lang.String type,
float content) |
PsXmlNode |
addChild(java.lang.String type,
int content) |
PsXmlNode |
addChild(java.lang.String type,
java.lang.String content) |
void |
addMixedContent(java.lang.Object obj)
Add an item to the mixed mode vector.
|
void |
appendContent(java.lang.String content) |
boolean |
contentEndsWith(char c)
Check if current content ends with the given string.
|
void |
expand(boolean flag)
Deprecated.
use #setExpanded(boolean).
|
java.lang.String |
getAttribute(java.lang.String key) |
java.util.Hashtable |
getAttributes() |
PsXmlNode |
getChild() |
PsXmlNode |
getChild(java.lang.String type)
Find child with given element type.
|
PsXmlNode[] |
getChildren()
Get all children in given order.
|
PsXmlNode[] |
getChildren(java.lang.String type)
Get children in given order of specified element type.
|
java.lang.String |
getContent() |
PsXmlNode |
getFather() |
java.util.Enumeration |
getMixedContent()
Get content of mixed mode vector.
|
int |
getNumChildren() |
PsXmlNode |
getSibling() |
java.lang.String |
getType()
Get name of xml type identifying the element.
|
boolean |
hasChild(java.lang.String type)
Check whether this node has a direct child with given element type.
|
boolean |
hasContent() |
boolean |
isExpanded() |
boolean |
isMixedMode()
Determine whether node is in mixed mode.
|
void |
removeAttribute(java.lang.String key) |
boolean |
removeChild(java.lang.String type)
Remove a direct child with given element type.
|
void |
removeChildren() |
void |
setChild(PsXmlNode child) |
void |
setContent(java.lang.String content) |
void |
setExpanded(boolean flag) |
void |
setFather(PsXmlNode father) |
void |
setMixedMode(boolean flag)
Set flag that node is in mixed mode.
|
void |
setSibling(PsXmlNode sibling) |
void |
setType(java.lang.String type)
Set name of xml type identifying the element.
|
static java.lang.StringBuffer |
writeNode(java.lang.StringBuffer xml,
PsXmlNode node,
java.lang.String tab)
Writes an XML node including all children but the node's siblings into a string.
|
static boolean |
writeNode(java.io.Writer writer,
PsXmlNode node,
java.lang.String tab)
Writes an XML node including all children but the node's siblings into a writer.
|
public PsXmlNode(java.lang.String type)
type
- Name of XML elementpublic boolean isMixedMode()
public void setMixedMode(boolean flag)
public void addMixedContent(java.lang.Object obj)
public java.util.Enumeration getMixedContent()
public PsXmlNode[] getChildren()
public PsXmlNode[] getChildren(java.lang.String type)
type
- Name of elementpublic boolean hasChild(java.lang.String type)
getChild(String)
public boolean removeChild(java.lang.String type)
type
- element type of this nodetrue
if child was found and successfully removed.hasChild(String)
public PsXmlNode getChild(java.lang.String type)
hasChild(String)
public PsXmlNode addChild(java.lang.String type, java.lang.String content)
public PsXmlNode addChild(java.lang.String type, boolean content)
public PsXmlNode addChild(java.lang.String type, double content)
public PsXmlNode addChild(java.lang.String type, float content)
public PsXmlNode addChild(java.lang.String type, int content)
public PsXmlNode addChild(java.lang.String type)
public PsXmlNode getChild()
public void removeChildren()
public void setChild(PsXmlNode child)
public java.lang.String getType()
public void setType(java.lang.String type)
type
- name of elementpublic boolean isExpanded()
public void setExpanded(boolean flag)
public void expand(boolean flag)
public PsXmlNode getFather()
public void setFather(PsXmlNode father)
public PsXmlNode getSibling()
public void setSibling(PsXmlNode sibling)
public int getNumChildren()
public boolean contentEndsWith(char c)
public boolean hasContent()
public java.lang.String getContent()
public void setContent(java.lang.String content)
public void appendContent(java.lang.String content)
public void addAttribute(java.lang.String key, java.lang.String value)
public java.util.Hashtable getAttributes()
public java.lang.String getAttribute(java.lang.String key)
public void removeAttribute(java.lang.String key)
public static java.lang.StringBuffer writeNode(java.lang.StringBuffer xml, PsXmlNode node, java.lang.String tab)
Passing a null tab will avoid indentation.
xml
- string buffer to write into, if null then create a new StringBuffer.node
- node to save.tab
- indentation tab which is increased on children, maybe null string.public static boolean writeNode(java.io.Writer writer, PsXmlNode node, java.lang.String tab) throws java.io.IOException
Passing a null tab will avoid indentation.
writer
- Write all data to this streamnode
- node to save.tab
- indentation tab which is increased on children, maybe null string.true
on success.java.io.IOException
"