01: /*
02: * xtc - The eXTensible Compiler
03: * Copyright (C) 2004-2007 Robert Grimm
04: *
05: * This program is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU General Public License
07: * version 2 as published by the Free Software Foundation.
08: *
09: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17: * USA.
18: */
19: package xtc.parser;
20:
21: /**
22: * Element to set the semantic value to a string.
23: *
24: * @author Robert Grimm
25: * @version $Revision: 1.5 $
26: */
27: public class StringValue extends ValueElement {
28:
29: /** The canonical string value element with unknown text. */
30: public static final StringValue VALUE = new StringValue();
31:
32: /** The statically known text, which is optional. */
33: public final String text;
34:
35: /** Create a new string value. */
36: public StringValue() {
37: text = null;
38: }
39:
40: /**
41: * Create a new string value.
42: *
43: * @param text The static text.
44: */
45: public StringValue(String text) {
46: this .text = text;
47: }
48:
49: public Tag tag() {
50: return Tag.STRING_VALUE;
51: }
52:
53: public int hashCode() {
54: return null == text ? 7 : text.hashCode();
55: }
56:
57: public boolean equals(Object o) {
58: if (this == o)
59: return true;
60: if (!(o instanceof StringValue))
61: return false;
62: StringValue other = (StringValue) o;
63: return null == text ? null == other.text : text
64: .equals(other.text);
65: }
66:
67: }
|