⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ognl.java

📁 OGNL文档包:----->最新版本!学习Struts2的必须帮助参考文档
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
       * @param root the root object for the OGNL expression
       * @return the result of evaluating the expression
       * @throws MethodFailedException if the expression called a method which failed
       * @throws NoSuchPropertyException if the expression referred to a nonexistent property
       * @throws InappropriateExpressionException if the expression can't be used in this context
       * @throws OgnlException if there is a pathological environmental problem
       */
    public static Object getValue( Object tree, Map context, Object root ) throws OgnlException
    {
        return getValue( tree, context, root, null );
    }

      /**
       * Evaluates the given OGNL expression tree to extract a value from the given root
       * object. The default context is set for the given context and root via
       * <CODE>addDefaultContext()</CODE>.
       *
       * @param tree the OGNL expression tree to evaluate, as returned by parseExpression()
       * @param context the naming context for the evaluation
       * @param root the root object for the OGNL expression
       * @param resultType the converted type of the resultant object, using the context's type converter
       * @return the result of evaluating the expression
       * @throws MethodFailedException if the expression called a method which failed
       * @throws NoSuchPropertyException if the expression referred to a nonexistent property
       * @throws InappropriateExpressionException if the expression can't be used in this context
       * @throws OgnlException if there is a pathological environmental problem
       */
    public static Object getValue( Object tree, Map context, Object root, Class resultType ) throws OgnlException
    {
        Object          result;
        OgnlContext     ognlContext = (OgnlContext)addDefaultContext(root, context);

        result = ((Node)tree).getValue( ognlContext, root );
        if (resultType != null) {
            result = getTypeConverter( context ).convertValue( context, root, null, null, result, resultType);
        }
        return result;
    }

      /**
       * Evaluates the given OGNL expression to extract a value from the given root
       * object in a given context
       *
       * @see #parseExpression(String)
       * @see #getValue(Object,Object)
       * @param expression the OGNL expression to be parsed
       * @param context the naming context for the evaluation
       * @param root the root object for the OGNL expression
       * @return the result of evaluating the expression
       * @throws MethodFailedException if the expression called a method which failed
       * @throws NoSuchPropertyException if the expression referred to a nonexistent property
       * @throws InappropriateExpressionException if the expression can't be used in this context
       * @throws OgnlException if there is a pathological environmental problem
       */
    public static Object getValue( String expression, Map context, Object root ) throws OgnlException
    {
        return getValue( expression, context, root, null );
    }

      /**
       * Evaluates the given OGNL expression to extract a value from the given root
       * object in a given context
       *
       * @see #parseExpression(String)
       * @see #getValue(Object,Object)
       * @param expression the OGNL expression to be parsed
       * @param context the naming context for the evaluation
       * @param root the root object for the OGNL expression
       * @param resultType the converted type of the resultant object, using the context's type converter
       * @return the result of evaluating the expression
       * @throws MethodFailedException if the expression called a method which failed
       * @throws NoSuchPropertyException if the expression referred to a nonexistent property
       * @throws InappropriateExpressionException if the expression can't be used in this context
       * @throws OgnlException if there is a pathological environmental problem
       */
    public static Object getValue( String expression, Map context, Object root, Class resultType ) throws OgnlException
    {
        return getValue( parseExpression(expression), context, root, resultType );
    }

      /**
       * Evaluates the given OGNL expression tree to extract a value from the given root
       * object.
       *
       * @param tree the OGNL expression tree to evaluate, as returned by parseExpression()
       * @param root the root object for the OGNL expression
       * @return the result of evaluating the expression
       * @throws MethodFailedException if the expression called a method which failed
       * @throws NoSuchPropertyException if the expression referred to a nonexistent property
       * @throws InappropriateExpressionException if the expression can't be used in this context
       * @throws OgnlException if there is a pathological environmental problem
       */
    public static Object getValue( Object tree, Object root ) throws OgnlException
    {
        return getValue( tree, root, null );
    }

      /**
       * Evaluates the given OGNL expression tree to extract a value from the given root
       * object.
       *
       * @param tree the OGNL expression tree to evaluate, as returned by parseExpression()
       * @param root the root object for the OGNL expression
       * @param resultType the converted type of the resultant object, using the context's type converter
       * @return the result of evaluating the expression
       * @throws MethodFailedException if the expression called a method which failed
       * @throws NoSuchPropertyException if the expression referred to a nonexistent property
       * @throws InappropriateExpressionException if the expression can't be used in this context
       * @throws OgnlException if there is a pathological environmental problem
       */
    public static Object getValue( Object tree, Object root, Class resultType ) throws OgnlException
    {
        return getValue( tree, createDefaultContext(root), root, resultType );
    }

      /**
       * Convenience method that combines calls to <code> parseExpression </code> and
       * <code> getValue</code>.
       *
       * @see #parseExpression(String)
       * @see #getValue(Object,Object)
       * @param expression the OGNL expression to be parsed
       * @param root the root object for the OGNL expression
       * @return the result of evaluating the expression
       * @throws ExpressionSyntaxException if the expression is malformed
       * @throws MethodFailedException if the expression called a method which failed
       * @throws NoSuchPropertyException if the expression referred to a nonexistent property
       * @throws InappropriateExpressionException if the expression can't be used in this context
       * @throws OgnlException if there is a pathological environmental problem
       */
    public static Object getValue( String expression, Object root ) throws OgnlException
    {
        return getValue( expression, root, null );
    }

      /**
       * Convenience method that combines calls to <code> parseExpression </code> and
       * <code> getValue</code>.
       *
       * @see #parseExpression(String)
       * @see #getValue(Object,Object)
       * @param expression the OGNL expression to be parsed
       * @param root the root object for the OGNL expression
       * @param resultType the converted type of the resultant object, using the context's type converter
       * @return the result of evaluating the expression
       * @throws ExpressionSyntaxException if the expression is malformed
       * @throws MethodFailedException if the expression called a method which failed
       * @throws NoSuchPropertyException if the expression referred to a nonexistent property
       * @throws InappropriateExpressionException if the expression can't be used in this context
       * @throws OgnlException if there is a pathological environmental problem
       */
    public static Object getValue( String expression, Object root, Class resultType ) throws OgnlException
    {
        return getValue( parseExpression(expression), root, resultType );
    }

      /**
       * Evaluates the given OGNL expression tree to insert a value into the object graph
       * rooted at the given root object.  The default context is set for the given
       * context and root via <CODE>addDefaultContext()</CODE>.
       *
       * @param tree the OGNL expression tree to evaluate, as returned by parseExpression()
       * @param context the naming context for the evaluation
       * @param root the root object for the OGNL expression
       * @param value the value to insert into the object graph
       * @throws MethodFailedException if the expression called a method which failed
       * @throws NoSuchPropertyException if the expression referred to a nonexistent property
       * @throws InappropriateExpressionException if the expression can't be used in this context
       * @throws OgnlException if there is a pathological environmental problem
       */
    public static void setValue( Object tree, Map context, Object root, Object value ) throws OgnlException
    {
        OgnlContext     ognlContext = (OgnlContext)addDefaultContext(root, context);
        Node            n = (Node) tree;

        n.setValue( ognlContext, root, value );
    }

      /**
       * Evaluates the given OGNL expression to insert a value into the object graph
       * rooted at the given root object given the context.
       *
       * @param expression the OGNL expression to be parsed
       * @param root the root object for the OGNL expression
       * @param context the naming context for the evaluation
       * @param value the value to insert into the object graph
       * @throws MethodFailedException if the expression called a method which failed
       * @throws NoSuchPropertyException if the expression referred to a nonexistent property
       * @throws InappropriateExpressionException if the expression can't be used in this context
       * @throws OgnlException if there is a pathological environmental problem
       */
    public static void setValue( String expression, Map context, Object root, Object value ) throws OgnlException
    {
        setValue( parseExpression(expression), context, root, value );
    }

      /**
       * Evaluates the given OGNL expression tree to insert a value into the object graph
       * rooted at the given root object.
       *
       * @param tree the OGNL expression tree to evaluate, as returned by parseExpression()
       * @param root the root object for the OGNL expression
       * @param value the value to insert into the object graph
       * @throws MethodFailedException if the expression called a method which failed
       * @throws NoSuchPropertyException if the expression referred to a nonexistent property
       * @throws InappropriateExpressionException if the expression can't be used in this context
       * @throws OgnlException if there is a pathological environmental problem
       */
    public static void setValue( Object tree, Object root, Object value ) throws OgnlException
    {
        setValue( tree, createDefaultContext(root), root, value );
    }

      /**
       * Convenience method that combines calls to <code> parseExpression </code> and
       * <code> setValue</code>.
       *
       * @see #parseExpression(String)
       * @see #setValue(Object,Object,Object)
       * @param expression the OGNL expression to be parsed
       * @param root the root object for the OGNL expression
       * @param value the value to insert into the object graph
       * @throws ExpressionSyntaxException if the expression is malformed
       * @throws MethodFailedException if the expression called a method which failed
       * @throws NoSuchPropertyException if the expression referred to a nonexistent property
       * @throws InappropriateExpressionException if the expression can't be used in this context
       * @throws OgnlException if there is a pathological environmental problem
       */
    public static void setValue( String expression, Object root, Object value ) throws OgnlException
    {
        setValue( parseExpression(expression), root, value );
    }

    public static boolean isConstant( Object tree, Map context ) throws OgnlException
    {
        return ((SimpleNode)tree).isConstant( (OgnlContext)addDefaultContext( null, context ) );
    }

    public static boolean isConstant( String expression, Map context ) throws OgnlException
    {
        return isConstant(parseExpression(expression), context);
    }

    public static boolean isConstant( Object tree ) throws OgnlException
    {
        return isConstant(tree, createDefaultContext(null));
    }

    public static boolean isConstant( String expression ) throws OgnlException
    {
        return isConstant(parseExpression(expression), createDefaultContext(null));
    }

    public static boolean isSimpleProperty( Object tree, Map context ) throws OgnlException
    {
        return ((SimpleNode)tree).isSimpleProperty( (OgnlContext)addDefaultContext( null, context ) );
    }

    public static boolean isSimpleProperty( String expression, Map context ) throws OgnlException
    {
        return isSimpleProperty(parseExpression(expression), context);
    }

    public static boolean isSimpleProperty( Object tree ) throws OgnlException
    {
        return isSimpleProperty(tree, createDefaultContext(null));
    }

    public static boolean isSimpleProperty( String expression ) throws OgnlException
    {
        return isSimpleProperty(parseExpression(expression), createDefaultContext(null));
    }

    public static boolean isSimpleNavigationChain( Object tree, Map context ) throws OgnlException
    {
        return ((SimpleNode)tree).isSimpleNavigationChain( (OgnlContext)addDefaultContext( null, context ) );
    }

    public static boolean isSimpleNavigationChain( String expression, Map context ) throws OgnlException
    {
        return isSimpleNavigationChain(parseExpression(expression), context);
    }

    public static boolean isSimpleNavigationChain( Object tree ) throws OgnlException
    {
        return isSimpleNavigationChain(tree, createDefaultContext(null));
    }

    public static boolean isSimpleNavigationChain( String expression ) throws OgnlException
    {
        return isSimpleNavigationChain(parseExpression(expression), createDefaultContext(null));
    }

      /** You can't make one of these. */
    private Ognl()
    {
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -