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.juneau.svl; 018 019import static org.apache.juneau.commons.utils.ThrowableUtils.*; 020 021import java.io.*; 022 023/** 024 * Abstract superclass of all Simple Var Language variables that resolve to simple returned string values. 025 * 026 * <p> 027 * Note the difference between this class and {@link StreamedVar} that streams values to writers. 028 * <br>Unlike the {@link StreamedVar} class, the returned value from this class can contain nested variables that will be 029 * recursively resolved by {@link VarResolver}. 030 * 031 * <p> 032 * Subclasses must implement the following method: 033 * <ul class='javatree'> 034 * <li class='jm'>{@link #resolve(VarResolverSession, String)} 035 * </ul> 036 * 037 * <h5 class='section'>See Also:</h5><ul> 038 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/SimpleVariableLanguageBasics">Simple Variable Language Basics</a> 039 * </ul> 04009 */ 041public abstract class SimpleVar extends Var { 042 043 /** 044 * Constructor. 045 * 046 * @param name The variable name (e.g. <js>"C"</js> for variables of the form <js>"$C{...}"</js>) 047 */ 048 protected SimpleVar(String name) { 049 super(name, false); 050 } 051 052 @Override /* Overridden from Var */ 053 public void resolveTo(VarResolverSession session, Writer w, String arg) throws Exception { 054 throw unsupportedOp("Cannot call streamTo() on SimpleVar class"); 055 } 056}