/** * Find a root of a logical tree containing this file, if any. * @param file a file on disk * @return an ancestor directory which is the root of a logical tree, * if any (else null) * @since 1.27 */ public static URI findRoot(URI file) { if (!file.equals(file.normalize())) { throw new IllegalArgumentException("Parameter file was not "+ // NOI18N "normalized. Was "+file+" instead of "+file.normalize()); // NOI18N } for (CollocationQueryImplementation2 cqi : implementations2.allInstances()) { URI root = cqi.findRoot(file); if (root != null) { return root; } } if ("file".equals(file.getScheme())) { // NOI18N File f = FileUtil.normalizeFile(Utilities.toFile(file)); for (org.netbeans.spi.queries.CollocationQueryImplementation cqi : implementations.allInstances()) { File root = cqi.findRoot(f); if (root != null) { return Utilities.toURI(root); } } } return null; } }
/** * Find a root of a logical tree containing this file, if any. * @param file a file on disk * @return an ancestor directory which is the root of a logical tree, * if any (else null) * @deprecated Use {@link #findRoot(java.net.URI)} instead. */ @Deprecated public static File findRoot(File file) { if (!file.equals(FileUtil.normalizeFile(file))) { throw new IllegalArgumentException("Parameter file was not "+ // NOI18N "normalized. Was "+file+" instead of "+FileUtil.normalizeFile(file)); // NOI18N } URI uri = Utilities.toURI(file); for (CollocationQueryImplementation2 cqi : implementations2.allInstances()) { URI root = cqi.findRoot(uri); if (root != null) { return Utilities.toFile(root); } } for (org.netbeans.spi.queries.CollocationQueryImplementation cqi : implementations.allInstances()) { File root = cqi.findRoot(file); if (root != null) { return root; } } return null; }