Class JavaPackage

java.lang.Object
org.jtool.srcmodel.JavaPackage

public class JavaPackage extends Object
An object representing a package.
  • Method Details

    • createDefault

      public static JavaPackage createDefault(JavaFile jfile)
      Creates a new object representing a default package. This constructor is not intended to be invoked by clients.
      Parameters:
      jfile - the file declaring this package
      Returns:
      the created package
    • create

      public static JavaPackage create(org.eclipse.jdt.core.dom.PackageDeclaration node, JavaFile jfile)
      Creates a new object representing a package. This constructor is not intended to be invoked by clients.
      Parameters:
      node - an AST node for this package
      jfile - a file that declares this package
      Returns:
      the created package
    • createExternal

      public static JavaPackage createExternal(org.eclipse.jdt.core.dom.IPackageBinding pbinding, JavaProject jproject)
      Creates a new object representing a package used in a class not having its corresponding file. This constructor is not intended to be invoked by clients.
      Parameters:
      pbinding - the package binding for this package
      jproject - a project which this package is used in
      Returns:
      the created package
    • getASTNode

      public org.eclipse.jdt.core.dom.ASTNode getASTNode()
      Returns the AST node corresponding to this package.
      Returns:
      the corresponding AST node
    • getName

      public String getName()
      Returns the name of this package.
      Returns:
      the package name
    • isInProject

      public boolean isInProject()
      Tests if this package exists inside the target project, which can resent the corresponding source code.
      Returns:
      true if this package exists inside the target project, otherwise false
    • isDefault

      public boolean isDefault()
      Tests if this is default package.
      Returns:
      true if this is default package, otherwise false
    • getClasses

      public Set<JavaClass> getClasses()
      Obtains classes belonging to this package.
      Returns:
      the collection of the belonging classes
    • getSortedClasses

      public List<JavaClass> getSortedClasses()
      Obtains sorted classes belonging to this package.
      Returns:
      the sorted collection of the belonging classes
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • equals

      public boolean equals(JavaPackage jpackage)
      Tests if a given package is equal to this package.
      Parameters:
      jpackage - the package to be checked
      Returns:
      the true if the given package is equal to this package
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Obtains information on this package.
      Overrides:
      toString in class Object
      Returns:
      the string representing the information
    • getEfferentJavaPackages

      public Set<JavaPackage> getEfferentJavaPackages()
      Obtains packages containing classes that are used by classes belonging to this package.
      Returns:
      the collection of the used packages, or an empty set if there is no file for this package
    • getAfferentJavaPackages

      public Set<JavaPackage> getAfferentJavaPackages()
      Obtains packages containing classes that use classes belonging to this package.
      Returns:
      the collection of the using packages, or an empty set if there is no file for this package