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.esigate.servlet.MockHttpServletRequestBuilder.java

/**
 * Build the request as defined in the current builder.
 * //  w ww  .jav  a  2s.  c  om
 * @return the request
 */
public HttpServletRequest build() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);

    Mockito.when(request.getMethod()).thenReturn(this.method);
    Mockito.when(request.getProtocol()).thenReturn(this.protocolVersion);
    Mockito.when(request.getRequestURI()).thenReturn(this.uriString);

    Mockito.when(request.getHeaderNames()).thenReturn(Collections.enumeration(headers));
    for (Header h : headers) {
        List<String> hresult = new ArrayList<String>();
        hresult.add(h.getValue());
        Mockito.when(request.getHeaders(h.getName())).thenReturn(Collections.enumeration(hresult));
        Mockito.when(request.getHeader(h.getName())).thenReturn(h.getValue());
    }

    if (session == null) {
        Mockito.when(request.getSession()).thenReturn(null);
    } else {
        HttpSession sessionMock = Mockito.mock(HttpSession.class);
        Mockito.when(request.getSession()).thenReturn(sessionMock);
    }
    return request;
}

From source file:org.springframework.portlet.ParameterAddingPortletRequestWrapper.java

@Override
public Enumeration<String> getParameterNames() {
    final Map<String, String[]> parameterMap = this.getParameterMap();
    return Collections.enumeration(parameterMap.keySet());
}

From source file:com.adobe.acs.commons.http.headers.impl.AbstractExpiresHeaderFilterTest.java

@Before
public void setup() throws Exception {
    properties = new Hashtable<String, Object>();
    properties.put(AbstractExpiresHeaderFilter.PROP_EXPIRES_TIME, exipres);

    agents = new HashSet<String>();
    expires = new HashSet<String>();
    params = new HashMap();

    filter = new AbstractExpiresHeaderFilter() {
        @Override//from   ww  w. j  a  v  a2s . c om
        protected void adjustExpires(Calendar nextExpiration) {
            // Do nothing.
        }
    };

    when(request.getMethod()).thenReturn("GET");
    when(request.getParameterMap()).thenReturn(params);
    agents.add(AbstractDispatcherCacheHeaderFilter.DISPATCHER_AGENT_HEADER_VALUE);
    when(request.getHeaders(AbstractDispatcherCacheHeaderFilter.SERVER_AGENT_NAME))
            .thenReturn(Collections.enumeration(agents));

}

From source file:com.steeleforge.aem.ironsites.i18n.I18nResourceBundle.java

@Override
public Enumeration<String> getKeys() {
    Set<String> names = new HashSet<String>();
    if (null != parent) {
        names.addAll(Collections.list(parent.getKeys()));
    }/* ww w  .  j  av  a 2  s.  co m*/
    if (null != bundle) {
        names.addAll(Collections.list(bundle.getKeys()));
    }
    if (null != content && null != content.keySet()) {
        names.addAll(content.keySet());
    }
    return Collections.enumeration(names);
}

From source file:alpha.portal.webapp.filter.LocaleRequestWrapper.java

/**
 * {@inheritDoc}/*  w ww.  jav  a 2 s  . c om*/
 */
@Override
@SuppressWarnings("unchecked")
public Enumeration<Locale> getLocales() {
    if (null != this.preferredLocale) {
        final List<Locale> l = Collections.list(super.getLocales());
        if (l.contains(this.preferredLocale)) {
            l.remove(this.preferredLocale);
        }
        l.add(0, this.preferredLocale);
        return Collections.enumeration(l);
    } else
        return super.getLocales();
}

From source file:com.twinsoft.convertigo.engine.util.HttpServletRequestTwsWrapper.java

public Enumeration<String> getParameterNames() {
    return Collections.enumeration(parameters.keySet());
}

From source file:com.github.horrorho.inflatabledonkey.pcs.xfile.FileAssembler.java

static InputStream inputStream(List<Chunk> chunkData) throws UncheckedIOException {
    List<InputStream> inputStreams = chunkData.stream().map(Chunk::inputStream).collect(Collectors.toList());

    Enumeration<InputStream> enumeration = Collections.enumeration(inputStreams);
    return new BufferedInputStream(new SequenceInputStream(enumeration), BUFFER_SIZE);
}

From source file:org.wso2.carbon.identity.auth.service.AuthenticationRequest.java

public Enumeration<String> getHeaderNames() {
    return Collections.enumeration(headers.keySet());
}

From source file:org.directwebremoting.util.FakeHttpServletRequest.java

public Enumeration<String> getHeaders(String name) {
    return Collections.enumeration(Collections.<String>emptySet());
}

From source file:com.vaushell.gfmongodb.MongoDbUserRealm.java

@Override
public Enumeration getGroupNames(final String username) {
    final QueryBuilder builder = QueryBuilder.start(getProperty(PARAM_USERNAME)).is(username);
    final DBObject user = usersCollection.findOne(builder.get());
    if (user == null) {
        return null;
    }//from  ww  w. j av  a  2 s  .c  o m

    return Collections.enumeration(getGroups(user));
}