001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.svl;
014
015import java.io.*;
016
017/**
018 * Abstract superclass of all Simple Var Language variables that resolve to simple returned string values.
019 *
020 * <p>
021 * Note the difference between this class and {@link StreamedVar} that streams values to writers.
022 * <br>Unlike the {@link StreamedVar} class, the returned value from this class can contain nested variables that will be
023 * recursively resolved by {@link VarResolver}.
024 *
025 * <p>
026 * Subclasses must implement the following method:
027 * <ul>
028 *    <li class='jm'>{@link #resolve(VarResolverSession, String)}
029 * </ul>
030 *
031 * <h5 class='section'>See Also:</h5>
032 * <ul>
033 *    <li class='link'>{@doc juneau-svl.SvlVariables}
034 * </ul>
035 */
036public abstract class SimpleVar extends Var {
037
038   /**
039    * Constructor.
040    *
041    * @param name The variable name (e.g. <js>"C"</js> for variables of the form <js>"$C{...}"</js>)
042    */
043   protected SimpleVar(String name) {
044      super(name, false);
045   }
046
047   @Override /* Var */
048   public void resolveTo(VarResolverSession session, Writer w, String arg) throws Exception {
049      throw new UnsupportedOperationException("Cannot call streamTo() on SimpleVar class");
050   }
051}