kaos.core.util
Class Msg

java.lang.Object
  extended by kaos.core.util.Msg
All Implemented Interfaces:
java.io.Serializable, org.xml.sax.ErrorHandler
Direct Known Subclasses:
AttributeMsg, DirectoryEventMsg, EnforcementCapabilityMsg, MethodCallMsg, PolicyMsg, PolicySetMsg, SubjectMsg

public class Msg
extends java.lang.Object
implements org.xml.sax.ErrorHandler, java.io.Serializable

$Revision: 1.11 $

See Also:
Serialized Form

Constructor Summary
  Msg()
          This public constructor gets you an un-named "fromDTD" document.
protected Msg(Msg m)
          This is for use by subclasses
 
Method Summary
 void addSubMsg(java.lang.String subMsgPath, Msg theSubMsg)
          Add a submsg to this message, or to one of its submsgs, subMsgPath being a heirarchical list.
 void addSubMsg(java.lang.String subMsgPath, java.lang.String delimsIgnored, Msg theSubMsg)
          Silly variant.
 void addSymbol(java.lang.String symbolName, java.lang.Object symbolObject)
          Variant of addSymbol - for Objects
 void addSymbol(java.lang.String symbolName, java.lang.String symbolValue)
          Given a Msg node, create a new simple SVP as a child, with a String for the value.
 void addSymbol(java.lang.String symbolName, java.lang.String delimsIgnored, java.lang.Object symbolObject)
          Silly variant of addSymbol.
 void addSymbol(java.lang.String symbolName, java.lang.String delimsIgnored, java.lang.String symbolValue)
          Silly variant of addSymbol.
 void addSymbol(java.lang.String symbolName, java.lang.String delimsIgnored, java.util.Vector vectorValue)
          Unused variant of addSymbol.
 void addSymbol(java.lang.String symbolName, java.util.Vector vectorValue)
          Given a Msg node, create a new vector-type SVP as a child, with a Vector (of String) for the value: symbolName may be a heirarchical path.
 java.lang.Object clone()
           
static Msg createFromFile(java.lang.String filename, org.xml.sax.ErrorHandler errHandler)
          createFromFile is more for exploring XML than for KAoS use....
 void error(org.xml.sax.SAXParseException exception)
           
 void fatalError(org.xml.sax.SAXParseException exception)
           
static kaos.core.util.FixNodeList getElementsNamed(org.w3c.dom.Node parent, java.lang.String desiredType)
          replace function of svpNodes = msgNode.getElementsByTagName(SVP_ELEMENT_NAME);
static org.w3c.dom.Element getFirstChildSkip(org.w3c.dom.Element n, boolean skip)
          getFirstChildNode if 1st child is #text, go to first non-#text sibling of it
 java.lang.String getNamedString(java.lang.String symbolPath)
          Get the given String-value symbol denoted by (possibly heirarchical) symbolPath.
 java.lang.String getNamedString(java.lang.String symbolPath, java.lang.String delimsIgnored)
          Convenience method.
 java.util.Vector getNamedVector(java.lang.String symbolPath)
          Convenience method.
static org.w3c.dom.Element getNextSkip(org.w3c.dom.Element n, boolean skip)
          getNextNode keep skipping #text nodes
static org.w3c.dom.NamedNodeMap getNodeAttributes(org.w3c.dom.Element n)
          Public util method; list all attributes.
static org.w3c.dom.Element getParentSkip(org.w3c.dom.Element n, boolean skip)
          getParentNode keep skipping #text nodes
static org.w3c.dom.Element getPreviousSkip(org.w3c.dom.Element n, boolean skip)
          getPreviousNode keep skipping #text nodes
 org.w3c.dom.Element getRootNode()
          getRootNode This gets the root Msg node, not the real root root.
 Msg getSubMsg(java.lang.String symbolPath)
          Search for and return the submessage of this message having the given name.
 Msg getSubMsg(java.lang.String subMsgName, java.lang.String delimsIgnored)
          Unused variant of getSubMsg.
 java.lang.Object getSymbol(java.lang.String symbolPath)
          Get the given symbol denoted by (possibly heirarchical) symbolPath.
 java.lang.Object getSymbol(java.lang.String symbolPath, java.lang.String delimsIgnored)
          Silly variant.
static boolean getVerbosity()
          Public method to get the verbosity level.
static void main(java.lang.String[] argv)
          getXML Obtain the XML representation of this Msg object.
 void removeSymbol(java.lang.String symbolPath)
           
