com.ecyrd.jspwiki
Class VariableManager

java.lang.Object
  |
  +--com.ecyrd.jspwiki.VariableManager

public class VariableManager
extends java.lang.Object

Manages variables. Variables are case-insensitive. A list of all available variables is on a Wiki page called "WikiVariables".

Since:
1.9.20.
Author:
Janne Jalkanen

Constructor Summary
VariableManager(java.util.Properties props)
           
 
Method Summary
 java.lang.String expandVariables(WikiContext context, java.lang.String source)
          This method does in-place expansion of any variables.
 java.lang.String getValue(WikiContext context, java.lang.String varName)
          Returns a value of the named variable.
static boolean isVariableLink(java.lang.String link)
          Returns true if the link is really command to insert a variable.
 java.lang.String parseAndGetValue(WikiContext context, java.lang.String link)
          Parses the link and finds a value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VariableManager

public VariableManager(java.util.Properties props)
Method Detail

isVariableLink

public static boolean isVariableLink(java.lang.String link)
Returns true if the link is really command to insert a variable.

Currently we just check if the link starts with "{$".


parseAndGetValue

public java.lang.String parseAndGetValue(WikiContext context,
                                         java.lang.String link)
                                  throws java.lang.IllegalArgumentException,
                                         NoSuchVariableException
Parses the link and finds a value.

A variable is inserted using the notation [{$variablename}].

Throws:
java.lang.IllegalArgumentException - If the format is not valid (does not start with {$, is zero length, etc.)
NoSuchVariableException - If a variable is not known.

expandVariables

public java.lang.String expandVariables(WikiContext context,
                                        java.lang.String source)
This method does in-place expansion of any variables. However, the expansion is not done twice, that is, a variable containing text $variable will not be expanded.

The variables should be in the same format ({$variablename} as in the web pages.

Parameters:
context - The WikiContext of the current page.
source - The source string.

getValue

public java.lang.String getValue(WikiContext context,
                                 java.lang.String varName)
                          throws java.lang.IllegalArgumentException,
                                 NoSuchVariableException
Returns a value of the named variable.

Parameters:
varName - Name of the variable.
Throws:
java.lang.IllegalArgumentException - If the name is somehow broken.
NoSuchVariableException - If a variable is not known.