Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

PackagePath



The PackagePath class specifies a package or a Class used in the DependencyChecker.

Creating a set of PackagePaths

You can create a Set of PackagePath with the following static methods: For example, the following represents the java.awt.geom and javax.swing packages minus the java.awt.geom.Arc2D class:
   Set<String> excluded = new HashSet<>();
   set.add("java.awt.geom.Area");
   Set<PackagePath> awtgeom = PackagePath.createPackagePathsFromArray(excluded, "java.awt.geom", "javax.swing");   

Type of PackagePath

The PackagePath can represent a Class or a package:
  • It will be a Class if the first character of the last element in the Classpath is an uppercase character
  • It will be a package if the first character of the last element in the Classpath is a lowercase character
The PackagePath.isPackageName() will return true if the PackagePath represent a package.

  • The PackagePath.getPath() will return the path of the Class or the Package
  • The PackagePath.getPackageName() will return the path of the Package. It will return the same result if the PackagePath represent a package, else it will represent the package of the Class
For example:
   PackagePath awtgeom = new PackagePath("java.awt.geom"); // represents a package
   boolean isPackage = awtgeom.isPackageName(); // will return true
   String path = awtgeom.getPath() // will return "java.awt.geom"
   String packageName = awtgeom.getPackageName() // will return "java.awt.geom"      
      
   PackagePath awtgeom2 = new PackagePath("java.awt.geom.Arc2D"); // represents a Class      
   isPackage = awtgeom2.isPackageName(); // will return false 
   path = awtgeom2.getPath() // will return "java.awt.geom.Arc2D"
   packageName = awtgeom2.getPackageName() // will return "java.awt.geom"                 

Examples

The following represents the java.awt.geom package:
   PackagePath awtgeom = new PackagePath("java.awt.geom"); 
The following represents the java.awt.geom package minus the java.awt.geom.Arc2D and java.awt.geom.Area classes:
   PackagePath awtgeom = new PackagePath("java.awt.geom", "java.awt.geom.Arc2D", "java.awt.geom.Area");   

See also


Categories: General

Copyright 2019 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 licence