Package org.restlet.routing
Class Variable
- java.lang.Object
 - 
- org.restlet.routing.Variable
 
 
- 
public final class Variable extends java.lang.ObjectVariable descriptor for reference templates.- Author:
 - Jerome Louvel
 - See Also:
 Template
 
- 
- 
Field Summary
Fields Modifier and Type Field Description static intTYPE_ALLMatches all characters.static intTYPE_ALPHAMatches all alphabetical characters.static intTYPE_ALPHA_DIGITMatches all alphabetical and digital characters.static intTYPE_COMMENTMatches any TEXT excluding "(" and ")".static intTYPE_COMMENT_ATTRIBUTEMatches any TEXT inside a comment excluding ";".static intTYPE_DIGITMatches all digital characters.static intTYPE_TOKENMatches any CHAR except CTLs or separators.static intTYPE_URI_ALLMatches all URI characters.static intTYPE_URI_FRAGMENTMatches URI fragment characters.static intTYPE_URI_PATHMatches URI path characters (not the query or the fragment parts).static intTYPE_URI_QUERYMatches URI query characters.static intTYPE_URI_QUERY_PARAMMatches URI query parameter characters (name or value).static intTYPE_URI_SCHEMEMatches URI scheme characters.static intTYPE_URI_SEGMENTMatches URI segment characters.static intTYPE_URI_UNRESERVEDMatches unreserved URI characters.static intTYPE_WORDMatches all alphabetical and digital characters plus the underscore. 
- 
Constructor Summary
Constructors Constructor Description Variable()Default constructor.Variable(int type)Constructor.Variable(int type, java.lang.String defaultValue, boolean required, boolean fixed)Constructor.Variable(int type, java.lang.String defaultValue, boolean required, boolean fixed, boolean decodingOnParse, boolean encodingOnFormat)Constructor. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringencode(java.lang.String value)According to the type of the variable, encodes the value given in parameters.java.lang.StringgetDefaultValue()Returns the default value to use if the key couldn't be found in the model.intgetType()Returns the type of variable.booleanisDecodingOnParse()Indicates if the parsed value must be decoded.booleanisEncodingOnFormat()Indicates if the formatted value must be encoded.booleanisFixed()Returns true if the value is fixed, in which case the "defaultValue" property is always used.booleanisRequired()Returns true if the variable is required or optional.voidsetDecodingOnParse(boolean decodingOnParse)Indicates if the parsed value must be decoded.voidsetDefaultValue(java.lang.String defaultValue)Sets the default value to use if the key couldn't be found in the model.voidsetEncodingOnFormat(boolean encodingOnFormat)Indicates if the formatted value must be encoded.voidsetFixed(boolean fixed)Indicates if the value is fixedvoidsetRequired(boolean required)Indicates if the variable is required or optional.voidsetType(int type)Sets the type of variable. 
 - 
 
- 
- 
Field Detail
- 
TYPE_ALL
public static final int TYPE_ALL
Matches all characters.- See Also:
 - Constant Field Values
 
 
- 
TYPE_ALPHA
public static final int TYPE_ALPHA
Matches all alphabetical characters.- See Also:
 - Constant Field Values
 
 
- 
TYPE_ALPHA_DIGIT
public static final int TYPE_ALPHA_DIGIT
Matches all alphabetical and digital characters.- See Also:
 - Constant Field Values
 
 
- 
TYPE_COMMENT
public static final int TYPE_COMMENT
Matches any TEXT excluding "(" and ")".- See Also:
 - Constant Field Values
 
 
- 
TYPE_COMMENT_ATTRIBUTE
public static final int TYPE_COMMENT_ATTRIBUTE
Matches any TEXT inside a comment excluding ";".- See Also:
 - Constant Field Values
 
 
- 
TYPE_DIGIT
public static final int TYPE_DIGIT
Matches all digital characters.- See Also:
 - Constant Field Values
 
 
- 
TYPE_TOKEN
public static final int TYPE_TOKEN
Matches any CHAR except CTLs or separators.- See Also:
 - Constant Field Values
 
 
- 
TYPE_URI_ALL
public static final int TYPE_URI_ALL
Matches all URI characters.- See Also:
 - Constant Field Values
 
 
- 
TYPE_URI_FRAGMENT
public static final int TYPE_URI_FRAGMENT
Matches URI fragment characters.- See Also:
 - Constant Field Values
 
 
- 
TYPE_URI_PATH
public static final int TYPE_URI_PATH
Matches URI path characters (not the query or the fragment parts).- See Also:
 - Constant Field Values
 
 
