001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.jxpath;
018
019import java.io.Serializable;
020
021/**
022 * Variables provide access to a global set of values accessible via XPath.
023 * XPath can reference variables using the <code>"$varname"</code> syntax.
024 * To use a custom implementation of this interface, pass it to
025 * {@link JXPathContext#setVariables JXPathContext.setVariables()}
026 *
027 * @author Dmitri Plotnikov
028 * @version $Revision: 652925 $ $Date: 2008-05-03 00:05:41 +0200 (Sa, 03 Mai 2008) $
029 */
030public interface Variables extends Serializable {
031
032    /**
033     * Returns true if the specified variable is declared.
034     * @param varName variable name
035     * @return boolean
036     */
037    boolean isDeclaredVariable(String varName);
038
039    /**
040     * Returns the value of the specified variable.
041     * @param varName variable name
042     * @return Object value
043     * @throws IllegalArgumentException if there is no such variable.
044     */
045    Object getVariable(String varName);
046
047    /**
048     * Defines a new variable with the specified value or modifies
049     * the value of an existing variable.
050     * May throw UnsupportedOperationException.
051     * @param varName variable name
052     * @param value to declare
053     */
054    void declareVariable(String varName, Object value);
055
056    /**
057     * Removes an existing variable. May throw UnsupportedOperationException.
058     *
059     * @param varName is a variable name without the "$" sign
060     */
061    void undeclareVariable(String varName);
062}