209 static { 210 String managerClassName = (String)Toolkit.getDefaultToolkit(). 211 getDesktopProperty("Shell.shellFolderManager"); 212 Class<?> managerClass = null; 213 try { 214 managerClass = Class.forName(managerClassName, false, null); 215 if (!ShellFolderManager.class.isAssignableFrom(managerClass)) { 216 managerClass = null; 217 } 218 // swallow the exceptions below and use default shell folder 219 } catch(ClassNotFoundException e) { 220 } catch(NullPointerException e) { 221 } catch(SecurityException e) { 222 } 223 224 if (managerClass == null) { 225 managerClass = ShellFolderManager.class; 226 } 227 try { 228 shellFolderManager = 229 (ShellFolderManager)managerClass.newInstance(); 230 } catch (InstantiationException e) { 231 throw new Error("Could not instantiate Shell Folder Manager: " 232 + managerClass.getName()); 233 } catch (IllegalAccessException e) { 234 throw new Error ("Could not access Shell Folder Manager: " 235 + managerClass.getName()); 236 } 237 238 invoker = shellFolderManager.createInvoker(); 239 } 240 241 /** 242 * Return a shell folder from a file object 243 * @exception FileNotFoundException if file does not exist 244 */ 245 public static ShellFolder getShellFolder(File file) throws FileNotFoundException { 246 if (file instanceof ShellFolder) { 247 return (ShellFolder)file; 248 } 249 250 if (!Files.exists(file.toPath(), LinkOption.NOFOLLOW_LINKS)) { 251 throw new FileNotFoundException(); 252 } 253 return shellFolderManager.createShellFolder(file); 254 } | 209 static { 210 String managerClassName = (String)Toolkit.getDefaultToolkit(). 211 getDesktopProperty("Shell.shellFolderManager"); 212 Class<?> managerClass = null; 213 try { 214 managerClass = Class.forName(managerClassName, false, null); 215 if (!ShellFolderManager.class.isAssignableFrom(managerClass)) { 216 managerClass = null; 217 } 218 // swallow the exceptions below and use default shell folder 219 } catch(ClassNotFoundException e) { 220 } catch(NullPointerException e) { 221 } catch(SecurityException e) { 222 } 223 224 if (managerClass == null) { 225 managerClass = ShellFolderManager.class; 226 } 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(file.toPath(), LinkOption.NOFOLLOW_LINKS)) { 248 throw new FileNotFoundException(); 249 } 250 return shellFolderManager.createShellFolder(file); 251 } |