Class AbstractRslNode

  • Direct Known Subclasses:
    ListRslNode, RslNode

    public abstract class AbstractRslNode
    extends Object
    This class represents an abstract RSL parse tree. It is composed of variable definitions (bindings), relations, and sub-specifications (sub nodes).
    • Constructor Detail

      • AbstractRslNode

        public AbstractRslNode()
      • AbstractRslNode

        public AbstractRslNode​(int operator)
    • Method Detail

      • add

        public abstract boolean add​(Bindings bindings)
      • add

        public abstract boolean add​(NameOpValue relations)
      • add

        public boolean add​(AbstractRslNode node)
        Adds a rsl parse tree to this node.
        Parameters:
        node - the rsl parse tree to add.
      • getParam

        public abstract NameOpValue getParam​(String attribute)
        Returns the relation associated with the given attribute.
        Parameters:
        attribute - the attribute of the relation.
        Returns:
        the relation for the attribute. Null, if not found.
      • getBindings

        public abstract Bindings getBindings​(String attribute)
        Returns the variable definitions associated wit the given attribute.
        Parameters:
        attribute - the attribute of the variable deinitions.
        Returns:
        the variable deinitions for the attribute. Null, if not found.
      • removeSpecification

        public boolean removeSpecification​(AbstractRslNode node)
        Removes a specific sub-specification tree from the sub-specification list.
        Parameters:
        node - node to remove.
        Returns:
        true if the tree was removed successfuly. False, otherwise.
      • removeBindings

        public abstract Bindings removeBindings​(String attribute)
        Removes a bindings list for the specified attribute.
        Parameters:
        attribute - the attribute name for the bindings.
        Returns:
        the bindings that were removed.
      • removeParam

        public abstract NameOpValue removeParam​(String attribute)
        Removes a relation for the specified attribute.
        Parameters:
        attribute - the attribute name for the relation to remove.
        Returns:
        the relation that was removed.
      • merge

        public void merge​(AbstractRslNode inNode)
        Merges the specified node with the current node. All sub-specifications from the given node will be copied to the current node. All relations and variable definitions will be added together in the current node.
        Parameters:
        inNode - the source parse tree.
      • getSpecifications

        public List getSpecifications()
        Returns the list of sub-specifications.
        Returns:
        the list of other sub-specifications.
      • getOperator

        public int getOperator()
        Returns the node operator.
        Returns:
        the operator.
      • setOperator

        public void setOperator​(int oper)
        Sets the operator.
        Parameters:
        oper - the operator.
      • getOperatorAsString

        public String getOperatorAsString()
        Returns the operator as a string.
        Returns:
        operator in a string representation.
      • getOperatorAsString

        public static String getOperatorAsString​(int op)
        Returns a string represention of a given operator.
        Parameters:
        op - the operator.
        Returns:
        the string representation of the operator.
      • evaluate

        public AbstractRslNode evaluate()
                                 throws RslEvaluationException
        Evalutes the rsl tree. All the variable definitions are first evaluated because they might update the symbol table. Then all the relations followed by the sub-specifications are evaluated.
        Returns:
        the evaluated rsl tree.
        Throws:
        RslEvaluationException - If an error occured during rsl evaluation.
      • evaluate

        public abstract AbstractRslNode evaluate​(Map symbolTable)
                                          throws RslEvaluationException
        Evalutes the rsl tree against the specified symbol table. All the variable definitions are first evaluated because they might update the symbol table. Then all the relations followed by the sub-specifications are evaluated.
        Parameters:
        symbolTable - the symbol table to evalute variables against.
        Returns:
        the evaluated rsl tree.
        Throws:
        RslEvaluationException - If an error occured during rsl evaluation.
      • toRSL

        public String toRSL​(boolean explicitConcat)
        Returns a RSL representation of this relation.
        Note: Enable explicitConcat to generate more 'valid' RSL
        Parameters:
        explicitConcat - if true explicit concatination will be used in RSL strings.
        Returns:
        RSL representation of this relation.
      • toRSL

        public abstract void toRSL​(StringBuffer buf,
                                   boolean explicitConcat)
        Produces a RSL representation of node.
        Parameters:
        buf - buffer to add the RSL representation to.
        explicitConcat - if true explicit concatination will be used in RSL strings.
      • canonicalize

        public static String canonicalize​(String str)
        Canonicalizes a string by removing any underscores and moving all characters to lowercase.
        Parameters:
        str - string to canonicalize
        Returns:
        canonicalized string