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:org.projectforge.web.UserFilter.java

/**
 * @param request//from   w  w w  .j a v a 2s  .c  o m
 * @param user
 * @return
 */
protected HttpServletRequest decorateWithLocale(HttpServletRequest request, final PFUserDO user) {
    final Locale locale = PFUserContext.getLocale(request.getLocale());
    request = new HttpServletRequestWrapper(request) {
        @Override
        public Locale getLocale() {
            return locale;
        }

        @Override
        public Enumeration<?> getLocales() {
            return Collections.enumeration(Collections.singleton(locale));
        }
    };
    return request;
}

From source file:jetbrains.buildServer.server.rest.APIController.java

private HttpServletRequest modifyRequestHeader(final HttpServletRequest request, final String headerName,
        final String newValue) {
    return new HttpServletRequestWrapper(request) {
        @Override//w  w w .ja v  a 2s  .  co  m
        public String getHeader(final String name) {
            if (headerName.equalsIgnoreCase(name)) {
                return newValue;
            }
            return super.getHeader(name);
        }

        @Override
        public Enumeration getHeaders(final String name) {
            if (headerName.equalsIgnoreCase(name)) {
                return Collections.enumeration(Collections.singletonList(newValue));
            }
            return super.getHeaders(name);
        }
    };
}

From source file:com.netxforge.oss2.xml.event.Event.java

/**
 * Method enumerateOperaction./*ww w  .ja  v  a  2 s  .c  o  m*/
 * 
 * @return an Enumeration over all possible elements of this collection
 */
public Enumeration<Operaction> enumerateOperaction() {
    return Collections.enumeration(_operactionList);
}

From source file:org.exist.util.io.FastByteArrayOutputStream.java

/**
 * Similar to {@link #toInputStream()}/*from w  ww.j ava  2 s .  c o  m*/
 * but utilises {@link FastByteArrayInputStream}
 * as opposed to {@link java.io.ByteArrayInputStream}.
 */
public /*synchronized*/ InputStream toFastByteInputStream() {
    int remaining = count;
    if (remaining == 0) {
        return new ClosedInputStream();
    }
    final List<FastByteArrayInputStream> list = new ArrayList<>(buffers.size());
    for (final byte[] buf : buffers) {
        final int c = Math.min(buf.length, remaining);
        list.add(new FastByteArrayInputStream(buf, 0, c));
        remaining -= c;
        if (remaining == 0) {
            break;
        }
    }
    reuseBuffers = false;
    return new SequenceInputStream(Collections.enumeration(list));
}

From source file:com.netxforge.oss2.xml.event.Event.java

/**
 * Method enumerateScript./*from   w w  w . java2 s.c o m*/
 * 
 * @return an Enumeration over all possible elements of this collection
 */
public Enumeration<Script> enumerateScript() {
    return Collections.enumeration(_scriptList);
}

From source file:de.micromata.genome.tpsb.httpmockup.MockHttpServletRequest.java

/** Gets an enumeration of all request attribute names. */
@Override//  w w w.ja v  a 2  s. co m
public Enumeration getAttributeNames() {
    return Collections.enumeration(this.attributes.keySet());
}

From source file:org.projectforge.business.user.filter.UserFilter.java

/**
 * @param request//from   w w  w.  ja v a 2 s . co m
 * @return
 */
protected HttpServletRequest decorateWithLocale(HttpServletRequest request) {
    final Locale locale = ThreadLocalUserContext.getLocale(request.getLocale());
    request = new HttpServletRequestWrapper(request) {
        @Override
        public Locale getLocale() {
            return locale;
        }

        @Override
        public Enumeration<Locale> getLocales() {
            return Collections.enumeration(Collections.singleton(locale));
        }
    };
    return request;
}

From source file:org.exist.http.servlets.HttpRequestWrapper.java

/**
 * @see javax.servlet.http.HttpServletRequest#getParameterNames()
 *///from   ww  w.j ava2  s  .  co  m
@Override
public Enumeration getParameterNames() {
    return Collections.enumeration(params.keySet());
}

From source file:org.apache.openaz.xacml.std.pap.StdPDPGroup.java

@Override
public Properties getPolicyProperties() {
    Properties properties = new Properties() {
        private static final long serialVersionUID = 1L;

        // For Debugging it is helpful for the file to be in a sorted order,
        // any by returning the keys in the natural Alpha order for strings we get close enough.
        // TreeSet is sorted, and this just overrides the normal Properties method to get the keys.
        @Override//from www  .ja va2s  . co m
        public synchronized Enumeration<Object> keys() {
            return Collections.enumeration(new TreeSet<Object>(super.keySet()));
        }
    };

    List<String> roots = new ArrayList<String>();
    List<String> refs = new ArrayList<String>();

    for (PDPPolicy policy : this.policies) {
        // for all policies need to tell PDP the "name", which is the base name for the file id
        if (policy.getName() != null) {
            properties.setProperty(policy.getId() + ".name", policy.getName());
        }
        // put the policy on the correct list
        if (policy.isRoot()) {
            roots.add(policy.getId());
        } else {
            refs.add(policy.getId());
        }
    }

    properties.setProperty(XACMLProperties.PROP_ROOTPOLICIES, Joiner.on(',').join(roots));
    properties.setProperty(XACMLProperties.PROP_REFERENCEDPOLICIES, Joiner.on(',').join(refs));

    return properties;
}

From source file:com.thoughtworks.go.http.mocks.MockServletContext.java

@Override
@Deprecated
public Enumeration<Servlet> getServlets() {
    return Collections.enumeration(Collections.emptySet());
}