< prev index next >

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

Print this page

     227         try {
     228             shellFolderManager =
     229                 (ShellFolderManager)managerClass.getDeclaredConstructor().newInstance();
     230         } catch (ReflectiveOperationException e) {
     231             throw new Error("Could not instantiate Shell Folder Manager: "
     232             + managerClass.getName());
     233         }
     234
     235         invoker = shellFolderManager.createInvoker();
     236     }
     237
     238     /**
     239      * Return a shell folder from a file object
     240      * @exception FileNotFoundException if file does not exist
     241      */
     242     public static ShellFolder getShellFolder(File file) throws FileNotFoundException {
     243         if (file instanceof ShellFolder) {
     244             return (ShellFolder)file;
     245         }
     246
     247         if (!Files.exists(Paths.get(file.getPath()), LinkOption.NOFOLLOW_LINKS)) {

     248             throw new FileNotFoundException();
     249         }
     250         return shellFolderManager.createShellFolder(file);
     251     }
     252
     253     /**
     254      * @param key a {@code String}
     255      * @return An Object matching the string {@code key}.
     256      * @see ShellFolderManager#get(String)
     257      */
     258     public static Object get(String key) {
     259         return shellFolderManager.get(key);
     260     }
     261
     262     /**
     263      * Does {@code dir} represent a "computer" such as a node on the network, or
     264      * "My Computer" on the desktop.
     265      */
     266     public static boolean isComputerNode(File dir) {
     267         return shellFolderManager.isComputerNode(dir);
     227         try {
     228             shellFolderManager =
     229                 (ShellFolderManager)managerClass.getDeclaredConstructor().newInstance();
     230         } catch (ReflectiveOperationException e) {
     231             throw new Error("Could not instantiate Shell Folder Manager: "
     232             + managerClass.getName());
     233         }
     234
     235         invoker = shellFolderManager.createInvoker();
     236     }
     237
     238     /**
     239      * Return a shell folder from a file object
     240      * @exception FileNotFoundException if file does not exist
     241      */
     242     public static ShellFolder getShellFolder(File file) throws FileNotFoundException {
     243         if (file instanceof ShellFolder) {
     244             return (ShellFolder)file;
     245         }
     246
     247         try {
     248             if (!Files.exists(Paths.get(file.getCanonicalPath()), LinkOption.NOFOLLOW_LINKS)) {
     249                 throw new FileNotFoundException();
     250             }
     251         } catch (IOException ex) {
     252             throw new FileNotFoundException();
     253         }
     254         return shellFolderManager.createShellFolder(file);
     255     }
     256
     257     /**
     258      * @param key a {@code String}
     259      * @return An Object matching the string {@code key}.
     260      * @see ShellFolderManager#get(String)
     261      */
     262     public static Object get(String key) {
     263         return shellFolderManager.get(key);
     264     }
     265
     266     /**
     267      * Does {@code dir} represent a "computer" such as a node on the network, or
     268      * "My Computer" on the desktop.
     269      */
     270     public static boolean isComputerNode(File dir) {
     271         return shellFolderManager.isComputerNode(dir);

< prev index next >