Java Code Examples for org.openide.util.Enumerations#concat()

The following examples show how to use org.openide.util.Enumerations#concat() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractFileSystemCompat.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Deprecated
public FileObject find(String aPackage, String name, String ext) {
    // create enumeration of name to look for
    Enumeration<String> st = NbCollections.checkedEnumerationByFilter(new StringTokenizer(aPackage, "."), String.class, true); // NOI18N

    if ((name == null) || (ext == null)) {
        // search for folder, return the object only if it is folder
        FileObject fo = afs().getAbstractRoot().find(st);

        return ((fo != null) && fo.isFolder()) ? fo : null;
    } else {
        Enumeration<String> en = Enumerations.concat(st, Enumerations.singleton(name + '.' + ext));

        // tries to find it (can return null)
        return afs().getAbstractRoot().find(en);
    }
}
 
Example 2
Source File: AntBridge.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Enumeration<URL> getResources(String name) throws IOException {
    Enumeration<URL> res =  super.getResources(name);
    if (isFromContextClassLoader(name, false)) {
        final Enumeration<URL> cclRes = contextClassLoader.getResources(name);
        res = Enumerations.concat(res, cclRes);
    }
    return res;
}
 
Example 3
Source File: OSGiClassLoader.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected @Override Enumeration<URL> findResources(String name) throws IOException {
    List<Enumeration<URL>> resourcess = new ArrayList<Enumeration<URL>>();
    for (Bundle b : bundles()) {
        Enumeration<?> resourcesRaw = b.getResources(name);
        if (resourcesRaw == null) {
            // Oddly, this is permitted.
            continue;
        }
        Enumeration<URL> resources = NbCollections.checkedEnumerationByFilter(resourcesRaw, URL.class, true);
        if (resources != null) {
            resourcess.add(resources);
        }
    }
    return Enumerations.concat(Collections.enumeration(resourcess));
}
 
Example 4
Source File: MultiFileSystem.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Deprecated // have to override for compat
public @Override FileObject find(String aPackage, String name, String ext) {
    // create enumeration of name to look for
    Enumeration<String> st = NbCollections.checkedEnumerationByFilter(new StringTokenizer(aPackage, "."), String.class, true); // NOI18N
    Enumeration<String> en;

    if ((name == null) || (ext == null)) {
        en = st;
    } else {
        en = Enumerations.concat(st, Enumerations.singleton(name + '.' + ext));
    }

    // tries to find it (can return null)
    return getMultiRoot().find(en);
}
 
Example 5
Source File: ProxyClassLoader.java    From netbeans with Apache License 2.0 4 votes vote down vote up
synchronized Enumeration<URL> getResourcesImpl(String name) throws IOException {
    name = stripInitialSlash(name);
    final int slashIdx = name.lastIndexOf('/');
    final String path = name.substring(0, slashIdx + 1);
    String pkg;
    String fallDef = null;
    if (slashIdx >= 0) {
        if (name.startsWith("META-INF/")) {
            pkg = name.substring(8);
            fallDef = name.substring(0, slashIdx).replace('/', '.');
        } else {
            pkg = name.substring(0, slashIdx).replace('/', '.');
        }
    } else {
        pkg = "default/" + name;
        fallDef = "";
    }
    List<Enumeration<URL>> sub = new ArrayList<Enumeration<URL>>();

    // always consult SCL first
    if (shouldDelegateResource(path, null)) sub.add(parents.systemCL().getResources(name));
    
    Set<ProxyClassLoader> del = ProxyClassPackages.findCoveredPkg(pkg);
    if (fallDef != null) {
        Set<ProxyClassLoader> snd = ProxyClassPackages.findCoveredPkg(fallDef);
        if (snd != null) {
            if (del != null) {
                del = new HashSet<ProxyClassLoader>(del);
                del.addAll(snd);
            } else {
                del = snd;
            }
        }
    }

    if (del != null) {
        for (ProxyClassLoader pcl : parents.loaders()) { // all our accessible parents
            if (del.contains(pcl) && shouldDelegateResource(path, pcl)) { // that cover given package
                sub.add(pcl.findResources(name));
            }
        }
        if (del.contains(this)) {
            sub.add(findResources(name));
        }
    }
    // Should not be duplicates, assuming the parent loaders are properly distinct
    // from one another and do not overlap in JAR usage, which they ought not.
    // Anyway MetaInfServicesLookup, the most important client of this method, does
    // its own duplicate filtering already.
    return Enumerations.concat(Collections.enumeration(sub));
}
 
