01: /**
02: * MVEL (The MVFLEX Expression Language)
03: *
04: * Copyright (C) 2007 Christopher Brock, MVFLEX/Valhalla Project and the Codehaus
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: *
18: */package org.mvel.ast;
19:
20: import org.mvel.integration.VariableResolverFactory;
21:
22: /**
23: * @author Christopher Brock
24: */
25: public class LiteralNode extends ASTNode {
26: // private Object literal;
27:
28: public LiteralNode(Object literal, Class type) {
29: this (literal);
30: this .egressType = type;
31: }
32:
33: public LiteralNode(Object literal) {
34: super ();
35: this .fields |= LITERAL;
36: if (literal instanceof String) {
37: this .literal = ((String) literal).intern();
38: } else if (literal instanceof Integer) {
39: this .fields |= INTEGER32;
40: this .intRegister = ((Integer) (this .literal = literal));
41: } else {
42: this .literal = literal;
43: }
44: }
45:
46: public LiteralNode(Object literal, int fields) {
47: super ();
48: this .fields = fields;
49: if (literal instanceof String) {
50: this .literal = ((String) literal).intern();
51: } else {
52: this .literal = literal;
53: }
54: }
55:
56: public Object getReducedValueAccelerated(Object ctx,
57: Object this Value, VariableResolverFactory factory) {
58: return literal;
59: }
60:
61: public Object getReducedValue(Object ctx, Object this Value,
62: VariableResolverFactory factory) {
63: return literal;
64: }
65:
66: public Object getLiteralValue() {
67: return literal;
68: }
69:
70: public void setLiteralValue(Object literal) {
71: this .literal = literal;
72: }
73:
74: public boolean isLiteral() {
75: return true;
76: }
77: }
|