Class SimpleNode

    • Field Detail

      • parent

        protected Node parent
      • children

        protected Node[] children
      • id

        protected int id
    • Constructor Detail

      • SimpleNode

        protected SimpleNode​(int i)
    • Method Detail

      • encodeScalarAsEJBQL

        protected static void encodeScalarAsEJBQL​(List<Object> parameterAccumulator,
                                                  Appendable out,
                                                  Object scalar)
                                           throws IOException

        This is a utility method that can represent the supplied scalar as either an EJBQL literal into the supplied PrintWriter or is able to add the scalar to the parameters and to instead write a positional parameter to the EJBQL written to the PrintWriter. If the parameters are null and the scalar object is not able to be represented as an EJBQL literal then the method will throw a runtime exception to indicate that it has failed to produce valid EJBQL.

        Throws:
        IOException
      • appendScalarAsString

        protected static void appendScalarAsString​(Appendable out,
                                                   Object scalar,
                                                   char quoteChar)
                                            throws IOException
        Utility method that encodes an object that is not an expression Node to String.
        Throws:
        IOException
      • appendAsEscapedString

        protected static void appendAsEscapedString​(Appendable out,
                                                    String source)
                                             throws IOException
        Utility method that prints a string to the provided Appendable, escaping special characters.
        Throws:
        IOException
      • getExpressionOperator

        protected abstract String getExpressionOperator​(int index)
      • getEJBQLExpressionOperator

        protected String getEJBQLExpressionOperator​(int index)
        Returns operator for EJBQL statements, which can differ for Cayenne expression operator
      • pruneNodeForPrunedChild

        protected boolean pruneNodeForPrunedChild​(Object prunedChild)
        Description copied from class: Expression
        Returns true if this node should be pruned from expression tree in the event a child is removed.
        Specified by:
        pruneNodeForPrunedChild in class Expression
      • expName

        public String expName()
        Implemented for backwards compatibility with exp package.
        Overrides:
        expName in class Expression
      • flattenTree

        protected void flattenTree()
        Flattens the tree under this node by eliminating any children that are of the same class as this node and copying their children to this node.
        Specified by:
        flattenTree in class Expression
      • getOperand

        public Object getOperand​(int index)
        Description copied from class: Expression
        Returns a value of operand at index. Operand indexing starts at 0.
        Specified by:
        getOperand in class Expression
      • wrapChild

        protected Node wrapChild​(Object child)
      • unwrapChild

        protected Object unwrapChild​(Node child)
      • getOperandCount

        public int getOperandCount()
        Description copied from class: Expression
        Returns a count of operands of this expression. In real life there are unary (count == 1), binary (count == 2) and ternary (count == 3) expressions.
        Specified by:
        getOperandCount in class Expression
      • setOperand

        public void setOperand​(int index,
                               Object value)
        Description copied from class: Expression
        Sets a value of operand at index. Operand indexing starts at 0.
        Specified by:
        setOperand in class Expression
      • jjtOpen

        public void jjtOpen()
        Description copied from interface: Node
        Called after the node has been made the current node. It indicates that child nodes can now be added to it.
        Specified by:
        jjtOpen in interface Node
      • jjtClose

        public void jjtClose()
        Description copied from interface: Node
        Called after all the child nodes have been added.
        Specified by:
        jjtClose in interface Node
      • jjtSetParent

        public void jjtSetParent​(Node n)
        Description copied from interface: Node
        This pair of methods are used to inform the node of its parent.
        Specified by:
        jjtSetParent in interface Node
      • jjtAddChild

        public void jjtAddChild​(Node n,
                                int i)
        Description copied from interface: Node
        This method tells the node to add its argument to the node's list of children.
        Specified by:
        jjtAddChild in interface Node
      • jjtGetChild

        public Node jjtGetChild​(int i)
        Description copied from interface: Node
        This method returns a child node. The children are numbered from zero, left to right.
        Specified by:
        jjtGetChild in interface Node
      • jjtGetNumChildren

        public final int jjtGetNumChildren()
        Description copied from interface: Node
        Return the number of children the node has.
        Specified by:
        jjtGetNumChildren in interface Node
      • evaluateNode

        protected abstract Object evaluateNode​(Object o)
                                        throws Exception
        Evaluates itself with object, pushing result on the stack.
        Throws:
        Exception
      • connectChildren

        protected void connectChildren()
        Sets the parent to this for all children.
        Since:
        3.0
      • evaluate

        public Object evaluate​(Object o)
        Description copied from class: Expression
        Calculates expression value with object as a context for path expressions.
        Specified by:
        evaluate in class Expression
      • appendAsEJBQL

        public void appendAsEJBQL​(Appendable out,
                                  String rootId)
                           throws IOException
        Description copied from class: Expression
        Stores a String representation of Expression as EJBQL using a provided Appendable. DB path expressions produce non-standard EJBQL path expressions.
        Overrides:
        appendAsEJBQL in class Expression
        Throws:
        IOException
        Since:
        4.0
      • appendAsEJBQL

        public void appendAsEJBQL​(List<Object> parameterAccumulator,
                                  Appendable out,
                                  String rootId)
                           throws IOException
        Description copied from class: Expression
        Stores a String representation of Expression as EJBQL using a provided PrintWriter. DB path expressions produce non-standard EJBQL path expressions. If the parameterAccumulator is supplied then as the EJBQL is output, it may load parameters into this list. In this case, the EJBQL output will contain reference to positional parameters. If no parameterAccumulator is supplied and a scalar type is encountered for which there is no EJBQL literal representation (such as dates) then this method will throw a runtime exception to indicate that it was not possible to generate a string-only representation of the Expression in EJBQL.
        Specified by:
        appendAsEJBQL in class Expression
        Throws:
        IOException
        Since:
        4.0