001: /*
002: * xtc - The eXTensible Compiler
003: * Copyright (C) 2006-2007 Robert Grimm
004: *
005: * This program is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU General Public License
007: * version 2 as published by the Free Software Foundation.
008: *
009: * This program is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013: *
014: * You should have received a copy of the GNU General Public License
015: * along with this program; if not, write to the Free Software
016: * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
017: * USA.
018: */
019: package xtc.type;
020:
021: import java.io.IOException;
022:
023: /**
024: * A package type.
025: *
026: * @author Robert Grimm
027: * @version $Revision: 1.12 $
028: */
029: public class PackageT extends Type {
030:
031: /** The name. */
032: private String name;
033:
034: /**
035: * Create a new package type.
036: *
037: * @param name The name.
038: */
039: public PackageT(String name) {
040: this .name = name;
041: }
042:
043: /**
044: * Create a new package type.
045: *
046: * @param template The type whose annotations to copy.
047: * @param name The name.
048: */
049: public PackageT(Type template, String name) {
050: super (template);
051: this .name = name;
052: }
053:
054: public PackageT copy() {
055: return new PackageT(this , name);
056: }
057:
058: public Type.Tag tag() {
059: return Type.Tag.PACKAGE;
060: }
061:
062: public boolean isPackage() {
063: return true;
064: }
065:
066: public PackageT toPackage() {
067: return this ;
068: }
069:
070: /**
071: * Get the name.
072: *
073: * @return The name.
074: */
075: public String getName() {
076: return name;
077: }
078:
079: public int hashCode() {
080: return name.hashCode();
081: }
082:
083: public boolean equals(Object o) {
084: if (!(o instanceof Type))
085: return false;
086: Type t = resolve(o);
087:
088: if (this == t)
089: return true;
090: if (!t.isPackage())
091: return false;
092: return name.equals(((PackageT) t).name);
093: }
094:
095: public void write(Appendable out) throws IOException {
096: out.append("package(");
097: out.append(name);
098: out.append(')');
099: }
100:
101: }
|