
public class VariableManager extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
VAR_ERROR |
static String |
VAR_MSG |
| Constructor and Description |
|---|
VariableManager(Properties props)
Creates a VariableManager object using the property list given.
|
| Modifier and Type | Method and Description |
|---|---|
String |
expandVariables(WikiContext context,
String source)
This method does in-place expansion of any variables.
|
String |
getValue(WikiContext context,
String varName)
Returns a value of the named variable.
|
String |
getValue(WikiContext context,
String varName,
String defValue)
Returns the value of a named variable.
|
static boolean |
isVariableLink(String link)
Deprecated.
|
String |
parseAndGetValue(WikiContext context,
String link)
Parses the link and finds a value.
|
public static final String VAR_ERROR
public static final String VAR_MSG
public VariableManager(Properties props)
props - The properties.@Deprecated public static boolean isVariableLink(String link)
LinkParsingOperations.isVariableLink(String)Currently we just check if the link starts with "{$".
link - The link textpublic String parseAndGetValue(WikiContext context, String link) throws IllegalArgumentException, NoSuchVariableException
LinkParsingOperations.isVariableLink(String) has found that
the link text actually contains a variable. For example, you could
pass in "{$username}" and get back "JanneJalkanen".context - The WikiContextlink - The link text containing the variable name.IllegalArgumentException - If the format is not valid (does not
start with "{$", is zero length, etc.)NoSuchVariableException - If a variable is not known.public String expandVariables(WikiContext context, String source)
The variables should be in the same format ({$variablename} as in the web pages.
context - The WikiContext of the current page.source - The source string.public String getValue(WikiContext context, String varName, String defValue)
getValue(WikiContext, String).
The only difference is that this method does not throw an exception, but it
returns the given default value instead.context - WikiContextvarName - The name of the variabledefValue - A default value.public String getValue(WikiContext context, String varName) throws IllegalArgumentException, NoSuchVariableException
context - The WikiContextvarName - Name of the variable.IllegalArgumentException - If the name is somehow broken.NoSuchVariableException - If a variable is not known.Copyright © 2001-2018 The Apache Software Foundation. All rights reserved.