View Javadoc

    1   /*
    2    * joey-gen and its relative products are published under the terms
    3    * of the Apache Software License.
    4    *
    5    * Created on 2004/12/19 21:13:00
    6    */
    7   package org.asyrinx.joey.gen.task;
    8
    9   import java.util.Map;
    10
    11  import ognl.ClassResolver;
    12  import ognl.Evaluation;
    13  import ognl.MemberAccess;
    14  import ognl.Ognl;
    15  import ognl.OgnlException;
    16  import ognl.TypeConverter;
    17
    18  /***
    19   * @author takeshi
    20   */
    21  public class OgnlHelper {
    22
    23      public OgnlHelper() {
    24          super();
    25      }
    26
    27      public OgnlHelper(Map map) {
    28          super();
    29          setContext(map);
    30      }
    31
    32      private Map context = null;
    33
    34      public Map getContext() {
    35          return context;
    36      }
    37
    38      public void setContext(Map context) {
    39          this.context = context;
    40      }
    41
    42      public void addDefaultContext(Object root, ClassResolver classResolver, Map context) {
    43          setContext(Ognl.addDefaultContext(root, classResolver, context));
    44      }
    45
    46      public void addDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter, Map context) {
    47          setContext(Ognl.addDefaultContext(root, classResolver, converter, context));
    48      }
    49
    50      public void addDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter,
    51              MemberAccess memberAccess, Map context) {
    52          setContext(Ognl.addDefaultContext(root, classResolver, converter, memberAccess, context));
    53      }
    54
    55      public void addDefaultContext(Object root, Map context) {
    56          setContext(Ognl.addDefaultContext(root, context));
    57      }
    58
    59      public void createDefaultContext(Object root) {
    60          setContext(Ognl.createDefaultContext(root));
    61      }
    62
    63      public void createDefaultContext(Object root, ClassResolver classResolver) {
    64          setContext(Ognl.createDefaultContext(root, classResolver));
    65      }
    66
    67      public void createDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter) {
    68          setContext(Ognl.createDefaultContext(root, classResolver, converter));
    69      }
    70
    71      public void createDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter,
    72              MemberAccess memberAccess) {
    73          setContext(Ognl.createDefaultContext(root, classResolver, converter, memberAccess));
    74      }
    75
    76      public ClassResolver getClassResolver() {
    77          return Ognl.getClassResolver(getContext());
    78      }
    79
    80      public Evaluation getLastEvaluation() {
    81          return Ognl.getLastEvaluation(getContext());
    82      }
    83
    84      public MemberAccess getMemberAccess() {
    85          return Ognl.getMemberAccess(getContext());
    86      }
    87
    88      public Object getRoot() {
    89          return Ognl.getRoot(getContext());
    90      }
    91
    92      public TypeConverter getTypeConverter() {
    93          return Ognl.getTypeConverter(getContext());
    94      }
    95
    96      public Object getValue(String expression, Object root) throws OgnlException {
    97          return Ognl.getValue(expression, getContext(), root);
    98      }
    99
    100     public Object getValue(String expression, Object root, Class resultType) throws OgnlException {
    101         return Ognl.getValue(expression, getContext(), root, resultType);
    102     }
    103
    104     public Object getValue(String expression) throws OgnlException {
    105         return Ognl.getValue(expression, getContext());
    106     }
    107
    108     public boolean isConstant(String expression) throws OgnlException {
    109         return Ognl.isConstant(expression);
    110     }
    111
    112     public boolean isConstant(String expression, Map context) throws OgnlException {
    113         return Ognl.isConstant(expression, context);
    114     }
    115
    116     public boolean isSimpleNavigationChain(String expression) throws OgnlException {
    117         return Ognl.isSimpleNavigationChain(expression);
    118     }
    119
    120     public boolean isSimpleNavigationChain(String expression, Map context) throws OgnlException {
    121         return Ognl.isSimpleNavigationChain(expression, context);
    122     }
    123
    124     public boolean isSimpleProperty(String expression) throws OgnlException {
    125         return Ognl.isSimpleProperty(expression);
    126     }
    127
    128     public boolean isSimpleProperty(String expression, Map context) throws OgnlException {
    129         return Ognl.isSimpleProperty(expression, context);
    130     }
    131
    132     public Object parseExpression(String expression) throws OgnlException {
    133         return Ognl.parseExpression(expression);
    134     }
    135
    136     public void setClassResolver(Map context, ClassResolver classResolver) {
    137         Ognl.setClassResolver(context, classResolver);
    138     }
    139
    140     public void setMemberAccess(Map context, MemberAccess memberAccess) {
    141         Ognl.setMemberAccess(context, memberAccess);
    142     }
    143
    144     public void setRoot(Map context, Object root) {
    145         Ognl.setRoot(context, root);
    146     }
    147
    148     public void setTypeConverter(Map context, TypeConverter converter) {
    149         Ognl.setTypeConverter(context, converter);
    150     }
    151
    152     public void setValue(String expression, Object root, Object value) throws OgnlException {
    153         Ognl.setValue(expression, getContext(), root, value);
    154     }
    155
    156 }