List of usage examples for org.apache.commons.collections EnumerationUtils toList
public static List toList(Enumeration enumeration)
From source file:org.apache.cocoon.jxpath.CocoonSessionHandler.java
public String[] getPropertyNames(Object session) { final Enumeration e = ((Session) session).getAttributeNames(); return (String[]) EnumerationUtils.toList(e).toArray(); }
From source file:org.apache.usergrid.rest.security.shiro.session.HttpServletRequestSession.java
@SuppressWarnings({ "unchecked" }) @Override//from www.j av a 2 s.c o m public Collection<Object> getAttributeKeys() throws InvalidSessionException { return EnumerationUtils.toList(request.getAttributeNames()); }
From source file:org.apereo.portal.portlet.container.services.AbstractPortletPreferencesImplTest.java
@Test public void testGetNames() throws ReadOnlyException, ValidatorException, IOException { addPref(basePrefs, "key", false, new String[] { "default" }); addPref(basePrefs, "key1", false, new String[] { "default" }); Enumeration<String> names = portletPreferences.getNames(); assertEquals(ImmutableSet.of("key", "key1"), new HashSet<String>(EnumerationUtils.toList(names))); //Set a modified value portletPreferences.setValues("key", new String[] { "modified" }); portletPreferences.setValues("key3", new String[] { "modified" }); names = portletPreferences.getNames(); assertEquals(ImmutableSet.of("key", "key1", "key3"), new HashSet<String>(EnumerationUtils.toList(names))); //Initial store, check that correct stored map is created portletPreferences.store();/*from w w w . java 2s.c om*/ //Actually "store" the stored prefs this.targetPrefs = new LinkedHashMap<String, IPortletPreference>(this.storedPrefs); names = portletPreferences.getNames(); assertEquals(ImmutableSet.of("key", "key1", "key3"), new HashSet<String>(EnumerationUtils.toList(names))); portletPreferences.reset("key3"); names = portletPreferences.getNames(); assertEquals(ImmutableSet.of("key", "key1"), new HashSet<String>(EnumerationUtils.toList(names))); //Initial store, check that correct stored map is created portletPreferences.store(); //Actually "store" the stored prefs this.targetPrefs = new LinkedHashMap<String, IPortletPreference>(this.storedPrefs); names = portletPreferences.getNames(); assertEquals(ImmutableSet.of("key", "key1"), new HashSet<String>(EnumerationUtils.toList(names))); }
From source file:org.debux.webmotion.server.call.ClientSessionTest.java
@Test public void testGetAttributeNames() { Enumeration<String> attributeNames = session.getAttributeNames(); AssertJUnit.assertFalse(attributeNames.hasMoreElements()); session.setAttribute("name1", "value"); session.setAttribute("name2", "value"); session.setAttribute("name3", "value"); attributeNames = session.getAttributeNames(); AssertJUnit.assertEquals(3, EnumerationUtils.toList(attributeNames).size()); }
From source file:org.geoserver.wms.map.GetMapKvpRequestReader.java
@SuppressWarnings("unchecked") @Override/*from w ww . j a v a 2 s . com*/ public GetMapRequest createRequest() throws Exception { GetMapRequest request = new GetMapRequest(); if (httpRequest != null) { request.setRequestCharset(httpRequest.getCharacterEncoding()); request.setGet("GET".equalsIgnoreCase(httpRequest.getMethod())); List<String> headerNames = (List<String>) EnumerationUtils.toList(httpRequest.getHeaderNames()); for (String headerName : headerNames) { request.putHttpRequestHeader(headerName, httpRequest.getHeader(headerName)); } } return request; }
From source file:org.iplantc.persondir.support.ldap.AttributesMapperImpl.java
/** * Convert the Attribute's NamingEnumeration of values into a List * /*from ww w .j a v a 2 s . c o m*/ * @param values The enumeration of Attribute values * @return The List version of the values enumeration */ protected List<?> getAttributeValues(NamingEnumeration<?> values) { return EnumerationUtils.toList(values); }
From source file:org.jahia.bundles.extender.jahiamodules.BundleHttpResourcesTracker.java
@SuppressWarnings("unchecked") static List<URL> getJsps(Bundle bundle) { Enumeration<?> jsps = bundle.findEntries("/", "*.jsp", true); if (jsps != null && jsps.hasMoreElements()) { return EnumerationUtils.toList(jsps); }/*from ww w. j a v a 2 s . c o m*/ return Collections.emptyList(); }
From source file:org.jahia.services.applications.pluto.JahiaPortletUtil.java
/** * Remove from request useless attributes * * @param portalRequest/*from ww w.j av a 2s .co m*/ * @return */ public static Map<String, Object> filterJahiaAttributes(HttpServletRequest portalRequest) { HashMap<String, Object> map = new HashMap<String, Object>(); @SuppressWarnings("unchecked") List<String> names = EnumerationUtils.toList(portalRequest.getAttributeNames()); for (String key : names) { if (isSpringAttribute(key)) { Object value = portalRequest.getAttribute(key); map.put(key, value); portalRequest.removeAttribute(key); } } return map; }
From source file:org.jahia.taglibs.functions.Functions.java
/** * Joins the elements of the provided array/collection/iterator into a single String containing the provided elements with specified * separator.//from w ww .j av a2 s . com * * @param elements * the set of values to join together, may be null * @param separator * the separator character to use, null treated as "" * @return the joined String, <code>null</code> if null elements input */ public static String join(Object elements, String separator) { if (elements == null) { return null; } if (elements instanceof Object[]) { return StringUtils.join((Object[]) elements, separator); } else if (elements instanceof Collection<?>) { return StringUtils.join((Collection<?>) elements, separator); } else if (elements instanceof Iterator<?>) { return StringUtils.join((Iterator<?>) elements, separator); } else if (elements instanceof Enumeration<?>) { return StringUtils.join(EnumerationUtils.toList((Enumeration<?>) elements), separator); } else if (elements instanceof Map<?, ?>) { return StringUtils.join(((Map<?, ?>) elements).keySet(), separator); } else if (elements instanceof String) { return (String) elements; } throw new IllegalArgumentException("Cannot handle the elements of type " + elements.getClass().getName()); }
From source file:org.kuali.rice.ksb.messaging.servlet.KSBDispatcherServlet.java
/** * This is a workaround after upgrading to CXF 2.7.0 whereby we could no longer just call "setHideServiceList" on * the ServletController. Instead, it is now reading this information from the ServletConfig, so wrapping the base * ServletContext to return true or false for hide service list depending on whether or not we are in dev mode. *///w ww. java2s . c om protected ServletConfig getCXFServletConfig(final ServletConfig baseServletConfig) { // disable handling of URLs ending in /services which display CXF generated service lists if we are not in dev mode final String shouldHide = Boolean .toString(!ConfigContext.getCurrentContextConfig().getDevMode().booleanValue()); return new ServletConfig() { private static final String HIDE_SERVICE_LIST_PAGE_PARAM = "hide-service-list-page"; @Override public String getServletName() { return baseServletConfig.getServletName(); } @Override public ServletContext getServletContext() { return baseServletConfig.getServletContext(); } @Override public String getInitParameter(String parameter) { if (HIDE_SERVICE_LIST_PAGE_PARAM.equals(parameter)) { return shouldHide; } return baseServletConfig.getInitParameter(parameter); } @Override public Enumeration<String> getInitParameterNames() { List<String> initParameterNames = EnumerationUtils .toList(baseServletConfig.getInitParameterNames()); initParameterNames.add(HIDE_SERVICE_LIST_PAGE_PARAM); return new Vector<String>(initParameterNames).elements(); } }; }