static void setLogger(Logger logger)
           
static void setVerbosity(boolean newVerbosity)
          Public method to set the verbosity level.
static java.lang.String showMsgInfo(org.w3c.dom.Element msgNode, boolean recurse, int iLevel, boolean crOnEnd)
           
static java.lang.String showMsgInfo(org.w3c.dom.Element msgNode, boolean recurse, int iLevel, boolean crOnEnd, boolean displayMsgName)
          showMsgInfo - public utility method.
 java.lang.String toString()
          Format a Msg for printing.
static void traverseDOMBranch(org.w3c.dom.Node node, int pIndent)
           
 void traverseRoot()
          Print out the whole fam damily.
 void warning(org.xml.sax.SAXParseException exception)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Msg

public Msg()
This public constructor gets you an un-named "fromDTD" document.


Msg

protected Msg(Msg m)
This is for use by subclasses

Method Detail

addSymbol

public void addSymbol(java.lang.String symbolName,
                      java.lang.String symbolValue)
Given a Msg node, create a new simple SVP as a child, with a String for the value. symbolName may be a heirarchical path. msgNode | SVP symName= | SVItem - SVItem ... vIVal= vIVal=


addSymbol

public void addSymbol(java.lang.String symbolName,
                      java.lang.String delimsIgnored,
                      java.lang.String symbolValue)
Silly variant of addSymbol. The old Msg class had the ability to use different delimiter characters, but that was never used. This method is here for backward compatibility.


setLogger

public static void setLogger(Logger logger)

addSymbol

public void addSymbol(java.lang.String symbolName,
                      java.lang.Object symbolObject)
Variant of addSymbol - for Objects


addSymbol

public void addSymbol(java.lang.String symbolName,
                      java.lang.String delimsIgnored,
                      java.lang.Object symbolObject)
Silly variant of addSymbol. The old Msg class had the ability to use different delimiter characters, but that was never used. This method is here for backward compatibility.


addSymbol

public void addSymbol(java.lang.String symbolName,
                      java.util.Vector vectorValue)
Given a Msg node, create a new vector-type SVP as a child, with a Vector (of String) for the value: symbolName may be a heirarchical path. msgNode | SVP | Symbol symName= | SVItem - SVItem ... VIVal= VIVal=


addSymbol

public void addSymbol(java.lang.String symbolName,
                      java.lang.String delimsIgnored,
                      java.util.Vector vectorValue)
Unused variant of addSymbol. The old Msg class had the ability to use different delimiter characters, but that was never used. This method is here for backward compatibility.


getSymbol

public java.lang.Object getSymbol(java.lang.String symbolPath)
                           throws SymbolNotFoundException
Get the given symbol denoted by (possibly heirarchical) symbolPath. May return a String, or a Vector, or ... ? Throw SymbolNotFoundException if not found.

Throws:
SymbolNotFoundException

removeSymbol

public void removeSymbol(java.lang.String symbolPath)
                  throws SymbolNotFoundException
Throws:
SymbolNotFoundException

getSymbol

public java.lang.Object getSymbol(java.lang.String symbolPath,
                                  java.lang.String delimsIgnored)
                           throws SymbolNotFoundException
Silly variant. The old Msg class had the ability to use different delimiter characters, but that was never used. This method is here for backward compatibility.

Throws:
SymbolNotFoundException

getNamedString

public java.lang.String getNamedString(java.lang.String symbolPath)
                                throws SymbolNotFoundException,
                                       java.lang.ClassCastException
Get the given String-value symbol denoted by (possibly heirarchical) symbolPath. This is a kind of silly method that just does the cast for ya.

Throws:
SymbolNotFoundException
java.lang.ClassCastException

getNamedString

public java.lang.String getNamedString(java.lang.String symbolPath,
                                       java.lang.String delimsIgnored)
                                throws SymbolNotFoundException,
                                       java.lang.ClassCastException
Convenience method. The old Msg class had the ability to use different delimiter characters, but that was never used. This method is here for backward compatibility.

Throws:
SymbolNotFoundException
java.lang.ClassCastException

getNamedVector

public java.util.Vector getNamedVector(java.lang.String symbolPath)
Convenience method.

Note that this returns null if not found, instead of throwing exception.


addSubMsg

public void addSubMsg(java.lang.String subMsgPath,
                      Msg theSubMsg)
Add a submsg to this message, or to one of its submsgs, subMsgPath being a heirarchical list. If the ultimate msg exists, replace it.


