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 021/** 022 * Abstract superclass of all Simple Var Language variables that write their values directly to a writer. 023 * 024 * <p> 025 * Note the difference between this class and {@link SimpleVar} that returns simple string values. 026 * <br>Unlike the {@link SimpleVar} class, the output from this class cannot contain nested variables. 027 * <br>However, this class can be more efficient for variables that produce large amounts of output so that the creation 028 * of large in-memory strings is avoided. 029 * 030 * <p> 031 * Subclasses must implement the following method: 032 * <ul class='javatree'> 033 * <li class='jm'>{@link #resolveTo(VarResolverSession, java.io.Writer, String)} 034 * </ul> 035 * 036 * <h5 class='section'>See Also:</h5><ul> 037 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/SimpleVariableLanguageBasics">Simple Variable Language Basics</a> 038 * </ul> 039 */ 040public abstract class StreamedVar extends Var { 041 042 /** 043 * Constructor. 044 * 045 * @param name The variable name (e.g. <js>"C"</js> for variables of the form <js>"$C{...}"</js>) 046 */ 047 public StreamedVar(String name) { 048 super(name, true); 049 } 050 051 @Override /* Overridden from Var */ 052 public String resolve(VarResolverSession session, String arg) throws Exception { 053 throw unsupportedOp("Cannot call resolve() on StreamedVar class"); 054 } 055}