Thu, 12 Oct 2017 19:44:07 +0800
merge
1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.codemodel.internal;
28 import java.util.Iterator;
30 /**
31 * The common aspect of a package and a class.
32 */
33 public interface JClassContainer {
35 /**
36 * Returns true if the container is a class.
37 */
38 boolean isClass();
39 /**
40 * Returns true if the container is a package.
41 */
42 boolean isPackage();
44 /**
45 * Add a new class to this package/class.
46 *
47 * @param mods
48 * Modifiers for this class declaration
49 *
50 * @param name
51 * Name of class to be added to this package
52 *
53 * @return Newly generated class
54 *
55 * @exception JClassAlreadyExistsException
56 * When the specified class/interface was already created.
57 */
58 JDefinedClass _class(int mods, String name) throws JClassAlreadyExistsException;
60 /**
61 * Add a new public class to this class/package.
62 *
63 * @exception JClassAlreadyExistsException
64 * When the specified class/interface was already created.
65 */
66 public JDefinedClass _class(String name) throws JClassAlreadyExistsException;
68 /**
69 * Add an interface to this class/package.
70 *
71 * @param mods
72 * Modifiers for this interface declaration
73 *
74 * @param name
75 * Name of interface to be added to this package
76 *
77 * @return Newly generated interface
78 *
79 * @exception JClassAlreadyExistsException
80 * When the specified class/interface was already created.
81 */
82 public JDefinedClass _interface(int mods, String name) throws JClassAlreadyExistsException;
84 /**
85 * Adds a public interface to this package.
86 *
87 * @exception JClassAlreadyExistsException
88 * When the specified class/interface was already created.
89 */
90 public JDefinedClass _interface(String name) throws JClassAlreadyExistsException;
92 /**
93 * Create a new class or a new interface.
94 *
95 * @deprecated
96 * use {@link #_class(int, String, ClassType)}
97 */
98 public JDefinedClass _class(int mods, String name, boolean isInterface )
99 throws JClassAlreadyExistsException;
101 /**
102 * Creates a new class/enum/interface/annotation.
103 */
104 public JDefinedClass _class(int mods, String name, ClassType kind )
105 throws JClassAlreadyExistsException;
108 /**
109 * Returns an iterator that walks the nested classes defined in this
110 * class.
111 */
112 public Iterator<JDefinedClass> classes();
114 /**
115 * Parent JClassContainer.
116 *
117 * If this is a package, this method returns a parent package,
118 * or null if this package is the root package.
119 *
120 * If this is an outer-most class, this method returns a package
121 * to which it belongs.
122 *
123 * If this is an inner class, this method returns the outer
124 * class.
125 */
126 public JClassContainer parentContainer();
128 /**
129 * Gets the nearest package parent.
130 *
131 * <p>
132 * If <tt>this.isPackage()</tt>, then return <tt>this</tt>.
133 */
134 public JPackage getPackage();
136 /**
137 * Get the root code model object.
138 */
139 public JCodeModel owner();
141 /**
142 * Add an annotationType Declaration to this package
143 * @param name
144 * Name of the annotation Type declaration to be added to this package
145 * @return
146 * newly created Annotation Type Declaration
147 * @exception JClassAlreadyExistsException
148 * When the specified class/interface was already created.
150 */
151 public JDefinedClass _annotationTypeDeclaration(String name) throws JClassAlreadyExistsException;
153 /**
154 * Add a public enum to this package
155 * @param name
156 * Name of the enum to be added to this package
157 * @return
158 * newly created Enum
159 * @exception JClassAlreadyExistsException
160 * When the specified class/interface was already created.
162 */
163 public JDefinedClass _enum (String name) throws JClassAlreadyExistsException;
165 }