001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.jdt.core.jdom;
011:
012: /**
013: * Represents a source type in a compilation unit, either as a top-level type or a member type.
014: * The corresponding syntactic units are ClassDeclaration (JLS2 8.1) and InterfaceDeclaration (JLS2 9.1).
015: * Enumeration types and annotation types, added in J2SE 1.5, are represented as
016: * classes and interfaces, respectively.
017: * <p>
018: * Allowable child types for a type are <code>IDOMType</code>, <code>IDOMField</code>,
019: * <code>IDOMMethod</code>, and <code>IDOMInitializer</code>.
020: * Children are listed in the order in which they appear in the source. The parent of a type
021: * is a type (in the case of a member type) or a compilation unit (in the case of a top-level type).
022: * </p>
023: * <p>
024: * This interface is not intended to be implemented by clients.
025: * </p>
026: * @deprecated The JDOM was made obsolete by the addition in 2.0 of the more
027: * powerful, fine-grained DOM/AST API found in the
028: * org.eclipse.jdt.core.dom package.
029: */
030: public interface IDOMType extends IDOMMember {
031: /**
032: * Adds the given interface name to the names of interfaces that this type implements or extends
033: * (the name will be added after the existing interface names). This is a convenience method.
034: *
035: * For classes, this represents the interfaces that this class implements.
036: * For interfaces, this represents the interfaces that this interface extends.
037: * The name may or may not be fully qualified.
038: *
039: * @param interfaceName the syntax for an interface name is defined by
040: * Interfaces in ClassDeclaration (JLS2 8.1). Type names must be specified as they would
041: * appear in source code. For example: "Cloneable", "java.io.Serializable".
042: *
043: * @exception IllegalArgumentException if <code>null</code> is specified
044: */
045: public void addSuperInterface(String interfaceName)
046: throws IllegalArgumentException;
047:
048: /**
049: * Returns the formal type parameters for this type.
050: * Returns an empty array if this method has no formal type parameters.
051: * <p>Formal type parameters are as they appear in the source
052: * code; for example:
053: * <code>"X extends List<String> & Serializable"</code>.
054: * </p>
055: *
056: * @return the formal type parameters of this type,
057: * in the order declared in the source, an empty array if none
058: * @since 3.0
059: */
060: String[] getTypeParameters();
061:
062: /**
063: * The <code>IDOMType</code> refinement of this <code>IDOMNode</code>
064: * method returns the name of this type. The name of a class is defined by
065: * ClassDeclaration (JLS2 8.1); the name of an interface is defined by
066: * InterfaceDeclaration (JLS2 9.1).
067: *
068: * @return the name of this type
069: */
070: public String getName();
071:
072: /**
073: * Returns the name of this type's superclass. The syntax for a superclass name
074: * is specified by Super in ClassDeclaration (JLS2 8.1). Type names must be
075: * specified as they would appear in source code. For example:
076: * <code>"Object"</code>, or <code>"java.io.File"</code>.
077: * As of J2SE 1.5, the superclass may also include parameterized
078: * types like <code>"ArrayList<String>"</code>.
079: *
080: * @return the superclass name, or <code>null</code> if this type represents
081: * an interface or if no superclass has been assigned to this class
082: */
083: public String getSuperclass();
084:
085: /**
086: * Returns the names of interfaces that this type implements or extends,
087: * in the order in which they are listed in the source, or an empty array
088: * if no superinterfaces are present. The syntax for interface names is
089: * defined by Interfaces in ClassDeclaration (JLS2 8.1). Type names appear
090: * as they would in source code. For example: <code>"Cloneable"</code>,
091: * or <code>"java.io.Serializable"</code>.
092: * As of J2SE 1.5, superinterfaces may also include parameterized
093: * types like <code>"List<String>"</code>.
094: * <p>
095: * For classes, this method returns the interfaces that this class implements.
096: * For interfaces, this method returns the interfaces that this interface extends.
097: * </p>
098: *
099: * @return the list of interface names
100: */
101: public String[] getSuperInterfaces();
102:
103: /**
104: * Returns whether this type is a class.
105: *
106: * @return <code>true</code> for classes, and <code>false</code> for interfaces
107: */
108: public boolean isClass();
109:
110: /**
111: * Returns whether this type represents an enumeration class ("enum" instead of "class").
112: *
113: * @return true if this type represents an enumeration class, false otherwise
114: * @since 3.0
115: */
116: boolean isEnum();
117:
118: /**
119: * Returns whether this type represents an annotation type ("@interface" instead of "interface").
120: *
121: * @return true if this type represents an annotation type, false otherwise
122: * @since 3.0
123: */
124: boolean isAnnotation();
125:
126: /**
127: * Sets whether this type is a class or an interface. If this type is
128: * a class, and is changed to an interface, this type's superclass
129: * becomes <code>null</code>. When a class becomes an interface or an
130: * interface becomes a class, superinterfaces remain (as part of an
131: * <code>implements</code> clause for classes, or an <code>extends</code>
132: * clause for interfaces).
133: *
134: * @param b <code>true</code> for classes, and <code>false</code> for interfaces
135: */
136: public void setClass(boolean b);
137:
138: /**
139: * Sets whether this type represents an enumeration class.
140: * If this type is a class and is changed to an enum,
141: * this type's superclass becomes <code>null</code>.
142: * If this type is an interface (including an annotation type),
143: * and is changed to an enum, this type is also changed to a class.
144: *
145: * @param b <code>true</code> for enum classes, and <code>false</code> otherwise
146: * @since 3.0
147: */
148: public void setEnum(boolean b);
149:
150: /**
151: * Sets whether this type represents an annotation type ("@interface" instead of "interface").
152: * If this type is a interface and is changed to an enum,
153: * this type's superclass becomes <code>null</code> and its superinterface list
154: * becomes empty. If this type is an class (including an enum),
155: * and is changed to an annotation type, this type is also changed to an interface.
156: *
157: * @param b <code>true</code> for an annotation type, and <code>false</code> otherwise
158: * @since 3.0
159: */
160: public void setAnnotation(boolean b);
161:
162: /**
163: * Sets the formal type parameters for this type.
164: * <p>Formal type parameters are given as they appear in the source
165: * code; for example:
166: * <code>"X extends List<String> & Serializable"</code>.
167: * </p>
168: *
169: * @param typeParameters the formal type parameters of this type,
170: * in the order to appear in the source, an empty array if none
171: * @since 3.0
172: */
173: void setTypeParameters(String[] typeParameters);
174:
175: /**
176: * The <code>IDOMType</code> refinement of this <code>IDOMNode</code>
177: * method sets the name of this type. The name of a class is defined by
178: * ClassDeclaration (JLS2 8.1); the name of an interface is defined by
179: * InterfaceDeclaration (JLS2 9.1).
180: *
181: * @param name the given name
182: * @exception IllegalArgumentException if <code>null</code> is specified
183: */
184: public void setName(String name) throws IllegalArgumentException;
185:
186: /**
187: * Sets the name of this type's superclass. Has no effect if this type
188: * represents an interface. A <code>null</code> name indicates that no
189: * superclass name (extends clause) should appear in the source code.
190: * The syntax for a superclass name is specified by Super in ClassDeclaration
191: * (JLS2 8.1). Type names must be specified as they would appear in source code.
192: * For example: <code>"Object"</code>, or <code>"java.io.File"</code>.
193: * As of J2SE 1.5, the superclass may also include parameterized
194: * types like <code>"ArrayList<String>"</code>.
195: *
196: * @param superclassName the superclass name, or <code>null</code> if this type
197: * should have to no explicitly specified superclass
198: */
199: public void setSuperclass(String super className);
200:
201: /**
202: * Sets the names of interfaces that this type implements or extends,
203: * in the order in which they are to be listed in the source. An empty array
204: * parameter indicates that no superinterfaces are present. The syntax for
205: * interface names is defined by Interfaces in ClassDeclaration (JLS2 8.1).
206: * Type names appear as they would in source code. For example:
207: * <code>"Cloneable"</code>, or <code>"java.io.Serializable"</code>.
208: * As of J2SE 1.5, superinterfaces may also include parameterized
209: * types like <code>"List<String>"</code>.
210: * <p>
211: * For classes, this method sets the interfaces that this class implements.
212: * For interfaces, this method sets the interfaces that this interface extends.
213: * </p>
214: *
215: * @param interfaceNames the list of interface names
216: */
217: public void setSuperInterfaces(String[] interfaceNames);
218: }
|