    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 */
    017
    018package org.apache.commons.jxpath;
    019
    020import java.io.Serializable;
    021
    022/**
    023 * Variables provide access to a global set of values accessible via XPath. XPath can reference variables using the {@code "$varname"} syntax. To use a custom
    024 * implementation of this interface, pass it to {@link JXPathContext#setVariables JXPathContext.setVariables()}
    025 */
    026public interface Variables extends Serializable {
    027
    028    /**
    029     * Defines a new variable with the specified value or modifies the value of an existing variable. May throw UnsupportedOperationException.
    030     *
    031     * @param name variable name
    032     * @param value   to declare
    033     */
    034    void declareVariable(String name, Object value);
    035
    036    /**
    037     * Returns the value of the specified variable.
    038     *
    039     * @param name variable name
    040     * @return Object value
    041     * @throws IllegalArgumentException if there is no such variable.
    042     */
    043    Object getVariable(String name);
    044
    045    /**
    046     * Returns true if the specified variable is declared.
    047     *
    048     * @param name variable name
    049     * @return boolean
    050     */
    051    boolean isDeclaredVariable(String name);
    052
    053    /**
    054     * Removes an existing variable. May throw UnsupportedOperationException.
    055     *
    056     * @param name is a variable name without the "$" sign
    057     */
    058    void undeclareVariable(String name);
    059}