< prev index next >

src/jdk.rmic/share/classes/sun/tools/java/Package.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad


  98 
  99         if (sourcePath != binaryPath) {
 100             // Look for the directory on our source path.
 101             dir = sourcePath.getDirectory(pkg);
 102             if (dir != null && dir.isDirectory()) {
 103                 return true;
 104             }
 105         }
 106 
 107         /* Accommodate ZIP files without CEN entries for directories
 108          * (packages): look on class path for at least one binary
 109          * file or one source file with the right package prefix
 110          */
 111         String prefix = pkg + File.separator;
 112 
 113         return binaryPath.getFiles(prefix, ".class").hasMoreElements()
 114             || sourcePath.getFiles(prefix, ".java").hasMoreElements();
 115     }
 116 
 117     private String makeName(String fileName) {
 118         return pkg.equals("") ? fileName : pkg + File.separator + fileName;
 119     }
 120 
 121     /**
 122      * Get the .class file of a class
 123      */
 124     public ClassFile getBinaryFile(Identifier className) {
 125         className = Type.mangleInnerType(className);
 126         String fileName = className.toString() + ".class";
 127         return binaryPath.getFile(makeName(fileName));
 128     }
 129 
 130     /**
 131      * Get the .java file of a class
 132      */
 133     public ClassFile getSourceFile(Identifier className) {
 134         // The source file of an inner class is that of its outer class.
 135         className = className.getTopName();
 136         String fileName = className.toString() + ".java";
 137         return sourcePath.getFile(makeName(fileName));
 138     }
 139 
 140     public ClassFile getSourceFile(String fileName) {
 141         if (fileName.endsWith(".java")) {
 142             return sourcePath.getFile(makeName(fileName));
 143         }
 144         return null;
 145     }
 146 
 147     public Enumeration<ClassFile> getSourceFiles() {
 148         return sourcePath.getFiles(pkg, ".java");
 149     }
 150 
 151     public Enumeration<ClassFile> getBinaryFiles() {
 152         return binaryPath.getFiles(pkg, ".class");
 153     }
 154 
 155     public String toString() {
 156         if (pkg.equals("")) {
 157             return "unnamed package";
 158         }
 159         return "package " + pkg;
 160     }
 161 }


  98 
  99         if (sourcePath != binaryPath) {
 100             // Look for the directory on our source path.
 101             dir = sourcePath.getDirectory(pkg);
 102             if (dir != null && dir.isDirectory()) {
 103                 return true;
 104             }
 105         }
 106 
 107         /* Accommodate ZIP files without CEN entries for directories
 108          * (packages): look on class path for at least one binary
 109          * file or one source file with the right package prefix
 110          */
 111         String prefix = pkg + File.separator;
 112 
 113         return binaryPath.getFiles(prefix, ".class").hasMoreElements()
 114             || sourcePath.getFiles(prefix, ".java").hasMoreElements();
 115     }
 116 
 117     private String makeName(String fileName) {
 118         return pkg.isEmpty() ? fileName : pkg + File.separator + fileName;
 119     }
 120 
 121     /**
 122      * Get the .class file of a class
 123      */
 124     public ClassFile getBinaryFile(Identifier className) {
 125         className = Type.mangleInnerType(className);
 126         String fileName = className.toString() + ".class";
 127         return binaryPath.getFile(makeName(fileName));
 128     }
 129 
 130     /**
 131      * Get the .java file of a class
 132      */
 133     public ClassFile getSourceFile(Identifier className) {
 134         // The source file of an inner class is that of its outer class.
 135         className = className.getTopName();
 136         String fileName = className.toString() + ".java";
 137         return sourcePath.getFile(makeName(fileName));
 138     }
 139 
 140     public ClassFile getSourceFile(String fileName) {
 141         if (fileName.endsWith(".java")) {
 142             return sourcePath.getFile(makeName(fileName));
 143         }
 144         return null;
 145     }
 146 
 147     public Enumeration<ClassFile> getSourceFiles() {
 148         return sourcePath.getFiles(pkg, ".java");
 149     }
 150 
 151     public Enumeration<ClassFile> getBinaryFiles() {
 152         return binaryPath.getFiles(pkg, ".class");
 153     }
 154 
 155     public String toString() {
 156         if (pkg.isEmpty()) {
 157             return "unnamed package";
 158         }
 159         return "package " + pkg;
 160     }
 161 }
< prev index next >