JavaScript is disabled on your browser.
  • Summary:
  • Nested Field Constructor
  • Method
  • | Detail:
  • Field Constructor
  • Method
Package: groovy.util

[Java] Class Eval


  • public class Eval
    extends Object 
    • Methods Summary

        Methods
        Type Params Return Type Name and description
        public static Object me (String expression)
        Evaluates the specified String expression and returns the result.
        public static Object me (String symbol, Object object, String expression)
        Evaluates the specified String expression and makes the parameter available inside the script, returning the result.
        public static Object x (Object x, String expression)
        Evaluates the specified String expression and makes the parameter available inside the script bound to a variable named 'x', returning the result.
        public static Object xy (Object x, Object y, String expression)
        Evaluates the specified String expression and makes the first two parameters available inside the script bound to variables named 'x' and 'y' respectively, returning the result.
        public static Object xyz (Object x, Object y, Object z, String expression)
        Evaluates the specified String expression and makes the first three parameters available inside the script bound to variables named 'x', 'y', and 'z' respectively, returning the result.
    • Inherited Methods Summary

    • Method Detail

      • public static Object me(String expression)

        Evaluates the specified String expression and returns the result. For example:

         assert Eval.me(' 2 * 4 + 2') == 10
         
        throws:
        CompilationFailedException if expression is not valid Groovy
        Parameters:
        expression - the Groovy expression to evaluate
        Returns:
        the result of the expression

      • public static Object me(String symbol, Object object, String expression)

        Evaluates the specified String expression and makes the parameter available inside the script, returning the result. For example, this code binds the 'x' variable:

         assert Eval.me('x', 2, ' x * 4 + 2') == 10
         
        throws:
        CompilationFailedException if expression is not valid Groovy
        Parameters:
        expression - the Groovy expression to evaluate
        Returns:
        the result of the expression

      • public static Object x(Object x, String expression)

        Evaluates the specified String expression and makes the parameter available inside the script bound to a variable named 'x', returning the result. For example, this code executes without failure:

         assert Eval.x(2, ' x * 4 + 2') == 10
         
        throws:
        CompilationFailedException if expression is not valid Groovy
        Parameters:
        expression - the Groovy expression to evaluate
        Returns:
        the result of the expression

      • public static Object xy(Object x, Object y, String expression)

        Evaluates the specified String expression and makes the first two parameters available inside the script bound to variables named 'x' and 'y' respectively, returning the result. For example, this code executes without failure:

         assert Eval.xy(2, 4, ' x * y + 2') == 10
         
        throws:
        CompilationFailedException if expression is not valid Groovy
        Parameters:
        expression - the Groovy expression to evaluate
        Returns:
        the result of the expression

      • public static Object xyz(Object x, Object y, Object z, String expression)

        Evaluates the specified String expression and makes the first three parameters available inside the script bound to variables named 'x', 'y', and 'z' respectively, returning the result. For example, this code executes without failure:

         assert Eval.xyz(2, 4, 2, ' x * y + z') == 10
         
        throws:
        CompilationFailedException if expression is not valid Groovy
        Parameters:
        expression - the Groovy expression to evaluate
        Returns:
        the result of the expression

  • Summary:
  • Nested Field Constructor
  • Method
  • | Detail:
  • Field Constructor
  • Method

Copyright © 2003-2025 The Apache Software Foundation. All rights reserved.

AltStyle によって変換されたページ (->オリジナル) /