Home | History | Annotate | Download | only in values

Lines Matching defs:Value

26  * Dynamic typing system used by JSilver interpreter. A value (e.g. "2") can act as a string,
30 public abstract class Value {
32 private static final Map<EscapeMode, Value> EMPTY_PART_ESCAPED;
33 private static final Map<EscapeMode, Value> EMPTY_UNESCAPED;
34 private static final Map<EscapeMode, Value> ZERO_PART_ESCAPED;
35 private static final Map<EscapeMode, Value> ZERO_UNESCAPED;
36 private static final Map<EscapeMode, Value> ONE_PART_ESCAPED;
37 private static final Map<EscapeMode, Value> ONE_UNESCAPED;
40 // Currently a Value's EscapeMode is either ESCAPE_NONE (no escaping) or
44 EMPTY_PART_ESCAPED = new HashMap<EscapeMode, Value>(2);
50 EMPTY_UNESCAPED = new HashMap<EscapeMode, Value>(2);
55 ZERO_PART_ESCAPED = new HashMap<EscapeMode, Value>(2);
60 ZERO_UNESCAPED = new HashMap<EscapeMode, Value>(2);
65 ONE_PART_ESCAPED = new HashMap<EscapeMode, Value>(2);
70 ONE_UNESCAPED = new HashMap<EscapeMode, Value>(2);
77 * True if either the {@code Value} was escaped, or it was created from a combination of escaped
83 public Value(EscapeMode escapeMode, boolean partiallyEscaped) {
89 * Fetch value as boolean. All non empty strings and numbers != 0 are treated as true.
94 * Fetch value as string.
99 * Fetch value as number. If number is not parseable, 0 is returned (this is consistent with
105 * Whether this value exists. Literals always return true, but variable references will return
106 * false if the value behind it is null.
113 * Create a literal value using an int.
115 public static Value literalValue(int value, EscapeMode mode, boolean partiallyEscaped) {
116 return getIntValue(mode, partiallyEscaped, value);
120 * Create a literal value using a String.
122 public static Value literalValue(String value, EscapeMode mode, boolean partiallyEscaped) {
123 if (value.isEmpty()) {
124 Value v = (partiallyEscaped ? EMPTY_PART_ESCAPED : EMPTY_UNESCAPED).get(mode);
130 return new StringValue(value, mode, partiallyEscaped);
134 * Create a literal value using a boolean.
136 public static Value literalValue(boolean value, EscapeMode mode, boolean partiallyEscaped) {
137 return getIntValue(mode, partiallyEscaped, value ? 1 : 0);
140 private static Value getIntValue(EscapeMode mode, boolean partiallyEscaped, int num) {
141 Value v = null;
156 * Create a literal value using an int with a {@code escapeMode} of {@code
160 * @param value integer value of the literal
161 * @param inputs Values that were used to compute the integer value.
163 public static Value literalConstant(int value, Value... inputs) {
165 for (Value input : inputs) {
171 return literalValue(value, EscapeMode.ESCAPE_IS_CONSTANT, isPartiallyEscaped);
175 * Create a literal value using a string with a {@code escapeMode} of {@code
179 * @param value String value of the literal
180 * @param inputs Values that were used to compute the string value.
182 public static Value literalConstant(String value, Value... inputs) {
184 for (Value input : inputs) {
190 return literalValue(value, EscapeMode.ESCAPE_IS_CONSTANT, isPartiallyEscaped);
194 * Create a literal value using a boolean with a {@code escapeMode} of {@code
198 * @param value boolean value of the literal
199 * @param inputs Values that were used to compute the boolean value.
201 public static Value literalConstant(boolean value, Value... inputs) {
203 for (Value input : inputs) {
209 return literalValue(value, EscapeMode.ESCAPE_IS_CONSTANT, isPartiallyEscaped);
213 * Create a value linked to a variable name.
218 * @return A Value object that allows access to the variable name, the variable Data object (if it
219 * exists) and to the value of the variable.
221 public static Value variableValue(String name, DataContext dataContext) {
227 if (other == null || !(other instanceof Value)) {
230 Value otherValue = (Value) other;
251 * Indicates the escaping that was applied to the expression represented by this value.
261 * @return {@code EscapeMode.ESCAPE_IS_CONSTANT} if the value represents a constant string
262 * literal. Or the appropriate {@link EscapeMode} if the value is the output of an