01: /* ****************************************************************************
02: * ASTIdentifier.java
03: * ****************************************************************************/
04:
05: /* J_LZ_COPYRIGHT_BEGIN *******************************************************
06: * Copyright 2001-2008 Laszlo Systems, Inc. All Rights Reserved. *
07: * Use is subject to license terms. *
08: * J_LZ_COPYRIGHT_END *********************************************************/
09:
10: package org.openlaszlo.sc.parser;
11:
12: public class ASTIdentifier extends SimpleNode {
13: private String name = null;
14: private Type type = null;
15: private int hash = 0;
16:
17: public static class Type {
18: public String typeName = null;
19: public boolean nullable = false; // has "?"
20: public boolean notnullable = false; // has "!"
21: public boolean untyped = false; // is "*"
22: }
23:
24: public ASTIdentifier(int id) {
25: super (id);
26: }
27:
28: public ASTIdentifier(Parser p, int id) {
29: super (p, id);
30: }
31:
32: public static Node jjtCreate(int id) {
33: return new ASTIdentifier(id);
34: }
35:
36: public static Node jjtCreate(Parser p, int id) {
37: return new ASTIdentifier(p, id);
38: }
39:
40: // Added
41: public ASTIdentifier(String s) {
42: setName(s);
43: }
44:
45: public void setName(String name) {
46: this .name = name.intern(); // to lower number of strings
47: this .hash = name.hashCode();
48: }
49:
50: public int hashCode() {
51: return hash;
52: }
53:
54: public String getName() {
55: return name;
56: }
57:
58: public Type getType() {
59: return type;
60: }
61:
62: public void setType(Type type) {
63: this .type = type;
64: }
65:
66: public String toString() {
67: String typesuffix = "";
68: if (type != null) {
69: typesuffix = ": ";
70: if (type.nullable)
71: typesuffix += "?";
72: typesuffix += type.typeName;
73: if (type.notnullable)
74: typesuffix += "!";
75: }
76: return "ASTIdentifier(" + name + typesuffix + ")";
77: }
78: }
|