org.restlet.util
Class Variable

java.lang.Object
  extended by org.restlet.util.Variable

public final class Variable
extends java.lang.Object

Variable descriptor for reference templates.

Author:
Jerome Louvel
See Also:
Template

Field Summary
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_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 Summary
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 decodedOnParse, boolean encodedOnFormat)
          Constructor.
 
Method Summary
 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 isDecodedOnParse()
          Indicates if the parsed value must be decoded.
 boolean isEncodedOnFormat()
          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 setDecodedOnParse(boolean decodedOnParse)
          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 setEncodedOnFormat(boolean encodedOnFormat)
          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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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_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 decodedOnParse,
                boolean encodedOnFormat)
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.
decodedOnParse - Indicates if the parsed value must be decoded.
encodedOnFormat - 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.

isDecodedOnParse

public boolean isDecodedOnParse()
Indicates if the parsed value must be decoded.

Returns:
True if the parsed value must be decoded, false otherwise.

isEncodedOnFormat

public boolean isEncodedOnFormat()
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.

setDecodedOnParse

public void setDecodedOnParse(boolean decodedOnParse)
Indicates if the parsed value must be decoded.

Parameters:
decodedOnParse - 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.

setEncodedOnFormat

public void setEncodedOnFormat(boolean encodedOnFormat)
Indicates if the formatted value must be encoded.

Parameters:
encodedOnFormat - 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.


Copyright © 2005-2008 Noelios Technologies.