} catch (InterruptedException e) { return null; } } /** * Invokes the {@code task} which throws checked exceptions from its {@code call} method. * If invokation is interrupted then Thread.currentThread().isInterrupted() will * be set and InterruptedException will be thrown as well. */ public static <T, E extends Throwable> T invoke(Callable<T> task, Class<E> exceptionClass) throws InterruptedException, E { try { return invoker.invoke(task); } catch (Exception e) { if (e instanceof RuntimeException) { // Rethrow unchecked exceptions throw (RuntimeException) e; } if (e instanceof InterruptedException) { // Set isInterrupted flag for current thread Thread.currentThread().interrupt(); // Rethrow InterruptedException throw (InterruptedException) e; } if (exceptionClass.isInstance(e)) { throw exceptionClass.cast(e); } throw new RuntimeException("Unexpected error", e); } } /** * Interface allowing to invoke tasks in different environments on different platforms. */ public static interface Invoker { /** * Invokes a callable task. * * @param task a task to invoke * @throws Exception {@code InterruptedException} or an exception that was thrown from the {@code task} * @return the result of {@code task}'s invokation */ <T> T invoke(Callable<T> task) throws Exception; } /** * Provides a default comparator for the default column set */ private static final Comparator DEFAULT_COMPARATOR = new Comparator() { public int compare(Object o1, Object o2) { int gt; if (o1 == null && o2 == null) { gt = 0; } else if (o1 != null && o2 == null) { gt = 1; } else if (o1 == null && o2 != null) { gt = -1; } else if (o1 instanceof Comparable) { gt = ((Comparable) o1).compareTo(o2); } else { gt = 0; } return gt; } }; private static final Comparator<File> FILE_COMPARATOR = new Comparator<File>() { public int compare(File f1, File f2) { ShellFolder sf1 = null; ShellFolder sf2 = null; if (f1 instanceof ShellFolder) { sf1 = (ShellFolder) f1; if (sf1.isFileSystem()) { sf1 = null; } } if (f2 instanceof ShellFolder) { sf2 = (ShellFolder) f2; if (sf2.isFileSystem()) { sf2 = null; } } if (sf1 != null && sf2 != null) { return sf1.compareTo(sf2); } else if (sf1 != null) { // Non-file shellfolders sort before files return -1; } else if (sf2 != null) { return 1; } else { String name1 = f1.getName(); String name2 = f2.getName(); // First ignore case when comparing int diff = name1.compareToIgnoreCase(name2); if (diff != 0) { return diff; } else { // May differ in case (e.g. "mail" vs. "Mail") // We need this test for consistent sorting return name1.compareTo(name2); } } } };}Lines 501–615 of 615. Previous lines
} catch (InterruptedException e) { return null; } } /** * Invokes the {@code task} which throws checked exceptions from its {@code call} method. * If invokation is interrupted then Thread.currentThread().isInterrupted() will * be set and InterruptedException will be thrown as well. */ public static <T, E extends Throwable> T invoke(Callable<T> task, Class<E> exceptionClass) throws InterruptedException, E { try { return invoker.invoke(task); } catch (Exception e) { if (e instanceof RuntimeException) { // Rethrow unchecked exceptions throw (RuntimeException) e; } if (e instanceof InterruptedException) { // Set isInterrupted flag for current thread Thread.currentThread().interrupt(); // Rethrow InterruptedException throw (InterruptedException) e; } if (exceptionClass.isInstance(e)) { throw exceptionClass.cast(e); } throw new RuntimeException("Unexpected error", e); } } /** * Interface allowing to invoke tasks in different environments on different platforms. */ public static interface Invoker { /** * Invokes a callable task. * * @param task a task to invoke * @throws Exception {@code InterruptedException} or an exception that was thrown from the {@code task} * @return the result of {@code task}'s invokation */ <T> T invoke(Callable<T> task) throws Exception; } /** * Provides a default comparator for the default column set */ private static final Comparator DEFAULT_COMPARATOR = new Comparator() { public int compare(Object o1, Object o2) { int gt; if (o1 == null && o2 == null) { gt = 0; } else if (o1 != null && o2 == null) { gt = 1; } else if (o1 == null && o2 != null) { gt = -1; } else if (o1 instanceof Comparable) { gt = ((Comparable) o1).compareTo(o2); } else { gt = 0; } return gt; } }; private static final Comparator<File> FILE_COMPARATOR = new Comparator<File>() { public int compare(File f1, File f2) { ShellFolder sf1 = null; ShellFolder sf2 = null; if (f1 instanceof ShellFolder) { sf1 = (ShellFolder) f1; if (sf1.isFileSystem()) { sf1 = null; } } if (f2 instanceof ShellFolder) { sf2 = (ShellFolder) f2; if (sf2.isFileSystem()) { sf2 = null; } } if (sf1 != null && sf2 != null) { return sf1.compareTo(sf2); } else if (sf1 != null) { // Non-file shellfolders sort before files return -1; } else if (sf2 != null) { return 1; } else { String name1 = f1.getName(); String name2 = f2.getName(); // First ignore case when comparing int diff = name1.compareToIgnoreCase(name2); if (diff != 0) { return diff; } else { // May differ in case (e.g. "mail" vs. "Mail") // We need this test for consistent sorting return name1.compareTo(name2); } } } }; }