addSubMsg

public void addSubMsg(java.lang.String subMsgPath,
                      java.lang.String delimsIgnored,
                      Msg theSubMsg)
Silly variant. The old Msg class had the ability to use different delimiter characters, but that was never used. This method is here for backward compatibility.


getSubMsg

public Msg getSubMsg(java.lang.String symbolPath)
              throws SymbolNotFoundException
Search for and return the submessage of this message having the given name. If it doesn't exist, return null.

Throws:
SymbolNotFoundException

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

getSubMsg

public Msg getSubMsg(java.lang.String subMsgName,
                     java.lang.String delimsIgnored)
              throws SymbolNotFoundException
Unused variant of getSubMsg. The old Msg class had the ability to use different delimiter characters, but that was never used. This method is here for backward compatibility.

Throws:
SymbolNotFoundException

createFromFile

public static Msg createFromFile(java.lang.String filename,
                                 org.xml.sax.ErrorHandler errHandler)
createFromFile is more for exploring XML than for KAoS use.... public util method.


getNodeAttributes

public static org.w3c.dom.NamedNodeMap getNodeAttributes(org.w3c.dom.Element n)
Public util method; list all attributes. For debugging, really.


toString

public java.lang.String toString()
Format a Msg for printing.

Overrides:
toString in class java.lang.Object

showMsgInfo

public static java.lang.String showMsgInfo(org.w3c.dom.Element msgNode,
                                           boolean recurse,
                                           int iLevel,
                                           boolean crOnEnd)

showMsgInfo

public static java.lang.String showMsgInfo(org.w3c.dom.Element msgNode,
                                           boolean recurse,
                                           int iLevel,
                                           boolean crOnEnd,
                                           boolean displayMsgName)
showMsgInfo - public utility method. Return a String representation of this object. Optionally recurse for all sub-Msgs.

Parameters:
msgNode - The root node at which to start displaying.
recurse - Shall we keep going into sub-messages?
iLevel - The display indentation level.
crOnEnd - Shall we put a carriage-return on the end of the returned string?

getRootNode

public org.w3c.dom.Element getRootNode()
getRootNode This gets the root Msg node, not the real root root. (if ya know what i mean) don' skip nothin'


getParentSkip

public static org.w3c.dom.Element getParentSkip(org.w3c.dom.Element n,
                                                boolean skip)
getParentNode keep skipping #text nodes


getPreviousSkip

public static org.w3c.dom.Element getPreviousSkip(org.w3c.dom.Element n,
                                                  boolean skip)
getPreviousNode keep skipping #text nodes


getNextSkip

public static org.w3c.dom.Element getNextSkip(org.w3c.dom.Element n,
                                              boolean skip)
getNextNode keep skipping #text nodes


getFirstChildSkip

public static org.w3c.dom.Element getFirstChildSkip(org.w3c.dom.Element n,
                                                    boolean skip)
getFirstChildNode if 1st child is #text, go to first non-#text sibling of it


traverseDOMBranch

public static void traverseDOMBranch(org.w3c.dom.Node node,
                                     int pIndent)

traverseRoot

public void traverseRoot()
Print out the whole fam damily.


error

public void error(org.xml.sax.SAXParseException exception)
           throws org.xml.sax.SAXException
Specified by:
error in interface org.xml.sax.ErrorHandler
Throws:
org.xml.sax.SAXException

warning

public void warning(org.xml.sax.SAXParseException exception)
             throws org.xml.sax.SAXException
Specified by:
warning in interface org.xml.sax.ErrorHandler
Throws:
org.xml.sax.SAXException

fatalError

public void fatalError(org.xml.sax.SAXParseException exception)
                throws org.xml.sax.SAXException
Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Throws:
org.xml.sax.SAXException

setVerbosity

public static void setVerbosity(boolean newVerbosity)
Public method to set the verbosity level.


getVerbosity

public static boolean getVerbosity()
Public method to get the verbosity level.


main

public static void main(java.lang.String[] argv)
getXML Obtain the XML representation of this Msg object. At the moment, does so without reference to any DTD; also does no verification of XML validity (which perhaps should be done elsewhere, anyway).


getElementsNamed

public static kaos.core.util.FixNodeList getElementsNamed(org.w3c.dom.Node parent,
                                                          java.lang.String desiredType)
replace function of svpNodes = msgNode.getElementsByTagName(SVP_ELEMENT_NAME);