Class JPackage

    • Method Detail

      • parentContainer

        public JClassContainer parentContainer()
        Description copied from interface: JClassContainer
        Parent JClassContainer. If this is a package, this method returns a parent package, or null if this package is the root package. If this is an outer-most class, this method returns a package to which it belongs. If this is an inner class, this method returns the outer class.
        Specified by:
        parentContainer in interface JClassContainer
      • parent

        public JPackage parent()
        Gets the parent package, or null if this class is the root package.
      • _getClass

        public JDefinedClass _getClass​(java.lang.String name)
        Gets a reference to the already created JDefinedClass.
        Returns:
        null If the class is not yet created.
      • compareTo

        public int compareTo​(JPackage that)
        Order is based on the lexicological order of the package name.
        Specified by:
        compareTo in interface java.lang.Comparable<JPackage>
      • hasResourceFile

        public boolean hasResourceFile​(java.lang.String name)
        Checks if a resource of the given name exists.
      • propertyFiles

        public java.util.Iterator<JResourceFile> propertyFiles()
        Iterates all resource files in this package.
      • javadoc

        public JDocComment javadoc()
        Creates, if necessary, and returns the package javadoc for this JDefinedClass.
        Specified by:
        javadoc in interface JDocCommentable
        Returns:
        JDocComment containing javadocs for this class
      • remove

        public void remove​(JClass c)
        Removes a class from this package.
      • ref

        public JClass ref​(java.lang.String name)
                   throws java.lang.ClassNotFoundException
        Reference a class within this package.
        Throws:
        java.lang.ClassNotFoundException
      • subPackage

        public JPackage subPackage​(java.lang.String pkg)
        Gets a reference to a sub package of this package.
      • classes

        public java.util.Iterator<JDefinedClass> classes()
        Returns an iterator that walks the top-level classes defined in this package.
        Specified by:
        classes in interface JClassContainer
      • hasClasses

        public boolean hasClasses()
        Checks if this package contains any classes.
        Returns:
        true if this package contains any classes or false otherwise.
      • isDefined

        public boolean isDefined​(java.lang.String classLocalName)
        Checks if a given name is already defined as a class/interface
      • isUnnamed

        public final boolean isUnnamed()
        Checks if this package is the root, unnamed package.
      • name

        public java.lang.String name()
        Get the name of this package
        Returns:
        The name of this package, or the empty string if this is the null package. For example, this method returns strings like "java.lang"
      • owner

        public final JCodeModel owner()
        Return the code model root object being used to create this package.
        Specified by:
        owner in interface JClassContainer
      • annotate

        public JAnnotationUse annotate​(JClass clazz)
        Description copied from interface: JAnnotatable
        Adds an annotation to this program element.
        Specified by:
        annotate in interface JAnnotatable
        Parameters:
        clazz - The annotation class to annotate the program element with
      • annotate

        public JAnnotationUse annotate​(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
        Description copied from interface: JAnnotatable
        Adds an annotation to this program element.
        Specified by:
        annotate in interface JAnnotatable
        Parameters:
        clazz - The annotation class to annotate the program element with
      • annotate2

        public <W extends JAnnotationWriter> W annotate2​(java.lang.Class<W> clazz)
        Description copied from interface: JAnnotatable
        Adds an annotation to this program element and returns a type-safe writer to fill in the values of such annotations.
        Specified by:
        annotate2 in interface JAnnotatable
      • removeAnnotation

        public boolean removeAnnotation​(JAnnotationUse annotation)
        Description copied from interface: JAnnotatable
        Removes annotation from this program element.
        Specified by:
        removeAnnotation in interface JAnnotatable
        Parameters:
        annotation - The annotation to be removed from the program element