hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-hivemind/framework/src/test/org/apache/hivemind/conditional TestEvaluationContext.java TestNode.java TestEvaluators.java
Date Wed, 29 Dec 2004 21:09:17 GMT
hlship      2004/12/29 13:09:17

  Modified:    framework/src/test/org/apache/hivemind/conditional
                        TestEvaluationContext.java TestNode.java
                        TestEvaluators.java
  Added:       framework/src/java/org/apache/hivemind/conditional
                        NotEvaluator.java Node.java OrEvaluator.java
                        PropertyEvaluator.java ClassNameEvaluator.java
                        Evaluator.java EvaluationContext.java
                        EvaluationContextImpl.java NodeImpl.java
                        AndEvaluator.java
  Removed:     framework/src/javacc SimpleDataLanguageParser.jj
               framework/src/java/org/apache/hivemind/condtional
                        NotEvaluator.java Evaluator.java NodeImpl.java
                        PropertyEvaulator.java OrEvaluator.java
                        EvaluationContext.java EvaluationContextImpl.java
                        ClassNameEvaluator.java AndEvaluator.java Node.java
  Log:
  Fix typo in package name for conditional classes.
  
  Revision  Changes    Path
  1.1                  jakarta-hivemind/framework/src/java/org/apache/hivemind/conditional/NotEvaluator.java
  
  Index: NotEvaluator.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.conditional;
  
  /**
   * Evaluates the left child of its peer Node and inverts the result.
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public class NotEvaluator implements Evaluator
  {
      public boolean evaluate(EvaluationContext context, Node node)
      {
          return !node.getLeft().evaluate(context);
      }
  }
  
  
  1.1                  jakarta-hivemind/framework/src/java/org/apache/hivemind/conditional/Node.java
  
  Index: Node.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.conditional;
  
  /**
   * An AST node in the tree parsed from the conditional expression. Nodes form a binary tree,
each
   * node may have a left and a right sub-node.
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public interface Node
  {
      public Node getLeft();
  
      public Node getRight();
  
      /**
       * Evaluates the nodes using the context to provide access to runtime information.
       */
      public boolean evaluate(EvaluationContext context);
  }
  
  
  1.1                  jakarta-hivemind/framework/src/java/org/apache/hivemind/conditional/OrEvaluator.java
  
  Index: OrEvaluator.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.conditional;
  
  /**
   * Or operation, returns true if either left or right Node evaluates to true.
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public class OrEvaluator implements Evaluator
  {
  
      public boolean evaluate(EvaluationContext context, Node node)
      {
          return node.getLeft().evaluate(context) || node.getRight().evaluate(context);
      }
  
  }
  
  
  1.1                  jakarta-hivemind/framework/src/java/org/apache/hivemind/conditional/PropertyEvaluator.java
  
  Index: PropertyEvaluator.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.conditional;
  
  import org.apache.hivemind.Defense;
  
  /**
   * Evaluates a system property and returns true if its value is true.
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public class PropertyEvaluator implements Evaluator
  {
      private String _propertyName;
  
      public PropertyEvaluator(String propertyName)
      {
          Defense.notNull(propertyName, "propertyName");
  
          _propertyName = propertyName;
      }
  
      /**
       * Invokes {@link org.apache.hivemind.conditional.EvaluationContext#isPropertySet(String)}.
       */
      public boolean evaluate(EvaluationContext context, Node node)
      {
          return context.isPropertySet(_propertyName);
      }
  
  }
  
  
  1.1                  jakarta-hivemind/framework/src/java/org/apache/hivemind/conditional/ClassNameEvaluator.java
  
  Index: ClassNameEvaluator.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.conditional;
  
  import org.apache.hivemind.Defense;
  
  /**
   * Evaluator for a fully qualified class name.
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public class ClassNameEvaluator implements Evaluator
  {
      private String _className;
  
      public ClassNameEvaluator(String className)
      {
          Defense.notNull(className, "className");
  
          _className = className;
      }
  
      public boolean evaluate(EvaluationContext context, Node node)
      {
          return context.doesClassExist(_className);
      }
  
  }
  
  
  1.1                  jakarta-hivemind/framework/src/java/org/apache/hivemind/conditional/Evaluator.java
  
  Index: Evaluator.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.conditional;
  
  /**
   * An evaluator is paired with a {@link Node}. The Node provides structure, the Evaluator
provides
   * meaning, interpreting the node.
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public interface Evaluator
  {
      /**
       * Invoked by the Node to evaluate its own value. Typical implementations will extract
the
       * Node's {@link org.apache.hivemind.conditional.Node#getLeft() left}  and
       * {@link org.apache.hivemind.conditional.Node#getRight() right}&nbsp properties
and combine or
       * otherwise evaluate them. Terminal nodes in the tree will have evaluators that don't
do that
       * but generate a return value internally.
       */
  
      public boolean evaluate(EvaluationContext context, Node node);
  }
  
  
  1.1                  jakarta-hivemind/framework/src/java/org/apache/hivemind/conditional/EvaluationContext.java
  
  Index: EvaluationContext.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.conditional;
  
  /**
   * Provides context when evaluating an AST of {@link org.apache.hivemind.conditional.Node}s.
   * Effectively, a wrapper around certain runtime operations.
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public interface EvaluationContext
  {
      /**
       * Returns true if the given system property is set.
       */
  
      public boolean isPropertySet(String propertyName);
      
      /**
       * Returns true if the class, specified by FQCN, exists.
       * 
       */
      
      public boolean doesClassExist(String className);
  }
  
  
  1.1                  jakarta-hivemind/framework/src/java/org/apache/hivemind/conditional/EvaluationContextImpl.java
  
  Index: EvaluationContextImpl.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.conditional;
  
  import org.apache.hivemind.ApplicationRuntimeException;
  import org.apache.hivemind.ClassResolver;
  import org.apache.hivemind.Defense;
  
  /**
   * @author Howard M. Lewis Ship
   */
  public class EvaluationContextImpl implements EvaluationContext
  {
      private ClassResolver _resolver;
  
      public EvaluationContextImpl(ClassResolver resolver)
      {
          Defense.notNull(resolver, "resolver");
  
          _resolver = resolver;
      }
  
      public boolean isPropertySet(String propertyName)
      {
          return Boolean.getBoolean(propertyName);
      }
  
      public boolean doesClassExist(String className)
      {
          try
          {
              _resolver.findClass(className);
  
              return true;
          }
          catch (ApplicationRuntimeException ex)
          {
              return false;
          }
      }
  
  }
  
  
  1.1                  jakarta-hivemind/framework/src/java/org/apache/hivemind/conditional/NodeImpl.java
  
  Index: NodeImpl.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.conditional;
  
  import org.apache.hivemind.Defense;
  
  /**
   * Implementation of {@link org.apache.hivemind.conditional.Node}.
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public class NodeImpl implements Node
  {
      private Node _left;
  
      private Node _right;
  
      private Evaluator _evaluator;
  
      public NodeImpl(Node left, Node right, Evaluator evaluator)
      {
          Defense.notNull(evaluator, "evaluator");
  
          _left = left;
          _right = right;
          _evaluator = evaluator;
      }
  
      /**
       * Alternate constructor used for terminal nodes.
       */
  
      public NodeImpl(Evaluator evaluator)
      {
          this(null, null, evaluator);
      }
  
      public Node getLeft()
      {
          return _left;
      }
  
      public Node getRight()
      {
          return _right;
      }
  
      public boolean evaluate(EvaluationContext context)
      {
          return _evaluator.evaluate(context, this);
      }
  
  }
  
  
  1.1                  jakarta-hivemind/framework/src/java/org/apache/hivemind/conditional/AndEvaluator.java
  
  Index: AndEvaluator.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.conditional;
  
  /**
   * And operation, evaluates the left node and then (perhaps) the right node (short circuiting
may
   * take place).
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public class AndEvaluator implements Evaluator
  {
      public boolean evaluate(EvaluationContext context, Node node)
      {
          return node.getLeft().evaluate(context) && node.getRight().evaluate(context);
      }
  
  }
  
  
  1.3       +3 -3      jakarta-hivemind/framework/src/test/org/apache/hivemind/conditional/TestEvaluationContext.java
  
  Index: TestEvaluationContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/org/apache/hivemind/conditional/TestEvaluationContext.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestEvaluationContext.java	21 Dec 2004 09:43:47 -0000	1.2
  +++ TestEvaluationContext.java	29 Dec 2004 21:09:17 -0000	1.3
  @@ -14,13 +14,13 @@
   
   package org.apache.hivemind.conditional;
   
  -import org.apache.hivemind.condtional.EvaluationContext;
  -import org.apache.hivemind.condtional.EvaluationContextImpl;
  +import org.apache.hivemind.conditional.EvaluationContext;
  +import org.apache.hivemind.conditional.EvaluationContextImpl;
   import org.apache.hivemind.impl.DefaultClassResolver;
   import org.apache.hivemind.test.HiveMindTestCase;
   
   /**
  - * Tests for {@link org.apache.hivemind.condtional.EvaluationContextImpl}.
  + * Tests for {@link org.apache.hivemind.conditional.EvaluationContextImpl}.
    * 
    * @author Howard M. Lewis Ship
    */
  
  
  
  1.3       +5 -5      jakarta-hivemind/framework/src/test/org/apache/hivemind/conditional/TestNode.java
  
  Index: TestNode.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/org/apache/hivemind/conditional/TestNode.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestNode.java	28 Dec 2004 22:43:15 -0000	1.2
  +++ TestNode.java	29 Dec 2004 21:09:17 -0000	1.3
  @@ -14,15 +14,15 @@
   
   package org.apache.hivemind.conditional;
   
  -import org.apache.hivemind.condtional.EvaluationContext;
  -import org.apache.hivemind.condtional.Evaluator;
  -import org.apache.hivemind.condtional.Node;
  -import org.apache.hivemind.condtional.NodeImpl;
  +import org.apache.hivemind.conditional.EvaluationContext;
  +import org.apache.hivemind.conditional.Evaluator;
  +import org.apache.hivemind.conditional.Node;
  +import org.apache.hivemind.conditional.NodeImpl;
   import org.apache.hivemind.test.HiveMindTestCase;
   import org.easymock.MockControl;
   
   /**
  - * Tests for the {@link org.apache.hivemind.condtional.NodeImpl}class.
  + * Tests for the {@link org.apache.hivemind.conditional.NodeImpl}class.
    * 
    * @author Howard M. Lewis Ship
    * @since 1.1
  
  
  
  1.2       +10 -10    jakarta-hivemind/framework/src/test/org/apache/hivemind/conditional/TestEvaluators.java
  
  Index: TestEvaluators.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/org/apache/hivemind/conditional/TestEvaluators.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestEvaluators.java	19 Dec 2004 15:42:45 -0000	1.1
  +++ TestEvaluators.java	29 Dec 2004 21:09:17 -0000	1.2
  @@ -14,19 +14,19 @@
   
   package org.apache.hivemind.conditional;
   
  -import org.apache.hivemind.condtional.AndEvaluator;
  -import org.apache.hivemind.condtional.ClassNameEvaluator;
  -import org.apache.hivemind.condtional.EvaluationContext;
  -import org.apache.hivemind.condtional.Node;
  -import org.apache.hivemind.condtional.NodeImpl;
  -import org.apache.hivemind.condtional.NotEvaluator;
  -import org.apache.hivemind.condtional.OrEvaluator;
  -import org.apache.hivemind.condtional.PropertyEvaulator;
  +import org.apache.hivemind.conditional.AndEvaluator;
  +import org.apache.hivemind.conditional.ClassNameEvaluator;
  +import org.apache.hivemind.conditional.EvaluationContext;
  +import org.apache.hivemind.conditional.Node;
  +import org.apache.hivemind.conditional.NodeImpl;
  +import org.apache.hivemind.conditional.NotEvaluator;
  +import org.apache.hivemind.conditional.OrEvaluator;
  +import org.apache.hivemind.conditional.PropertyEvaluator;
   import org.apache.hivemind.test.HiveMindTestCase;
   import org.easymock.MockControl;
   
   /**
  - * Tests for {@link org.apache.hivemind.condtional.PropertyEvaulator}.
  + * Tests for {@link org.apache.hivemind.conditional.PropertyEvaluator}.
    * 
    * @author Howard M. Lewis Ship
    * @since 1.1
  @@ -65,7 +65,7 @@
   
           replayControls();
   
  -        PropertyEvaulator pe = new PropertyEvaulator("foo.bar");
  +        PropertyEvaluator pe = new PropertyEvaluator("foo.bar");
   
           assertEquals(true, pe.evaluate(context, null));
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org


Mime
View raw message