/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A Java package.
*/
public final class JPackage implements JDeclaration, JGenerable, JClassContainer, JAnnotatable, Comparable<JPackage>, JDocCommentable {
/**
* Name of the package.
* May be the empty string for the root package.
*/
/**
* List of classes contained within this package keyed by their name.
*/
/**
* List of resources files inside this package.
*/
/**
* All {@link JClass}s in this package keyed the upper case class name.
*
* This field is non-null only on Windows, to detect
* "Foo" and "foo" as a collision.
*/
/**
* Lazily created list of package annotations.
*/
/**
* package javadoc.
*/
/**
* JPackage constructor
*
* @param name
* Name of package
*
* @param cw The code writer being used to create this package
*
* @throws IllegalArgumentException
* If each part of the package name is not a valid identifier
*/
throw new IllegalArgumentException(msg);
}
else
}
return parent();
}
/**
* Gets the parent package, or null if this class is the root package.
*/
}
public boolean isClass() { return false; }
public boolean isPackage() { return true; }
/**
* Add a class to this package.
*
* @param mods
* Modifiers for this class declaration
*
* @param name
* Name of class to be added to this package
*
* @return Newly generated class
*
* @exception JClassAlreadyExistsException
*/
}
/**
* {@inheritDoc}
* @deprecated
*/
public JDefinedClass _class( int mods, String name, boolean isInterface ) throws JClassAlreadyExistsException {
}
public JDefinedClass _class( int mods, String name, ClassType classTypeVal ) throws JClassAlreadyExistsException {
else {
// XXX problems caught in the NC constructor
if( upperCaseClassMap!=null ) {
throw new JClassAlreadyExistsException(dc);
}
return c;
}
}
/**
* Adds a public class to this package.
*/
}
/**
* Gets a reference to the already created {@link JDefinedClass}.
*
* @return null
* If the class is not yet created.
*/
else
return null;
}
/**
* Order is based on the lexicological order of the package name.
*/
}
/**
* Add an interface to this package.
*
* @param mods
* Modifiers for this interface declaration
*
* @param name
* Name of interface to be added to this package
*
* @return Newly generated interface
*/
}
/**
* Adds a public interface to this package.
*/
}
/**
* Add an annotationType Declaration to this package
* @param name
* Name of the annotation Type declaration to be added to this package
* @return
* newly created Annotation Type Declaration
* @exception JClassAlreadyExistsException
*/
}
/**
* Add a public enum to this package
* @param name
* Name of the enum to be added to this package
* @return
* newly created Enum
* @exception JClassAlreadyExistsException
*/
}
/**
* Adds a new resource file to this package.
*/
return rsrc;
}
/**
* Checks if a resource of the given name exists.
*/
for (JResourceFile r : resources)
return true;
return false;
}
/**
* Iterates all resource files in this package.
*/
}
/**
* Creates, if necessary, and returns the package javadoc for this
* JDefinedClass.
*
* @return JDocComment containing javadocs for this class
*/
return jdoc;
}
/**
* Removes a class from this package.
*/
if (c._package() != this)
throw new IllegalArgumentException(
"the specified class is not a member of this package," + " or it is a referenced class");
// note that c may not be a member of classes.
// this happens when someone is trying to remove a non generated class
if (upperCaseClassMap != null)
}
/**
* Reference a class within this package.
*/
String n = "";
if (!isUnnamed())
n = this.name + '.';
n += name;
}
/**
* Gets a reference to a sub package of this package.
*/
}
/**
* Returns an iterator that walks the top-level classes defined in this
* package.
*/
}
/**
*/
return true;
}
return false;
}
/**
* Checks if this package is the root, unnamed package.
*/
/**
* Get the name of this package
*
* @return
* The name of this package, or the empty string if this is the
* null package. For example, this method returns strings like
* <code>"java.lang"</code>
*/
return name;
}
/**
* Return the code model root object being used to create this package.
*/
if(isUnnamed())
throw new IllegalArgumentException("the root package cannot be annotated");
if(annotations==null)
annotations.add(a);
return a;
}
}
}
if (annotations == null)
}
/**
* Convert the package name to directory path equivalent
*/
}
}
f.p(name);
}
// write classes
if (c.isHidden())
continue; // don't generate this file
f.write(c);
f.close();
}
// write package annotations
f.g(jdoc);
// TODO: think about importing
if (annotations != null){
for (JAnnotationUse a : annotations)
f.g(a).nl();
}
f.d(this);
f.close();
}
// write resources
}
}
int r = 0;
if (c.isHidden())
continue; // don't generate this file
r++;
}
r++;
}
return r;
}
private JFormatter createJavaSourceFileWriter(CodeWriter src, String className) throws IOException {
}
}