Class Rulebase

java.lang.Object
COM.TIBCO.hawk.config.rbengine.rulebase.RulebaseElement
COM.TIBCO.hawk.config.rbengine.rulebase.Rulebase
All Implemented Interfaces:
RBEConfigObject, Cloneable

public class Rulebase extends RulebaseElement implements RBEConfigObject
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 Details

  • Constructor Details

    • Rulebase

      public Rulebase(Reader reader) throws RulebaseException
      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

      public Rulebase(String name, Rule[] rules)
      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 null
      IllegalArgumentException - if name contains illegal characters
      IllegalArgumentException - if any of the rule names are not unique
    • Rulebase

      protected Rulebase(Rulebase rb)
      Constructs a Rulebase from an existing rulebase. Note: new rulebase reference to the given rulebase.
    • Rulebase

      protected Rulebase(COM.TIBCO.hawk.util.xml.XmlElementNode xmlNode) throws RulebaseException
      Constructs a Rulebase from XML representation
      Parameters:
      xmlNode - XML node that contain the Rulebase
      Throws:
      RulebaseException
      See Also:
      • XmlElementNode
  • Method Details

    • getFileExtension

      public String getFileExtension()
      Returns file extension based on the configuration object type.
      Specified by:
      getFileExtension in interface RBEConfigObject
      Returns:
      the file extension of the configuration object
    • toXML

      public void toXML(Writer writer) throws RulebaseException
      Write the configuration object to the writer in XML.
      Specified by:
      toXML in interface RBEConfigObject
      Overrides:
      toXML in class RulebaseElement
      Throws:
      RulebaseException
    • toString

      public String toString()
      Returns the string representation of the parameter.
      Overrides:
      toString in class Object
    • setName

      public void setName(String name)
      Sets the name of this rulebase element.
      Overrides:
      setName in class RulebaseElement
      Throws:
      IllegalArgumentException - if name contains illegal characters
    • setAuthor

      public void setAuthor(String author)
      Sets the author
    • getAuthor

      public String getAuthor()
      Returns the author of the rulebase.
    • setLastModification

      public void setLastModification(String mod)
      Sets the last modification record.
    • getLastModification

      public String getLastModification()
      Returns the last modification string. This attribute is used to record information about the last edit made to the rulebase.
    • setComment

      public void setComment(String comment)
      Sets the comment.
    • getComment

      public String 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

      public void setRules(Rule[] rules) throws IllegalArgumentException
      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 null
      IllegalArgumentException - if the rule names are not unique
    • getRules

      public Rule[] getRules()
      Returns the list of Rule objects that make up this rulebase.
    • setIncludedRulebases

      public void setIncludedRulebases(String[] rbNames) throws IllegalArgumentException
      Sets the include rulebase list.
      Throws:
      IllegalArgumentException
    • getIncludedRulebases

      public String[] 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

      public void setCommands(String[] commands) throws IllegalArgumentException
      Sets the commands list.
      Throws:
      IllegalArgumentException
    • getCommands

      public String[] getCommands()
      Returns the command list of a rulebase.
    • applyVariables

      public Rulebase applyVariables(Properties variables) throws IOException
      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

      public boolean equals(Object obj)
      Compare the specified object with this rulebase.
      Overrides:
      equals in class RulebaseElement
      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:
      getChecksum in interface RBEConfigObject
    • clone

      public Object clone()
      Returns a copy of this object
      Specified by:
      clone in class RulebaseElement
    • saveNewVersion

      protected boolean saveNewVersion(String fileName)
      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:
      IOException
      RulebaseException
    • toXML

      protected void toXML(COM.TIBCO.hawk.util.xml.XmlWriter out) throws IOException, RulebaseException
      Write XML representation of the rulebase to the XML writer.
      Overrides:
      toXML in class RulebaseElement
      Parameters:
      out - the XML writer where the output will be written.
      Throws:
      IOException
      RulebaseException
    • 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:
      fromXML in class RulebaseElement
      Parameters:
      node - the XML node containing the rulebase.
      Throws:
      RulebaseException
    • clone

      protected Rule[] clone(Rule[] a)
      make a copy of Rule array
    • substituteValues

      public static String substituteValues(String source, Properties prop) throws Exception
      substitues keys with values in the input
      Parameters:
      input -
      prop - REPLACES KEY with VALUES
      Throws:
      Exception