aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/analysis/stringtemplate/TemplateContext.java
blob: dc6d27598daa94c1a7b96aee298be042d9a77a29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2017 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.devtools.build.lib.analysis.stringtemplate;

/**
 * Interface to be implemented by callers of {@link TemplateExpander} which defines the expansion of
 * each template variable and function.
 */
public interface TemplateContext {

  /**
   * Returns the expansion of the specified template variable.
   *
   * @param name the variable to expand
   * @return the expansion of the variable
   * @throws ExpansionException if the given variable was not defined or there was any other error
   *     during expansion
   */
  String lookupVariable(String name) throws ExpansionException;

  /**
   * Returns the expansion of the specified template function with the given parameter.
   *
   * @param name the function name
   * @param param the function parameter
   * @return the expansion of the function applied to the parameter
   * @throws ExpansionException if the function was not defined, or if the function application
   *     failed for some reason
   */
  String lookupFunction(String name, String param) throws ExpansionException;
}