Example 6
Source File: ValidateLayerConsistencyTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testAreAttributesFine () {
    List<String> errors = new ArrayList<String>();
    
    FileObject root = FileUtil.getConfigRoot();
    Enumeration<? extends FileObject> files = Enumerations.concat(Enumerations.singleton(root), root.getChildren(true));
    while (files.hasMoreElements()) {
        FileObject fo = files.nextElement();
        
        if (
            "Keymaps/NetBeans/D-BACK_QUOTE.shadow".equals(fo.getPath()) ||
            "Keymaps/NetBeans55/D-BACK_QUOTE.shadow".equals(fo.getPath()) ||
            "Keymaps/Emacs/D-BACK_QUOTE.shadow".equals(fo.getPath())
        ) {
            // #46753
            continue;
        }
        if (
            "Services/Browsers/FirefoxBrowser.settings".equals(fo.getPath()) ||
            "Services/Browsers/MozillaBrowser.settings".equals(fo.getPath()) ||
            "Services/Browsers/NetscapeBrowser.settings".equals(fo.getPath())
        ) {
            // #161784
            continue;
        }
        
        Enumeration<String> attrs = fo.getAttributes();
        while (attrs.hasMoreElements()) {
            String name = attrs.nextElement();

            if (isInstanceAttribute(name)) {
                continue;
            }
            
            if (name.indexOf('\\') != -1) {
                errors.add("File: " + fo.getPath() + " attribute name must not contain backslashes: " + name);
            }
            
            Object attr = fo.getAttribute(name);
            if (attr == null) {
                CharSequence warning = Log.enable("", Level.WARNING);
                if (
                    fo.getAttribute("class:" + name) != null &&
                    fo.getAttribute(name) == null &&
                    warning.length() == 0
                ) {
                    // ok, factory method returned null
                    continue;
                }

                errors.add("File: " + fo.getPath() + " attribute name: " + name);
            }

            if (attr instanceof URL) {
                URL u = (URL) attr;
                int read = -1;
                try {
                    read = u.openStream().read(new byte[4096]);
                } catch (IOException ex) {
                    errors.add(fo.getPath() + ": " + ex.getMessage());
                }
                if (read <= 0) {
                    errors.add("URL resource does not exist: " + fo.getPath() + " attr: " + name + " value: " + attr);
                }
            }

        }
    }
    
    assertNoErrors("Some attributes in files are unreadable", errors);
}
 
Example 7
Source File: EnumerationsTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected <T> Enumeration<T> concat(Enumeration<T> en1, Enumeration<T> en2) {
    return Enumerations.concat(en1, en2);
}
 
Example 8
Source File: EnumerationsTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected <T> Enumeration<T> concat(Enumeration<Enumeration<T>> enumOfEnums) {
    return Enumerations.concat(enumOfEnums);
}
 
Example 9
Source File: Snapshot.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Enumeration concat(Enumeration en1, Enumeration en2) {
    return Enumerations.concat(en1, en2);
}
 
Example 10
Source File: NodeInfo.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Enumeration<FxNode> getEnclosedNodes() {
    return Enumerations.concat(Collections.enumeration(attributes), Collections.enumeration(children));
}
 
Example 11
Source File: Snapshot.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
public Enumeration concat(Enumeration en1, Enumeration en2) {
    return Enumerations.concat(en1, en2);
}