View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.scxml;
18  
19  import org.w3c.dom.Node;
20  
21  /***
22   * Interface for a component that may be used by the SCXML engines to
23   * evaluate the expressions within the SCXML document.
24   *
25   */
26  public interface Evaluator {
27  
28      /***
29       * Evaluate an expression.
30       *
31       * @param ctx variable context
32       * @param expr expression
33       * @return a result of the evaluation
34       * @throws SCXMLExpressionException A malformed exception
35       */
36      Object eval(Context ctx, String expr)
37      throws SCXMLExpressionException;
38  
39      /***
40       * Evaluate a condition.
41       * Manifests as "cond" attributes of <transition>,
42       * <if> and <elseif> elements.
43       *
44       * @param ctx variable context
45       * @param expr expression
46       * @return true/false
47       * @throws SCXMLExpressionException A malformed exception
48       */
49      Boolean evalCond(Context ctx, String expr)
50      throws SCXMLExpressionException;
51  
52      /***
53       * Evaluate a location that returns a Node within an XML data tree.
54       * Manifests as "location" attributes of <assign> element.
55       *
56       * @param ctx variable context
57       * @param expr expression
58       * @return The location node.
59       * @throws SCXMLExpressionException A malformed exception
60       */
61      Node evalLocation(Context ctx, String expr)
62      throws SCXMLExpressionException;
63  
64      /***
65       * Create a new child context.
66       *
67       * @param parent parent context
68       * @return new child context
69       */
70      Context newContext(Context parent);
71  
72  }
73