01: /*
02: * The contents of this file are subject to the Mozilla Public License
03: * Version 1.1 (the "License"); you may not use this file except in
04: * compliance with the License. You may obtain a copy of the License at
05: * http://www.mozilla.org/MPL/
06: *
07: * Software distributed under the License is distributed on an "AS IS"
08: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
09: * License for the specific language governing rights and limitations
10: * under the License.
11: *
12: * The Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
13: *
14: * The Initial Developer of the Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
15: * Portions created by Mark A. Kobold are Copyright (C) 2000-2007. All Rights Reserved.
16: *
17: * Contributor(s):
18: * Mark A. Kobold [mkobold <at> isqlviewer <dot> com].
19: *
20: * If you didn't download this code from the following link, you should check
21: * if you aren't using an obsolete version: http://www.isqlviewer.com
22: */
23: package org.isqlviewer.sql.processor;
24:
25: import java.text.MessageFormat;
26:
27: /**
28: * Representation of a interpreted symbol from a processor.
29: * <p>
30: *
31: * @author Mark A. Kobold <mkobold at isqlviewer dot com>
32: * @version 1.0
33: */
34: /**
35: * A Symbol represents the information shared between similar tokens, i.e. their type and spelling.
36: */
37: public class TextSymbol {
38:
39: /**
40: * The type isused to classify symbols.
41: * <p>
42: * It also distinguishes different symbols with the same spelling, where necessary.
43: */
44: public final TokenType type;
45:
46: /**
47: * The spelling.
48: */
49: public final String name;
50:
51: /**
52: * Construct a symbol from its type and name.
53: */
54: public TextSymbol(TokenType type, String name) {
55:
56: this .type = type;
57: this .name = name;
58: }
59:
60: @Override
61: public String toString() {
62:
63: return MessageFormat.format(
64: "TextSymbol [name=''{0}'', type=''{1}'']", name, type);
65: }
66:
67: @Override
68: public int hashCode() {
69:
70: return name.hashCode();
71: }
72:
73: @Override
74: public boolean equals(Object obj) {
75:
76: if (obj instanceof TextSymbol) {
77: TextSymbol that = (TextSymbol) obj;
78: return name.equalsIgnoreCase(that.name)
79: && type == that.type;
80: }
81: return false;
82: }
83:
84: }
|