01: /*
02: * xtc - The eXTensible Compiler
03: * Copyright (C) 2005-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.type;
20:
21: import java.io.IOException;
22:
23: import java.util.List;
24:
25: /**
26: * A class type.
27: *
28: * @author Robert Grimm
29: * @version $Revision: 1.13 $
30: */
31: public class ClassT extends ClassOrInterfaceT {
32:
33: /** The optional parent class. */
34: private Type parent;
35:
36: /**
37: * Create a new class type.
38: *
39: * @param qname The fully qualified name.
40: * @param parent The optional parent class.
41: * @param interfaces The list of interfaces.
42: * @param fields The list of fields.
43: * @param methods The list of methods.
44: */
45: public ClassT(String qname, Type parent, List<Type> interfaces,
46: List<Type> fields, List<Type> methods) {
47: super (null, qname, interfaces, fields, methods);
48: this .parent = parent;
49: }
50:
51: /**
52: * Create a new class type.
53: *
54: * @param template The type whose annotations to copy.
55: * @param qname The fully qualified name.
56: * @param parent The optional parent class.
57: * @param interfaces The list of interfaces.
58: * @param fields The list of fields.
59: * @param methods The list of methods.
60: */
61: public ClassT(Type template, String qname, Type parent,
62: List<Type> interfaces, List<Type> fields, List<Type> methods) {
63: super (template, qname, interfaces, fields, methods);
64: this .parent = parent;
65: }
66:
67: public ClassT copy() {
68: return new ClassT(this , qname, parent.copy(), copy(interfaces),
69: copy(fields), copy(methods));
70: }
71:
72: public Type.Tag tag() {
73: return Type.Tag.CLASS;
74: }
75:
76: public boolean isClass() {
77: return true;
78: }
79:
80: public ClassT toClass() {
81: return this ;
82: }
83:
84: /**
85: * Get the parent class.
86: *
87: * @return The parent class.
88: */
89: public Type getParent() {
90: return parent;
91: }
92:
93: public void write(Appendable out) throws IOException {
94: out.append("class ");
95: out.append(qname);
96: }
97:
98: }
|