Class DimensionVisitor

    • Field Detail

      • DIM_KEY

        public static final Node.HookKey DIM_KEY
        A Key to use with Nodes and Variables to store the dimensions.
      • jep

        protected Jep jep
    • Constructor Detail

      • DimensionVisitor

        public DimensionVisitor()
        Should only be used as when the init(Jep) will be called.
      • DimensionVisitor

        public DimensionVisitor​(Jep jep1)
    • Method Detail

      • getDimByValue

        public static final Dimensions getDimByValue​(java.lang.Object val)
        Find the dimensions of a given value. Handles cases when the value is of types MatrixI, VectorI, one and two dimensional java.util.Vectors.
        Parameters:
        val - value
        Returns:
        dimensions of object, unknown types returns SCALER.
      • setVariableDimensions

        public void setVariableDimensions​(Variable var,
                                          Dimensions dim)
        Sets the dimensions of a variable to give value. Can be used in a situation when a variable is defined without a value being set for example
        
             Variable var = jep.addVariable("v");
             dimensionVisitor.setVariableDimensions(var,Dimensions.THREE);
         
        Parameters:
        var -
        dim -
        Since:
        Jep 4.0/Extensions 2.1
      • calcVariableDimensionsByValue

        public Dimensions calcVariableDimensionsByValue​(Variable var)
        Calculate and sets the dimensions of a variable using its value
        Parameters:
        var - the variable, it is assumed it does not have a null value
        Returns:
        the dimensions of its value
        Throws:
        java.lang.NullPointerException - if the variable does not have a value
      • visit

        public Dimensions visit​(XVariable var)
                         throws ParseException
        If the variable has an equation visit that equation to find the dimensions and set the variables dimension.
        Parameters:
        var - the variable
        Returns:
        the calculated dimension
        Throws:
        ParseException - if the variable does not have an equation
        Since:
        Jep 4.0/Extensions 2.1
      • getDimensions

        public Dimensions getDimensions​(Variable var)
        Get the dimensions of a variable.
        Parameters:
        var - the variable
        Returns:
        the dimensions or null if it has not been set
        Since:
        Jep 4.0/Extensions 2.1
      • getDimensions

        public Dimensions getDimensions​(Node node)
        Get the dimensions of a node. For use in a static context use (Dimensions) node.getHook(DimensionVisitor.DIM_KEY);
        Parameters:
        node - the node
        Returns:
        the dimensions or null if it has not been previously calculated
        Since:
        Jep 4.0/Extensions 2.1
      • visit

        public Dimensions visit​(Node node)
                         throws ParseException
        Annotate every node in the tree.
        Parameters:
        node - root node of the expression
        Returns:
        dimensions of the root node
        Throws:
        ParseException
      • getWarnings

        public java.util.List<java.lang.String> getWarnings()
        The list of warnings when a variable has changed dimension.
        Returns:
      • init

        public void init​(Jep jep1)
        Description copied from interface: JepComponent
        Initialize the component. This methods is called whenever a component is added to Jep. Hence it allows components to keep track of the other components they may rely on.
        Specified by:
        init in interface JepComponent
        Parameters:
        jep1 - the current Jep instance
      • getLightWeightInstance

        public JepComponent getLightWeightInstance()
        Description copied from interface: JepComponent
        Gets a light-weight instance suitable for using in multiple threads.
        Specified by:
        getLightWeightInstance in interface JepComponent
        Returns:
        either an new instance, null or 'this'.