public final class Variable
extends java.lang.Object
Template
Modifier and Type | Field and Description |
---|---|
static int |
TYPE_ALL
Matches all characters.
|
static int |
TYPE_ALPHA
Matches all alphabetical characters.
|
static int |
TYPE_ALPHA_DIGIT
Matches all alphabetical and digital characters.
|
static int |
TYPE_COMMENT
Matches any TEXT excluding "(" and ")".
|
static int |
TYPE_COMMENT_ATTRIBUTE
Matches any TEXT inside a comment excluding ";".
|
static int |
TYPE_DIGIT
Matches all digital characters.
|
static int |
TYPE_TOKEN
Matches any CHAR except CTLs or separators.
|
static int |
TYPE_URI_ALL
Matches all URI characters.
|
static int |
TYPE_URI_FRAGMENT
Matches URI fragment characters.
|
static int |
TYPE_URI_PATH
Matches URI path characters (not the query or the fragment parts).
|
static int |
TYPE_URI_QUERY
Matches URI query characters.
|
static int |
TYPE_URI_QUERY_PARAM
Matches URI query parameter characters (name or value).
|
static int |
TYPE_URI_SCHEME
Matches URI scheme characters.
|
static int |
TYPE_URI_SEGMENT
Matches URI segment characters.
|
static int |
TYPE_URI_UNRESERVED
Matches unreserved URI characters.
|
static int |
TYPE_WORD
Matches all alphabetical and digital characters plus the underscore.
|
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
encode(java.lang.String value)
According to the type of the variable, encodes the value given in
parameters.
|
java.lang.String |
getDefaultValue()
Returns the default value to use if the key couldn't be found in the
model.
|
int |
getType()
Returns the type of variable.
|
boolean |
isDecodingOnParse()
Indicates if the parsed value must be decoded.
|
boolean |
isEncodingOnFormat()
Indicates if the formatted value must be encoded.
|
boolean |
isFixed()
Returns true if the value is fixed, in which case the "defaultValue"
property is always used.
|
boolean |
isRequired()
Returns true if the variable is required or optional.
|
void |
setDecodingOnParse(boolean decodingOnParse)
Indicates if the parsed value must be decoded.
|
void |
setDefaultValue(java.lang.String defaultValue)
Sets the default value to use if the key couldn't be found in the model.
|
void |
setEncodingOnFormat(boolean encodingOnFormat)
Indicates if the formatted value must be encoded.
|
void |
setFixed(boolean fixed)
Indicates if the value is fixed
|
void |
setRequired(boolean required)
Indicates if the variable is required or optional.
|
void |
setType(int type)
Sets the type of variable.
|
public static final int TYPE_ALL
public static final int TYPE_ALPHA
public static final int TYPE_ALPHA_DIGIT
public static final int TYPE_COMMENT
public static final int TYPE_COMMENT_ATTRIBUTE
public static final int TYPE_DIGIT
public static final int TYPE_TOKEN
public static final int TYPE_URI_ALL
public static final int TYPE_URI_FRAGMENT
public static final int TYPE_URI_PATH
public static final int TYPE_URI_QUERY
public static final int TYPE_URI_QUERY_PARAM
public static final int TYPE_URI_SCHEME
public static final int TYPE_URI_SEGMENT
public static final int TYPE_URI_UNRESERVED
public static final int TYPE_WORD
public Variable()
public Variable(int type)
type
- The type of variable. See TYPE_* constants.public Variable(int type, java.lang.String defaultValue, boolean required, boolean fixed)
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.public Variable(int type, java.lang.String defaultValue, boolean required, boolean fixed, boolean decodingOnParse, boolean encodingOnFormat)
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.public java.lang.String encode(java.lang.String value)
value
- The value to encode.public java.lang.String getDefaultValue()
public int getType()
public boolean isDecodingOnParse()
public boolean isEncodingOnFormat()
public boolean isFixed()
public boolean isRequired()
public void setDecodingOnParse(boolean decodingOnParse)
decodingOnParse
- True if the parsed value must be decoded, false otherwise.public void setDefaultValue(java.lang.String defaultValue)
defaultValue
- The default value to use if the key couldn't be found in the
model.public void setEncodingOnFormat(boolean encodingOnFormat)
encodingOnFormat
- True if the formatted value must be encoded, false otherwise.public void setFixed(boolean fixed)
fixed
- True if the value is fixedpublic void setRequired(boolean required)
required
- True if the variable is required or optional.public void setType(int type)
type
- The type of variable.Copyright © 2005-2024 Restlet.