Package org.restlet.routing
Class Variable
java.lang.Object
org.restlet.routing.Variable
Variable descriptor for reference templates.
- Author:
- Jerome Louvel
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMatches all characters.static final intMatches all alphabetical characters.static final intMatches all alphabetical and digital characters.static final intMatches any TEXT excluding "(" and ")".static final intMatches any TEXT inside a comment excluding ";".static final intMatches all digital characters.static final intMatches any CHAR except CTLs or separators.static final intMatches all URI characters.static final intMatches URI fragment characters.static final intMatches URI path characters (not the query or the fragment parts).static final intMatches URI query characters.static final intMatches URI query parameter characters (name or value).static final intMatches URI scheme characters.static final intMatches URI segment characters.static final intMatches unreserved URI characters.static final intMatches all alphabetical and digital characters plus the underscore. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAccording to the type of the variable, encodes the value given in parameters.Returns the default value to use if the key couldn't be found in the model.intgetType()Returns the type of variable.booleanIndicates if the parsed value must be decoded.booleanIndicates if the formatted value must be encoded.booleanisFixed()Returns true if the value is fixed, in which case the "defaultValue" property is always used.booleanReturns true if the variable is required or optional.voidsetDecodingOnParse(boolean decodingOnParse) Indicates if the parsed value must be decoded.voidsetDefaultValue(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 Details
-
TYPE_ALL
public static final int TYPE_ALLMatches all characters.- See Also:
-
TYPE_ALPHA
public static final int TYPE_ALPHAMatches all alphabetical characters.- See Also:
-
TYPE_ALPHA_DIGIT
public static final int TYPE_ALPHA_DIGITMatches all alphabetical and digital characters.- See Also:
-
TYPE_COMMENT
public static final int TYPE_COMMENTMatches any TEXT excluding "(" and ")".- See Also:
-
TYPE_COMMENT_ATTRIBUTE
public static final int TYPE_COMMENT_ATTRIBUTEMatches any TEXT inside a comment excluding ";".- See Also:
-
TYPE_DIGIT
public static final int TYPE_DIGITMatches all digital characters.- See Also:
-
TYPE_TOKEN
public static final int TYPE_TOKENMatches any CHAR except CTLs or separators.- See Also:
-
TYPE_URI_ALL
public static final int TYPE_URI_ALLMatches all URI characters.- See Also:
-
TYPE_URI_FRAGMENT
public static final int TYPE_URI_FRAGMENTMatches URI fragment characters.- See Also:
-
TYPE_URI_PATH
public static final int TYPE_URI_PATHMatches URI path characters (not the query or the fragment parts).- See Also:
-
TYPE_URI_QUERY
public static final int TYPE_URI_QUERYMatches URI query characters.- See Also:
-
TYPE_URI_QUERY_PARAM
public static final int TYPE_URI_QUERY_PARAMMatches URI query parameter characters (name or value).- See Also:
-
TYPE_URI_SCHEME
public static final int TYPE_URI_SCHEMEMatches URI scheme characters.- See Also:
-
TYPE_URI_SEGMENT
public static final int TYPE_URI_SEGMENTMatches URI segment characters.- See Also:
-
TYPE_URI_UNRESERVED
public static final int TYPE_URI_UNRESERVEDMatches unreserved URI characters.- See Also:
-
TYPE_WORD
public static final int TYPE_WORDMatches all alphabetical and digital characters plus the underscore.- See Also:
-
-
Constructor Details
-
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
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, 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 Details
-
encode
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
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
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.
-