001: /*
002: * Spoon - http://spoon.gforge.inria.fr/
003: * Copyright (C) 2006 INRIA Futurs <renaud.pawlak@inria.fr>
004: *
005: * This software is governed by the CeCILL-C License under French law and
006: * abiding by the rules of distribution of free software. You can use, modify
007: * and/or redistribute the software under the terms of the CeCILL-C license as
008: * circulated by CEA, CNRS and INRIA at http://www.cecill.info.
009: *
010: * This program is distributed in the hope that it will be useful, but WITHOUT
011: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
012: * FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details.
013: *
014: * The fact that you are presently reading this means that you have had
015: * knowledge of the CeCILL-C license and that you accept its terms.
016: */
017:
018: package spoon.reflect.declaration;
019:
020: import java.util.List;
021: import java.util.Set;
022:
023: import spoon.reflect.code.CtCodeSnippetExpression;
024: import spoon.reflect.code.CtCodeSnippetStatement;
025: import spoon.reflect.reference.CtTypeReference;
026:
027: /**
028: * This abstract element represents the types that can be declared in a Java
029: * program.
030: *
031: * @param <T>
032: * the actual runtime type
033: */
034: public interface CtSimpleType<T> extends CtNamedElement {
035:
036: /**
037: * Returns the types used by this type.
038: *
039: * @param includeSamePackage
040: * set to true if the method should return also the types located
041: * in the same package as the current type
042: */
043: Set<CtTypeReference<?>> getUsedTypes(boolean includeSamePackage);
044:
045: /**
046: * The string separator in a Java innertype qualified name.
047: */
048: public static final String INNERTTYPE_SEPARATOR = "$";
049:
050: /**
051: * Returns the actual runtime class if exists.
052: *
053: * @return the runtime class, null if is not accessible or does not exist
054: */
055: Class<T> getActualClass();
056:
057: /**
058: * Returns the fields that are directly declared by this class or interface.
059: * Includes enum constants.
060: */
061: // List<CtField<?>> getAllFields();
062: /**
063: * Gets the type where this one is declared. If a declaring type is set, the
064: * package corresponds to the declaring type's package.
065: *
066: * @return declaring type or null
067: */
068: CtSimpleType<?> getDeclaringType();
069:
070: /**
071: * Gets a field from its name.
072: *
073: * @return null if does not exit
074: */
075: CtField<?> getField(String name);
076:
077: /**
078: * Returns the fields that are directly declared by this class or interface.
079: * Includes enum constants.
080: */
081: List<CtField<?>> getFields();
082:
083: /**
084: * Gets a nested type from its name.
085: */
086: CtSimpleType<?> getNestedType(String name);
087:
088: /**
089: * Returns the declarations of the nested classes and interfaces that are
090: * directly declared by this class or interface.
091: */
092: Set<CtSimpleType<?>> getNestedTypes();
093:
094: /**
095: * Gets the package where this type is declared.
096: */
097: CtPackage getPackage();
098:
099: /**
100: * Returns the fully qualified name of this type declaration.
101: */
102: String getQualifiedName();
103:
104: CtTypeReference<T> getReference();
105:
106: /**
107: * Returns true if this type is top-level (declared as the main type in a
108: * file).
109: */
110: boolean isTopLevel();
111:
112: /**
113: * Sets the type's fields.
114: */
115: void setFields(List<CtField<?>> fields);
116:
117: /**
118: * Sets some nested types.
119: */
120: void setNestedTypes(Set<CtSimpleType<?>> nestedTypes);
121:
122: /**
123: * Compiles and replace all the code snippets that are found in this type.
124: *
125: * @see CtCodeSnippet
126: * @see CtCodeSnippetExpression
127: * @see CtCodeSnippetStatement
128: */
129: void compileAndReplaceSnippets();
130:
131: }
|