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 static org.apache.juneau.internal.StringUtils.*; 016 017/** 018 * Interface for the resolution of vars that consist of a comma-delimited list. 019 * 020 * <h5 class='figure'>Example:</h5> 021 * <p class='bcode'> 022 * <js>"$X{foo, bar, baz}"</js> 023 * </p> 024 * 025 * <h5 class='section'>See Also:</h5> 026 * <ul> 027 * <li class='link'><a class="doclink" href="../../../../overview-summary.html#juneau-svl.SvlVariables">Overview > juneau-svl > SVL Variables</a> 028 * </ul> 029 */ 030public abstract class MultipartVar extends SimpleVar { 031 032 /** 033 * Constructor. 034 * 035 * @param name The name of this variable. 036 */ 037 public MultipartVar(String name) { 038 super(name); 039 } 040 041 /** 042 * The interface that needs to be implemented for this interface. 043 * 044 * @param session The session object used for a single instance of a string resolution. 045 * @param args The arguments inside the variable. 046 * @return The resolved variable. 047 */ 048 public abstract String resolve(VarResolverSession session, String[] args); 049 050 @Override /* Var */ 051 public String resolve(VarResolverSession session, String s) { 052 String[] s2 = s.indexOf(',') == -1 ? new String[]{s.trim()} : split(s); 053 return resolve(session, s2); 054 } 055}