- 
TYPE_URI_QUERY
public static final int TYPE_URI_QUERY
Matches URI query characters.- See Also:
 - Constant Field Values
 
 
- 
TYPE_URI_QUERY_PARAM
public static final int TYPE_URI_QUERY_PARAM
Matches URI query parameter characters (name or value).- See Also:
 - Constant Field Values
 
 
- 
TYPE_URI_SCHEME
public static final int TYPE_URI_SCHEME
Matches URI scheme characters.- See Also:
 - Constant Field Values
 
 
- 
TYPE_URI_SEGMENT
public static final int TYPE_URI_SEGMENT
Matches URI segment characters.- See Also:
 - Constant Field Values
 
 
- 
TYPE_URI_UNRESERVED
public static final int TYPE_URI_UNRESERVED
Matches unreserved URI characters.- See Also:
 - Constant Field Values
 
 
- 
TYPE_WORD
public static final int TYPE_WORD
Matches all alphabetical and digital characters plus the underscore.- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Constructor Detail
- 
Variable
public Variable()
Default constructor. Type is TYPE_ALL, default value is "", required is true and fixed is false. 
- 
Variable
public Variable(int type)
Constructor. Default value is "", required is true and fixed is false.- Parameters:
 type- The type of variable. See TYPE_* constants.
 
- 
Variable
public Variable(int type, java.lang.String defaultValue, boolean required, boolean fixed)Constructor.- Parameters:
 type- The type of variable. See TYPE_* constants.defaultValue- The default value to use if the key couldn't be found in the model.required- Indicates if the variable is required or optional.fixed- Indicates if the value is fixed, in which case the "defaultValue" property is always used.
 
- 
Variable
public Variable(int type, java.lang.String defaultValue, boolean required, boolean fixed, boolean decodingOnParse, boolean encodingOnFormat)Constructor.- Parameters:
 type- The type of variable. See TYPE_* constants.defaultValue- The default value to use if the key couldn't be found in the model.required- Indicates if the variable is required or optional.fixed- Indicates if the value is fixed, in which case the "defaultValue" property is always used.decodingOnParse- Indicates if the parsed value must be decoded.encodingOnFormat- Indicates if the formatted value must be encoded.
 
 - 
 
- 
Method Detail
- 
encode
public java.lang.String encode(java.lang.String value)
According to the type of the variable, encodes the value given in parameters.- Parameters:
 value- The value to encode.- Returns:
 - The encoded value, according to the variable type.
 
 
- 
getDefaultValue
public java.lang.String getDefaultValue()
Returns the default value to use if the key couldn't be found in the model.- Returns:
 - The default value to use if the key couldn't be found in the model.
 
 
- 
getType
public int getType()
Returns the type of variable. See TYPE_* constants.- Returns:
 - The type of variable. See TYPE_* constants.
 
 
- 
isDecodingOnParse
public boolean isDecodingOnParse()
Indicates if the parsed value must be decoded.- Returns:
 - True if the parsed value must be decoded, false otherwise.
 
 
- 
isEncodingOnFormat
public boolean isEncodingOnFormat()
Indicates if the formatted value must be encoded.- Returns:
 - True if the formatted value must be encoded, false otherwise.
 
 
- 
isFixed
public boolean isFixed()
Returns true if the value is fixed, in which case the "defaultValue" property is always used.- Returns:
 - True if the value is fixed, in which case the "defaultValue" property is always used.
 
 
- 
isRequired
public boolean isRequired()
Returns true if the variable is required or optional.- Returns:
 - True if the variable is required or optional.
 
 
- 
setDecodingOnParse
public void setDecodingOnParse(boolean decodingOnParse)
Indicates if the parsed value must be decoded.- Parameters:
 decodingOnParse- True if the parsed value must be decoded, false otherwise.
 
- 
setDefaultValue
public void setDefaultValue(java.lang.String defaultValue)
Sets the default value to use if the key couldn't be found in the model.- Parameters:
 defaultValue- The default value to use if the key couldn't be found in the model.
 
- 
setEncodingOnFormat
public void setEncodingOnFormat(boolean encodingOnFormat)
Indicates if the formatted value must be encoded.- Parameters:
 encodingOnFormat- True if the formatted value must be encoded, false otherwise.
 
- 
setFixed
public void setFixed(boolean fixed)
Indicates if the value is fixed- Parameters:
 fixed- True if the value is fixed
 
- 
setRequired
public void setRequired(boolean required)
Indicates if the variable is required or optional.- Parameters:
 required- True if the variable is required or optional.
 
- 
setType
public void setType(int type)
Sets the type of variable. See TYPE_* constants.- Parameters:
 type- The type of variable.
 
 - 
 
 -