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.jxpath;
18  
19  import java.io.Serializable;
20  
21  /**
22   * Variables provide access to a global set of values accessible via XPath.
23   * XPath can reference variables using the <code>"$varname"</code> syntax.
24   * To use a custom implementation of this interface, pass it to
25   * {@link JXPathContext#setVariables JXPathContext.setVariables()}
26   *
27   * @author Dmitri Plotnikov
28   * @version $Revision: 652925 $ $Date: 2008-05-03 00:05:41 +0200 (Sa, 03 Mai 2008) $
29   */
30  public interface Variables extends Serializable {
31  
32      /**
33       * Returns true if the specified variable is declared.
34       * @param varName variable name
35       * @return boolean
36       */
37      boolean isDeclaredVariable(String varName);
38  
39      /**
40       * Returns the value of the specified variable.
41       * @param varName variable name
42       * @return Object value
43       * @throws IllegalArgumentException if there is no such variable.
44       */
45      Object getVariable(String varName);
46  
47      /**
48       * Defines a new variable with the specified value or modifies
49       * the value of an existing variable.
50       * May throw UnsupportedOperationException.
51       * @param varName variable name
52       * @param value to declare
53       */
54      void declareVariable(String varName, Object value);
55  
56      /**
57       * Removes an existing variable. May throw UnsupportedOperationException.
58       *
59       * @param varName is a variable name without the "$" sign
60       */
61      void undeclareVariable(String varName);
62  }