public abstract class Value extends Object
Constructor and Description |
---|
Value(EscapeMode escapeMode,
boolean partiallyEscaped) |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
asBoolean()
Fetch value as boolean.
|
abstract int |
asNumber()
Fetch value as number.
|
abstract String |
asString()
Fetch value as string.
|
boolean |
equals(Object other) |
abstract boolean |
exists()
Whether this value exists.
|
EscapeMode |
getEscapeMode()
Indicates the escaping that was applied to the expression represented by this value.
|
int |
hashCode() |
abstract boolean |
isEmpty() |
boolean |
isPartiallyEscaped() |
static Value |
literalConstant(boolean value,
Value... inputs)
Create a literal value using a boolean with a
escapeMode of EscapeMode.ESCAPE_IS_CONSTANT and partiallyEscaped based on the partiallyEscaped values of the inputs. |
static Value |
literalConstant(int value,
Value... inputs)
Create a literal value using an int with a
escapeMode of EscapeMode.ESCAPE_IS_CONSTANT and partiallyEscaped based on the partiallyEscaped values of the inputs. |
static Value |
literalConstant(String value,
Value... inputs)
Create a literal value using a string with a
escapeMode of EscapeMode.ESCAPE_IS_CONSTANT and partiallyEscaped based on the partiallyEscaped values of the inputs. |
static Value |
literalValue(boolean value,
EscapeMode mode,
boolean partiallyEscaped)
Create a literal value using a boolean.
|
static Value |
literalValue(int value,
EscapeMode mode,
boolean partiallyEscaped)
Create a literal value using an int.
|
static Value |
literalValue(String value,
EscapeMode mode,
boolean partiallyEscaped)
Create a literal value using a String.
|
String |
toString() |
static Value |
variableValue(String name,
DataContext dataContext)
Create a value linked to a variable name.
|
public Value(EscapeMode escapeMode, boolean partiallyEscaped)
public abstract boolean asBoolean()
public abstract String asString()
public abstract int asNumber()
public abstract boolean exists()
public abstract boolean isEmpty()
public static Value literalValue(int value, EscapeMode mode, boolean partiallyEscaped)
public static Value literalValue(String value, EscapeMode mode, boolean partiallyEscaped)
public static Value literalValue(boolean value, EscapeMode mode, boolean partiallyEscaped)
public static Value literalConstant(int value, Value... inputs)
escapeMode
of EscapeMode.ESCAPE_IS_CONSTANT
and partiallyEscaped
based on the partiallyEscaped
values of the inputs.value
- integer value of the literalinputs
- Values that were used to compute the integer value.public static Value literalConstant(String value, Value... inputs)
escapeMode
of EscapeMode.ESCAPE_IS_CONSTANT
and partiallyEscaped
based on the partiallyEscaped
values of the inputs.value
- String value of the literalinputs
- Values that were used to compute the string value.public static Value literalConstant(boolean value, Value... inputs)
escapeMode
of EscapeMode.ESCAPE_IS_CONSTANT
and partiallyEscaped
based on the partiallyEscaped
values of the inputs.value
- boolean value of the literalinputs
- Values that were used to compute the boolean value.public static Value variableValue(String name, DataContext dataContext)
name
- The pathname of the variable relative to the given DataContext
dataContext
- The DataContext defining the scope and Data objects to use when
dereferencing the name.public boolean isPartiallyEscaped()
public EscapeMode getEscapeMode()
May be checked by the JSilver code before applying autoescaping. It differs from isEscaped
, which is true iff any part of the variable expression contains an escaping
function, even if the entire expression has not been escaped. Both methods are required,
isEscaped
to determine whether <?cs escape > commands should be applied, and
getEscapeMode
for autoescaping. This is done to maintain compatibility with
ClearSilver's behaviour.
EscapeMode.ESCAPE_IS_CONSTANT
if the value represents a constant string
literal. Or the appropriate EscapeMode
if the value is the output of an
escaping function.EscapeMode
Copyright © 2010–2016 Google. All rights reserved.