Class Rulebase
java.lang.Object
COM.TIBCO.hawk.config.rbengine.rulebase.RulebaseElement
COM.TIBCO.hawk.config.rbengine.rulebase.Rulebase
- All Implemented Interfaces:
RBEConfigObject,Cloneable
This class represents a rulebase. A rulebase is a configuration
object for the RulebaseEngine microagent of a TIB/Hawk agent.
It provides the instructions for the monitoring activities that
are to be autonomously performed.
The author and lastModification attributes are maintained by convention. Your code should set the author when a new rulebase is constructed. It should also record last modification information each time the rulebase is modified.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs a Rulebase from an existing rulebase.protectedRulebase(COM.TIBCO.hawk.util.xml.XmlElementNode xmlNode) Constructs a Rulebase from XML representationConstruct the ruleBase object from a reader.Constructs a Rulebase. -
Method Summary
Modifier and TypeMethodDescriptionapplyVariables(Properties variables) Substitutes variable in the rulebase with the key:value pairs in the variables.clone()Returns a copy of this objectprotected Rule[]make a copy of Rule arraybooleanCompare the specified object with this rulebase.protected voidfromXML(COM.TIBCO.hawk.util.xml.XmlElementNode documentNode) Read XML representation of the rulebase from the XML node.Returns the author of the rulebase.longReturns the checksum of the config objectString[]Returns the command list of a rulebase.Returns the rulebase comment.Returns file extension based on the configuration object type.String[]Returns the rulebase include list.Returns the last modification string.Rule[]getRules()Returns the list of Rule objects that make up this rulebase.protected voidreadExtra(COM.TIBCO.hawk.util.xml.XmlElementNode documentNode) protected booleansaveNewVersion(String fileName) Save this rulebase to fileName if conversion is done when loading.voidSets the authorvoidsetCommands(String[] commands) Sets the commands list.voidsetComment(String comment) Sets the comment.voidsetIncludedRulebases(String[] rbNames) Sets the include rulebase list.voidSets the last modification record.voidSets the name of this rulebase element.voidSets the list of Rule objects that make up this rulebase.static StringsubstituteValues(String source, Properties prop) substitues keys with values in the inputtoString()Returns the string representation of the parameter.protected voidtoXML(COM.TIBCO.hawk.util.xml.XmlWriter out) Write XML representation of the rulebase to the XML writer.voidWrite the configuration object to the writer in XML.protected voidwriteExtra(COM.TIBCO.hawk.util.xml.XmlWriter out) Methods inherited from class COM.TIBCO.hawk.config.rbengine.rulebase.RulebaseElement
fromXML, fromXML, getName, getSchedule, loadFromFile, saveToFile, setSchedule, toXMLMethods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface COM.TIBCO.hawk.config.rbengine.RBEConfigObject
getName
-
Field Details
-
CNAME
-
FILE_EXTENSION
- See Also:
-
-
Constructor Details
-
Rulebase
Construct the ruleBase object from a reader. The reader should provide the rulebase represented in XML. This is a convinien way to contruct the object from a file via FileReader.- Parameters:
reader- the input reader of the configuration object in XML representation.- Throws:
RulebaseException- if error encountered when creating rulebase from the reader
-
Rulebase
Constructs a Rulebase.- Parameters:
name- the rulebase name, it must contain only alpha-numeric characters, "_", "-", and no spaces.rules- an array of Rule objects, all rules must have unique names.- Throws:
IllegalArgumentException- if either argument is nullIllegalArgumentException- if name contains illegal charactersIllegalArgumentException- if any of the rule names are not unique
-
Rulebase
Constructs a Rulebase from an existing rulebase. Note: new rulebase reference to the given rulebase. -
Rulebase
Constructs a Rulebase from XML representation- Parameters:
xmlNode- XML node that contain the Rulebase- Throws:
RulebaseException- See Also:
-
XmlElementNode
-
-
Method Details
-
getFileExtension
Returns file extension based on the configuration object type.- Specified by:
getFileExtensionin interfaceRBEConfigObject- Returns:
- the file extension of the configuration object
-
toXML
Write the configuration object to the writer in XML.- Specified by:
toXMLin interfaceRBEConfigObject- Overrides:
toXMLin classRulebaseElement- Throws:
RulebaseException
-
toString
Returns the string representation of the parameter. -
setName
Sets the name of this rulebase element.- Overrides:
setNamein classRulebaseElement- Throws:
IllegalArgumentException- if name contains illegal characters
-
setAuthor
Sets the author -
getAuthor
Returns the author of the rulebase. -
setLastModification
Sets the last modification record. -
getLastModification
Returns the last modification string. This attribute is used to record information about the last edit made to the rulebase. -
setComment
Sets the comment. -
getComment
Returns the rulebase comment. The comment attribute is used to record user comments about the purpose of the rulebase. It also may serve as a place to record the rulebase change history. -
setRules
Sets the list of Rule objects that make up this rulebase.- Parameters:
rules- the array of rules, may not be null, all names must be unique- Throws:
IllegalArgumentException- if rules is nullIllegalArgumentException- if the rule names are not unique
-
getRules
Returns the list of Rule objects that make up this rulebase. -
setIncludedRulebases
Sets the include rulebase list.- Throws:
IllegalArgumentException
-
getIncludedRulebases
Returns the rulebase include list. This is a list of rulebases that the RulebaseEngine will attempt to load when it loads the current rulebase. -
setCommands
Sets the commands list.- Throws:
IllegalArgumentException
-
getCommands
Returns the command list of a rulebase. -
applyVariables
Substitutes variable in the rulebase with the key:value pairs in the variables. The variables in the rulebase are expected in the form of %%key%%.- Parameters:
variables- a list of key:value pairs of the variables to be substituted.- Returns:
- Returns a Rulebase with variables substituted.
- Throws:
IOException- if there is an error substituting rulebase variables.
-
equals
Compare the specified object with this rulebase.- Overrides:
equalsin classRulebaseElement- Parameters:
obj- the object to compare with- Returns:
- true if the objects are the same; false otherwise
-
getChecksum
public long getChecksum()Returns the checksum of the config object- Specified by:
getChecksumin interfaceRBEConfigObject
-
clone
Returns a copy of this object- Specified by:
clonein classRulebaseElement
-
saveNewVersion
Save this rulebase to fileName if conversion is done when loading.- Parameters:
fileName- the full path name of the file to save
-
writeExtra
protected void writeExtra(COM.TIBCO.hawk.util.xml.XmlWriter out) throws IOException, RulebaseException - Throws:
IOExceptionRulebaseException
-
toXML
Write XML representation of the rulebase to the XML writer.- Overrides:
toXMLin classRulebaseElement- Parameters:
out- the XML writer where the output will be written.- Throws:
IOExceptionRulebaseException
-
readExtra
protected void readExtra(COM.TIBCO.hawk.util.xml.XmlElementNode documentNode) -
fromXML
protected void fromXML(COM.TIBCO.hawk.util.xml.XmlElementNode documentNode) throws RulebaseException Read XML representation of the rulebase from the XML node.- Overrides:
fromXMLin classRulebaseElement- Parameters:
node- the XML node containing the rulebase.- Throws:
RulebaseException
-
clone
make a copy of Rule array -
substituteValues
substitues keys with values in the input- Parameters:
input-prop- REPLACES KEY with VALUES- Throws:
Exception
-