jv.rsrc
Class PsXmlSrc
- java.lang.Object
-
- jv.rsrc.PsXmlSrc
-
- All Implemented Interfaces:
- java.io.Serializable
public class PsXmlSrc extends java.lang.Object implements java.io.SerializableResource tree generated from an XML file.- See Also:
- Serialized Form
- Author:
- Konrad Polthier
- Version:
- 20.02.00, 1.10 revised (kp) Extended from PsObject instead from Object.
04.02.00, 1.00 created (kp)
-
-
Constructor Summary
Constructors Constructor and Description PsXmlSrc()Constructor with no action.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static PsXmlNodeassureChild(PsXmlNode parent, java.lang.String type)Assure existence of a child node of given element type, and create it if necessary.java.lang.StringgetDocName()Get name of root element of associated DTD, or null.java.lang.StringgetDocType()Get url of associated DTD, or null.java.lang.StringgetParameter(java.lang.String name)Get a parameter given by hierarchical name.PsXmlNodegetRootNode()Get root node of resource tree.static java.lang.StringgetRsrc(PsXmlNode rsrcNode, java.lang.String type)Get content of node in resource tree with given element type by searching from given node.static booleangetRsrcAsBoolean(PsXmlNode rsrcNode, java.lang.String type)Get content of node in resource tree with given element type by searching from given node.static doublegetRsrcAsDouble(PsXmlNode rsrcNode, java.lang.String type)Get content of node in resource tree with given element type by searching from given node.static intgetRsrcAsInteger(PsXmlNode rsrcNode, java.lang.String type)Get content of node in resource tree with given element type by searching from given node.java.lang.StringgetRsrcFile()Get resource file name.static PsXmlNodegetRsrcNode(PsXmlNode rsrcNode, java.lang.String type)Get descendant node in resource tree with given element type.static PsXmlNode[]getRsrcNodes(PsXmlNode rsrcNode)Get children nodes of a given element.static PsXmlNode[]getRsrcNodes(PsXmlNode rsrcNode, java.lang.String type)Get nodes in resource tree with given element type by searching from given node.voidsetDocName(java.lang.String name)Set name of root element of associated DTD, or null.voidsetDocType(java.lang.String type)Set url of associated DTD, or null.voidsetRootNode(PsXmlNode root)Set root node of resource tree.voidsetRsrcFile(java.lang.String rsrcFile)Set name of resource name.static java.lang.Stringwrite(PsXmlSrc src)Writes an XML tree into a string.static booleanwrite(java.io.Writer writer, PsXmlSrc src)Writes an XML tree into a writer.
-
-
-
Method Detail
-
write
public static java.lang.String write(PsXmlSrc src)
Writes an XML tree into a string.- Parameters:
src- an XML source with XML tree- Returns:
- a string with formatted XML data
- Author:
- Konrad Polthier
- Version:
- 09.01.01, 2.10 revised (kp) Method move to PsXmlSrc from jv.loader.PsXmlLoader.
16.04.00, 1.10 revised (kp) Method argument changed to to PsXmlSrc.
05.02.00, 1.00 created (kp)
-
write
public static boolean write(java.io.Writer writer, PsXmlSrc src) throws java.io.IOExceptionWrites an XML tree into a writer.- Parameters:
writer- Write all data to this streamsrc- an XML source with XML tree- Returns:
trueon success.- Throws:
java.io.IOException- Author:
- Konrad Polthier
- Version:
- 18.02.01, 1.00 revised (kp)
18.02.01, 1.00 created (kp)
-
getParameter
public java.lang.String getParameter(java.lang.String name)
Get a parameter given by hierarchical name. For example, javaview/license/usage would be a valid hierarchical name. The first component need not be the root node of the JavaView XML resource but it must uniquely identify a node in the XML tree. The parameter may refer to an element or an element attribute. If it refers to an attribute then the element must be given.- Parameters:
name- (incomplete) hierarchical name of an element or attribute.- Returns:
- content resp. value of the requested element resp. attribute, or null.
-
getRsrcFile
public java.lang.String getRsrcFile()
Get resource file name. Only assigned if file has already been read or a file name has been given by explicit call ofsetRsrcFile(String).- Returns:
- name of a XML file
-
setRsrcFile
public void setRsrcFile(java.lang.String rsrcFile)
Set name of resource name.- Parameters:
rsrcFile- name of a XML file
-
getDocName
public java.lang.String getDocName()
Get name of root element of associated DTD, or null.
-
setDocName
public void setDocName(java.lang.String name)
Set name of root element of associated DTD, or null.
-
getDocType
public java.lang.String getDocType()
Get url of associated DTD, or null.
-
setDocType
public void setDocType(java.lang.String type)
Set url of associated DTD, or null.
-
getRootNode
public PsXmlNode getRootNode()
Get root node of resource tree.
-
setRootNode
public void setRootNode(PsXmlNode root)
Set root node of resource tree.- Parameters:
root- new root node
-
assureChild
public static PsXmlNode assureChild(PsXmlNode parent, java.lang.String type)
Assure existence of a child node of given element type, and create it if necessary.- Parameters:
parent- to be checked whether it has a decendent node of given element type.type- element type of node to be assured- Returns:
- argument node if it exists, else newly created instance.
-
getRsrcNode
public static PsXmlNode getRsrcNode(PsXmlNode rsrcNode, java.lang.String type)
Get descendant node in resource tree with given element type.- Parameters:
rsrcNode- node whose descendants are searched including itselftype- element type of node to be searched- Returns:
- node if found, else
null
-
getRsrcNodes
public static PsXmlNode[] getRsrcNodes(PsXmlNode rsrcNode, java.lang.String type)
Get nodes in resource tree with given element type by searching from given node.- Parameters:
rsrcNode- node whose descendants are searched including itselftype- element type of node to be searched- Returns:
- node array if found, else array of length 0.
-
getRsrcNodes
public static PsXmlNode[] getRsrcNodes(PsXmlNode rsrcNode)
Get children nodes of a given element.- Parameters:
rsrcNode- node whose descendants are searched including itself- Returns:
- node array if found, else array of length 0.
-
getRsrc
public static java.lang.String getRsrc(PsXmlNode rsrcNode, java.lang.String type)
Get content of node in resource tree with given element type by searching from given node.- Parameters:
rsrcNode- node whose descendants are searched including itselftype- element type of node to be searched- Returns:
- content of resource if resource is found, else
null.
-
getRsrcAsDouble
public static double getRsrcAsDouble(PsXmlNode rsrcNode, java.lang.String type)
Get content of node in resource tree with given element type by searching from given node. Method assumes that content is formated as double and does some checking.- Parameters:
rsrcNode- node whose descendants are searched including itselftype- element type of node to be searched- Returns:
- content of resource if resource is found, else default value 0.
-
getRsrcAsInteger
public static int getRsrcAsInteger(PsXmlNode rsrcNode, java.lang.String type)
Get content of node in resource tree with given element type by searching from given node. Method assumes that content is formated as double and does some checking.- Parameters:
rsrcNode- node whose descendants are searched including itselftype- element type of node to be searched- Returns:
- content of resource if resource is found, else default value 0.
-
getRsrcAsBoolean
public static boolean getRsrcAsBoolean(PsXmlNode rsrcNode, java.lang.String type)
Get content of node in resource tree with given element type by searching from given node. Method assumes that content is formated as double and does some checking.- Parameters:
rsrcNode- node whose descendants are searched including itselftype- element type of node to be searched- Returns:
- content of resource if resource is found, else default value
false.
-
-
"