|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.weborganic.furi.Variable
public class Variable
A variable in a URL pattern or template. The variables can be typed by prefixing the variable name. Types are not required, if no type is specified, the variable is considered untyped. Note: there is no predefined list of types as the handling of types is out of scope. The syntax simply allows variables to be associated with a type. Examples of variables:
foo - An untyped variable named 'foo' bar - An untyped variable named 'bar' ping:foo - A variable named 'foo' typed 'ping' ping:foo=1 - A variable named 'foo' typed 'ping' which default value is '1' foo=pong - An untyped variable named 'foo' which default value is 'pong'Variables only appear in the context of the a template expansion. Expansion rule (4.4.1):
"In a variable ('var') expansion, if the variable is defined then substitute the value of the variable, otherwise substitute the default value. If no default value is given then substitute with the empty string."Syntax for variables:
var = [ vartype ":" ] varname [ "=" vardefault ] vars = var [ *("," var) ] vartype = (ALPHA / DIGIT)* (ALPHA / DIGIT / "." / "_" / "-" ) varname = (ALPHA / DIGIT)* (ALPHA / DIGIT / "." / "_" / "-" ) vardefault = *(unreserved / pct-encoded)
Nested Class Summary | |
---|---|
static class |
Variable.Form
Indicate that the variable's value should be processed as a list ("@") or an associative array ("%"). |
static class |
Variable.Modifier
Indicate that the variable's value should be processed as a list ("@") or an associative array ("%"). |
static class |
Variable.Reserved
Used for reserved variable names. |
Constructor Summary | |
---|---|
Variable(String name)
Creates a new untyped variable. |
|
Variable(String name,
String def)
Creates a new untyped variable. |
|
Variable(String name,
String def,
VariableType type)
Creates a new variable. |
|
Variable(String name,
String def,
VariableType type,
Variable.Form form)
Creates a new variable. |
|
Variable(Variable.Reserved reserved)
Creates a new untyped reserved variable. |
Method Summary | |
---|---|
String |
defaultValue()
Returns the default value for this variable. |
boolean |
equals(Object o)
|
Variable.Form |
form()
Returns the form of this variable. |
int |
hashCode()
|
static boolean |
isValidName(String name)
Indicates whether the variable has a valid name according to the specifications. |
static boolean |
isValidValue(String value)
Indicates whether the variable has a valid value according to the specifications. |
String |
name()
Returns the name of this variable. |
static Variable |
parse(String exp)
Parses the given expression and returns the corresponding instance. |
String |
toString()
|
VariableType |
type()
Returns the implementation type of this variable. |
String |
value(Parameters parameters)
Returns the expanded value of this variable. |
String[] |
values(Parameters parameters)
Returns the expanded value of this variable. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Variable(Variable.Reserved reserved) throws NullPointerException, IllegalArgumentException
reserved
- The name of the variable.
NullPointerException
- If the specified name is null
.
IllegalArgumentException
- If the specified name is an empty string.public Variable(String name) throws NullPointerException, IllegalArgumentException
name
- The name of the variable.
NullPointerException
- If the specified name is null
.
IllegalArgumentException
- If the specified name is an empty string.public Variable(String name, String def) throws NullPointerException, IllegalArgumentException
name
- The name of the variable.def
- The default value for the variable.
NullPointerException
- If the specified name is null
.
IllegalArgumentException
- If the specified name is an empty string.public Variable(String name, String def, VariableType type) throws NullPointerException, IllegalArgumentException
name
- The name of the variable.def
- The default value for the variable.type
- The type of the variable.
NullPointerException
- If the specified name is null
.
IllegalArgumentException
- If the specified name is an empty string.public Variable(String name, String def, VariableType type, Variable.Form form) throws NullPointerException, IllegalArgumentException
name
- The name of the variable.def
- The default value for the variable.type
- The type of the variable.
NullPointerException
- If the specified name is null
.
IllegalArgumentException
- If the specified name is an empty string.Method Detail |
---|
public Variable.Form form()
This method will never return null
.
public String name()
This method never return null
.
public String defaultValue()
null
.
public VariableType type()
This method will return null
if the variable is untyped.
public String value(Parameters parameters)
parameters
- The parameters.
public String[] values(Parameters parameters)
parameters
- The parameters.
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
public static Variable parse(String exp) throws URITemplateSyntaxException
exp
- The expression to parse.
URITemplateSyntaxException
- If the expression cannot be parsedpublic static boolean isValidName(String name)
name
- The name of the variable.
true
if the name is valid; false
otherwise.public static boolean isValidValue(String value)
value
- The value of the variable.
true
if the name is not valid; false
otherwise.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |