commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/resolver FlatResolver.java
Date Thu, 13 Jun 2002 16:10:44 GMT
geirm       2002/06/13 09:10:44

  Added:       jexl/src/java/org/apache/commons/jexl/resolver
                        FlatResolver.java
  Log:
  resolver that just looks up the data from the context w/o regard to
  structure
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/resolver/FlatResolver.java
  
  Index: FlatResolver.java
  ===================================================================
  package org.apache.commons.jexl.resolver;
  
  import org.apache.commons.jexl.JexlExprResolver;
  import org.apache.commons.jexl.JexlContext;
  
  /**
   *  Simple resolver to try the expression as-is from the context.
   *
   *  For example, you could resolve ant-ish properties (foo.bar.woogie)
   *  using this...
   *
   *  hint, hint...
   *
   *  @author <a href="mailto:geirm@adeptra.com">Geir Magnusson Jr.</a>
   *  @version $Id: FlatResolver.java,v 1.1 2002/06/13 16:10:44 geirm Exp $
   */
  public class FlatResolver implements JexlExprResolver
  {
      /**
       *  flag to return NO_VALUE on null from context
       *  this allows jexl to try to evaluate
       */
      protected boolean noValOnNull = true;
  
      /**
       * default CTOR
       */
      public FlatResolver()
      {
      }
  
      /**
       *  CTOR that lets you override the default behavior of
       *  noValOnNull, which is true (jexl gets a shot after if null)
       */
      public FlatResolver(boolean noValOnNull)
      {
          this.noValOnNull = noValOnNull;
      }
  
      public Object evaluate(JexlContext context, String expression)
      {
          Object val = context.getVars().get(expression);
  
          if (val == null && noValOnNull)
          {
              return JexlExprResolver.NO_VALUE;
          }
  
          return val;
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message