Example usage for java.util Collections enumeration

List of usage examples for java.util Collections enumeration

Introduction

In this page you can find the example usage for java.util Collections enumeration.

Prototype

public static <T> Enumeration<T> enumeration(final Collection<T> c) 

Source Link

Document

Returns an enumeration over the specified collection.

Usage

From source file:nl.armatiek.xslweb.web.servlet.XSLWebHttpServletRequest.java

@Override
public Enumeration<String> getAttributeNames() {
    return Collections.enumeration(new ArrayList<String>());
}

From source file:org.nuxeo.osgi.JarBundleFile.java

@Override
public Enumeration<URL> findEntries(String name, String pattern, boolean recurse) {
    if (name.startsWith("/")) {
        name = name.substring(1);/*from   w w w  .j  av a  2  s  .  co  m*/
    }
    String prefix;
    if (name.length() == 0) {
        name = null;
        prefix = "";
    } else if (!name.endsWith("/")) {
        prefix = name + "/";
    } else {
        prefix = name;
    }
    int len = prefix.length();
    EntryFilter filter = EntryFilter.newFilter(pattern);
    Enumeration<JarEntry> entries = jarFile.entries();
    ArrayList<URL> result = new ArrayList<URL>();
    try {
        while (entries.hasMoreElements()) {
            JarEntry entry = entries.nextElement();
            if (entry.isDirectory()) {
                continue;
            }
            String ename = entry.getName();
            if (name != null && !ename.startsWith(prefix)) {
                continue;
            }
            int i = ename.lastIndexOf('/');
            if (!recurse) {
                if (i > -1) {
                    if (ename.indexOf('/', len) > -1) {
                        continue;
                    }
                }
            }
            String n = i > -1 ? ename.substring(i + 1) : ename;
            if (filter.match(n)) {
                result.add(getEntryUrl(ename));
            }
        }
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    }
    return Collections.enumeration(result);
}

From source file:org.romaframework.core.resource.ResourceResolver.java

/**
 * Search the resource in the specified package if the package is "" find all class in current classloader jars.
 * /*  w  ww  . j  a v  a2s .c o m*/
 * @param iStartingPackage
 *          the package to find.
 */
public void loadResources(String iStartingPackage) {
    File f;
    log.debug("[ResourceResolver.loadEntities] loading Resources for: " + iStartingPackage);
    // ClassLoader classLoader = getClass().getClassLoader();
    try {
        String path = iStartingPackage.replace(PACKAGE_SEPARATOR, JAR_PATH_SEPARATOR);
        Enumeration<URL> esploringPackage;
        if (path.length() == 0 && classLoader instanceof URLClassLoader) {
            esploringPackage = Collections.enumeration(Arrays.asList(((URLClassLoader) classLoader).getURLs()));
        } else {
            esploringPackage = classLoader.getResources(path);
        }
        while (esploringPackage.hasMoreElements()) {
            URL url = esploringPackage.nextElement();
            String file = url.getPath();
            file = URLDecoder.decode(file, "UTF-8");
            if (file.startsWith(Utility.FILE_PREFIX)) {
                file = file.substring(Utility.FILE_PREFIX.length());
            }
            if (file.contains(JAR_SUFFIX)) {
                file = file.substring(0, file.indexOf(JAR_SUFFIX) + JAR_SUFFIX.length());
                f = new File(file);
                if (acceptArchives(f.getName()) && f.exists()) {
                    log.debug("[ResourceResolver.loadEntities] > Inspecting jar: " + file);
                    examineJarFile(f, iStartingPackage);
                }
            } else {
                f = new File(file);
                if (f.exists() && f.isDirectory()) {
                    log.debug("[ResourceResolver.loadEntities] > Inspecting path: " + file);
                    addFiles(f.listFiles(), iStartingPackage + PACKAGE_SEPARATOR, iStartingPackage);
                }
            }
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    log.debug("[ResourceResolver.loadEntities] End of loading resources for: " + iStartingPackage);
}

From source file:com.ocpsoft.pretty.faces.url.QueryString.java

/**
 * Get the list of parameter names currently stored in this query string..
 *//*from   w  w w.  j  a va 2s . c  o  m*/
public Enumeration<String> getParameterNames() {
    return Collections.enumeration(parameters.keySet());
}

From source file:uk.ac.ebi.atlas.web.controllers.rest.GeneNameTooltipController.java

String format(Collection<String> values, boolean returnEmptyValuesAsNA, int restrictListLengthTo) {
    if (CollectionUtils.isEmpty(values)) {
        return returnEmptyValuesAsNA ? "NA" : StringUtils.EMPTY;
    }/*from   ww  w.  jav a  2s.c  om*/
    List<String> subList;
    if (values.size() > restrictListLengthTo) {
        subList = Collections.list(Collections.enumeration(values)).subList(0, restrictListLengthTo);
        subList.add("(...and " + values.size() + " more)");
    } else {
        subList = Collections.list(Collections.enumeration(values));
    }

    return WORD_SPAN_OPEN + Joiner.on(WORD_SPAN_CLOSE + " " + WORD_SPAN_OPEN).join(subList) + WORD_SPAN_CLOSE;
}

From source file:net.mymam.upload.UploadMultipartRequestWrapper.java

@Override
public Enumeration getParameterNames() {
    Set<String> paramNames = new LinkedHashSet<String>();
    paramNames.addAll(formParameters.keySet());
    Enumeration<String> original = super.getParameterNames();
    while (original.hasMoreElements()) {
        paramNames.add(original.nextElement());
    }//from  w w w .ja v a 2  s. c  o m
    return Collections.enumeration(paramNames);
}

From source file:org.infoglue.deliver.applications.filters.PortalServletRequest.java

public Enumeration getParameterNames() {
    return Collections.enumeration(paramMap.keySet());
}

From source file:org.apereo.portal.portlet.container.PortalContextImpl.java

@Override
public Enumeration<WindowState> getSupportedWindowStates() {
    return Collections.enumeration(this.windowStates);
}

From source file:org.opennms.netmgt.xml.eventconf.Varbind.java

/**
 * Method enumerateVbvalue.//ww  w . j  a  va 2s  .c  o  m
 * 
 * @return an Enumeration over all possible elements of this
 * collection
 */
public Enumeration<String> enumerateVbvalue() {
    return Collections.enumeration(this.vbvalueList);
}

From source file:net.lightbody.bmp.proxy.jetty.jetty.servlet.Holder.java

public Enumeration getInitParameterNames() {
    if (_initParams == null)
        return Collections.enumeration(Collections.EMPTY_LIST);
    return Collections.enumeration(_initParams.keySet());
}