|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object issrg.pba.rbac.xmlpolicy.PolicyXMLNode
public class PolicyXMLNode
This is the class that represents the node of the XML Policy. Its subclasses are used when parsing the Policy.
As the XMLPolicyParser has been written in 2000, the DOM3 classes were not readily available with Java, so we went for a lightweight parser, SAX parser. XMLPolicyParser is an extension of SAXParser, which builds a tree of PolicyXMLNodes, similar to the trees of Nodes, built by modern DOM3 parsers. XMLPolicyParser keeps a register of classes corresponding to each XML tag, so when such tag is encountered in XML, a respective class is instantiated. It is assumed that each class extends PolicyXMLNode.
Field Summary | |
---|---|
protected java.util.Map |
attributes
This is the Map of element attributes by their names; each element is a String. |
protected java.util.Vector |
children
This is a collection of the element children nodes; each element is of the PolicyXMLNode class. |
protected java.lang.String |
name
The name of the node. |
protected java.lang.String |
nodeStr
This is the string associated with the node. |
Constructor Summary | |
---|---|
protected |
PolicyXMLNode()
This constructor builds a PolicyXMLNode with no name and no attributes. |
protected |
PolicyXMLNode(java.lang.String nodeName)
This constructor builds a node with a given name, but no attributes. |
|
PolicyXMLNode(java.lang.String nodeName,
org.xml.sax.Attributes attr)
This constructor builds a node with the given name and a set of attributes. |
|
PolicyXMLNode(java.lang.String nodeName,
java.util.Map attrs)
This constructor builds a node with the given name and a set of attributes, though, the attributes are in a different form. |
Method Summary | |
---|---|
void |
addChild(PolicyXMLNode child)
This method adds another child to the collection of children. |
void |
addString(java.lang.String str)
This method adds more text that is read in blocks by the XML Parser. |
void |
construct()
This method is called when the node is closed. |
java.util.Map |
getAttributes()
This method returns the collection of attributes for this node; for walking the tree. |
java.util.Vector |
getChildren()
This method returns the collection of children. |
java.lang.String |
getName()
This method returns the name of the node, so you could walk down the tree, if you wanted. |
java.lang.String |
getString()
This method returns the text contained between the opening and closing tags of the element. |
java.lang.String |
toString()
|
java.lang.String |
toXML()
This function returnes the XML representation of the XML element. |
void |
toXML(java.lang.StringBuffer xmlStr,
java.lang.String currentIndent,
java.lang.String indentIncrement)
This method converts the node to XML text with the specified indent for the current node and the indent increment for children nodes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.lang.String name
protected java.util.Map attributes
protected java.util.Vector children
protected java.lang.String nodeStr
Constructor Detail |
---|
protected PolicyXMLNode()
protected PolicyXMLNode(java.lang.String nodeName)
nodeName
- - the name of the XML elementpublic PolicyXMLNode(java.lang.String nodeName, org.xml.sax.Attributes attr)
nodeName
- - the name of the XML elementattr
- - the attributes of the XML element represented by this
objectpublic PolicyXMLNode(java.lang.String nodeName, java.util.Map attrs)
nodeName
- - the name of the XML elementattrs
- - the Map of attributes of the XML element represented by
this objectMethod Detail |
---|
public void addString(java.lang.String str)
str
- is the string associated with the nodepublic java.lang.String getString()
public void addChild(PolicyXMLNode child)
construct
method to have any
effect.
child
- is the node to append as a child node at the end of the list
of childrenconstruct()
public java.lang.String getName()
public java.util.Map getAttributes()
public java.util.Vector getChildren()
public void construct() throws PolicyParsingException
This method does nothing by default, and should be overridden.
PolicyParsingException
- if any syntax or semantics error occurredpublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toXML()
<Obligations> <Obligation ObligationID="111" Chronicle="BeforeEnforcement"/> <Obligation ObligationID="123" Chronicle="BeforeEnforcement"> Any Text here representing the chilldren of the obligation 123. </Obligation> </Obligations>
public void toXML(java.lang.StringBuffer xmlStr, java.lang.String currentIndent, java.lang.String indentIncrement)
xmlStr
- - the StringBuffer to output the XML text tocurrentIndent
- - the indent for the current node; if null, no
indentation is performed for this node, or any children, and the
whole piece of XML will be output as a single lineindentIncrement
- - the increment of indentation between the current
node and its childrent; has no effect, if the currentIndent is null;
if this value is null, two white spaces are used as the indentation
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |