src/share/classes/sun/awt/shell/ShellFolder.java

Print this page
rev 9830 : 8039642: Fix raw and unchecked warnings in sun.awt.*
Reviewed-by: darcy, prr


 110      * @since 1.4
 111      */
 112     public File getParentFile() {
 113         if (parent != null) {
 114             return parent;
 115         } else if (isFileSystem()) {
 116             return super.getParentFile();
 117         } else {
 118             return null;
 119         }
 120     }
 121 
 122     public File[] listFiles() {
 123         return listFiles(true);
 124     }
 125 
 126     public File[] listFiles(boolean includeHiddenFiles) {
 127         File[] files = super.listFiles();
 128 
 129         if (!includeHiddenFiles) {
 130             Vector v = new Vector();
 131             int nameCount = (files == null) ? 0 : files.length;
 132             for (int i = 0; i < nameCount; i++) {
 133                 if (!files[i].isHidden()) {
 134                     v.addElement(files[i]);
 135                 }
 136             }
 137             files = (File[])v.toArray(new File[v.size()]);
 138         }
 139 
 140         return files;
 141     }
 142 
 143 
 144     /**
 145      * @return Whether this shell folder is a link
 146      */
 147     public abstract boolean isLink();
 148 
 149     /**
 150      * @return The shell folder linked to by this shell folder, or null
 151      * if this shell folder is not a link
 152      */
 153     public abstract ShellFolder getLinkLocation() throws FileNotFoundException;
 154 
 155     /**
 156      * @return The name used to display this shell folder
 157      */


 191     }
 192 
 193     /**
 194      * @param getLargeIcon whether to return large icon (ignored in base implementation)
 195      * @return The icon used to display this shell folder
 196      */
 197     public Image getIcon(boolean getLargeIcon) {
 198         return null;
 199     }
 200 
 201 
 202     // Static
 203 
 204     private static ShellFolderManager shellFolderManager;
 205 
 206     private static Invoker invoker;
 207 
 208     static {
 209         String managerClassName = (String)Toolkit.getDefaultToolkit().
 210                                       getDesktopProperty("Shell.shellFolderManager");
 211         Class managerClass = null;
 212         try {
 213             managerClass = ReflectUtil.forName(managerClassName);
 214         // swallow the exceptions below and use default shell folder
 215         } catch(ClassNotFoundException e) {
 216         } catch(NullPointerException e) {
 217         } catch(SecurityException e) {
 218         }
 219 
 220         if (managerClass == null) {
 221             managerClass = ShellFolderManager.class;
 222         }
 223         try {
 224             shellFolderManager =
 225                 (ShellFolderManager)managerClass.newInstance();
 226         } catch (InstantiationException e) {
 227             throw new Error("Could not instantiate Shell Folder Manager: "
 228             + managerClass.getName());
 229         } catch (IllegalAccessException e) {
 230             throw new Error ("Could not access Shell Folder Manager: "
 231             + managerClass.getName());


 537         }
 538     }
 539 
 540     /**
 541      * Interface allowing to invoke tasks in different environments on different platforms.
 542      */
 543     public static interface Invoker {
 544         /**
 545          * Invokes a callable task.
 546          *
 547          * @param task a task to invoke
 548          * @throws Exception {@code InterruptedException} or an exception that was thrown from the {@code task}
 549          * @return the result of {@code task}'s invokation
 550          */
 551         <T> T invoke(Callable<T> task) throws Exception;
 552     }
 553 
 554     /**
 555      * Provides a default comparator for the default column set
 556      */
 557     private static final Comparator DEFAULT_COMPARATOR = new Comparator() {
 558         public int compare(Object o1, Object o2) {
 559             int gt;
 560 
 561             if (o1 == null && o2 == null) {
 562                 gt = 0;
 563             } else if (o1 != null && o2 == null) {
 564                 gt = 1;
 565             } else if (o1 == null && o2 != null) {
 566                 gt = -1;
 567             } else if (o1 instanceof Comparable) {
 568                 gt = ((Comparable) o1).compareTo(o2);


 569             } else {
 570                 gt = 0;
 571             }
 572 
 573             return gt;
 574         }
 575     };
 576 
 577     private static final Comparator<File> FILE_COMPARATOR = new Comparator<File>() {
 578         public int compare(File f1, File f2) {
 579             ShellFolder sf1 = null;
 580             ShellFolder sf2 = null;
 581 
 582             if (f1 instanceof ShellFolder) {
 583                 sf1 = (ShellFolder) f1;
 584                 if (sf1.isFileSystem()) {
 585                     sf1 = null;
 586                 }
 587             }
 588             if (f2 instanceof ShellFolder) {




 110      * @since 1.4
 111      */
 112     public File getParentFile() {
 113         if (parent != null) {
 114             return parent;
 115         } else if (isFileSystem()) {
 116             return super.getParentFile();
 117         } else {
 118             return null;
 119         }
 120     }
 121 
 122     public File[] listFiles() {
 123         return listFiles(true);
 124     }
 125 
 126     public File[] listFiles(boolean includeHiddenFiles) {
 127         File[] files = super.listFiles();
 128 
 129         if (!includeHiddenFiles) {
 130             Vector<File> v = new Vector<>();
 131             int nameCount = (files == null) ? 0 : files.length;
 132             for (int i = 0; i < nameCount; i++) {
 133                 if (!files[i].isHidden()) {
 134                     v.addElement(files[i]);
 135                 }
 136             }
 137             files = v.toArray(new File[v.size()]);
 138         }
 139 
 140         return files;
 141     }
 142 
 143 
 144     /**
 145      * @return Whether this shell folder is a link
 146      */
 147     public abstract boolean isLink();
 148 
 149     /**
 150      * @return The shell folder linked to by this shell folder, or null
 151      * if this shell folder is not a link
 152      */
 153     public abstract ShellFolder getLinkLocation() throws FileNotFoundException;
 154 
 155     /**
 156      * @return The name used to display this shell folder
 157      */


 191     }
 192 
 193     /**
 194      * @param getLargeIcon whether to return large icon (ignored in base implementation)
 195      * @return The icon used to display this shell folder
 196      */
 197     public Image getIcon(boolean getLargeIcon) {
 198         return null;
 199     }
 200 
 201 
 202     // Static
 203 
 204     private static ShellFolderManager shellFolderManager;
 205 
 206     private static Invoker invoker;
 207 
 208     static {
 209         String managerClassName = (String)Toolkit.getDefaultToolkit().
 210                                       getDesktopProperty("Shell.shellFolderManager");
 211         Class<?> managerClass = null;
 212         try {
 213             managerClass = ReflectUtil.forName(managerClassName);
 214         // swallow the exceptions below and use default shell folder
 215         } catch(ClassNotFoundException e) {
 216         } catch(NullPointerException e) {
 217         } catch(SecurityException e) {
 218         }
 219 
 220         if (managerClass == null) {
 221             managerClass = ShellFolderManager.class;
 222         }
 223         try {
 224             shellFolderManager =
 225                 (ShellFolderManager)managerClass.newInstance();
 226         } catch (InstantiationException e) {
 227             throw new Error("Could not instantiate Shell Folder Manager: "
 228             + managerClass.getName());
 229         } catch (IllegalAccessException e) {
 230             throw new Error ("Could not access Shell Folder Manager: "
 231             + managerClass.getName());


 537         }
 538     }
 539 
 540     /**
 541      * Interface allowing to invoke tasks in different environments on different platforms.
 542      */
 543     public static interface Invoker {
 544         /**
 545          * Invokes a callable task.
 546          *
 547          * @param task a task to invoke
 548          * @throws Exception {@code InterruptedException} or an exception that was thrown from the {@code task}
 549          * @return the result of {@code task}'s invokation
 550          */
 551         <T> T invoke(Callable<T> task) throws Exception;
 552     }
 553 
 554     /**
 555      * Provides a default comparator for the default column set
 556      */
 557     private static final Comparator<Object> DEFAULT_COMPARATOR = new Comparator<Object>() {
 558         public int compare(Object o1, Object o2) {
 559             int gt;
 560 
 561             if (o1 == null && o2 == null) {
 562                 gt = 0;
 563             } else if (o1 != null && o2 == null) {
 564                 gt = 1;
 565             } else if (o1 == null && o2 != null) {
 566                 gt = -1;
 567             } else if (o1 instanceof Comparable) {
 568                 @SuppressWarnings("unchecked")
 569                 Comparable<Object> o = (Comparable<Object>) o1;
 570                 gt = o.compareTo(o2);
 571             } else {
 572                 gt = 0;
 573             }
 574 
 575             return gt;
 576         }
 577     };
 578 
 579     private static final Comparator<File> FILE_COMPARATOR = new Comparator<File>() {
 580         public int compare(File f1, File f2) {
 581             ShellFolder sf1 = null;
 582             ShellFolder sf2 = null;
 583 
 584             if (f1 instanceof ShellFolder) {
 585                 sf1 = (ShellFolder) f1;
 586                 if (sf1.isFileSystem()) {
 587                     sf1 = null;
 588                 }
 589             }
 590             if (f2 instanceof ShellFolder) {