Java Code Examples for java.util.Collections#enumeration()

The following examples show how to use java.util.Collections#enumeration() . 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: HttpFields.java    From IoTgo_Android_App with MIT License 6 votes vote down vote up
/**
 * Get enumeration of header _names. Returns an enumeration of strings representing the header
 * _names for this request.
 */
public Enumeration<String> getFieldNames()
{
    final Enumeration<?> buffers = Collections.enumeration(_names.keySet());
    return new Enumeration<String>()
    {
        public String nextElement()
        {
            return buffers.nextElement().toString();
        }
        
        public boolean hasMoreElements()
        {
            return buffers.hasMoreElements();
        }
    }; 
}
 
Example 2
Source File: StandardMultipartHttpServletRequest.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public Enumeration<String> getParameterNames() {
	if (this.multipartParameterNames == null) {
		initializeMultipart();
	}
	if (this.multipartParameterNames.isEmpty()) {
		return super.getParameterNames();
	}

	// Servlet 3.0 getParameterNames() not guaranteed to include multipart form items
	// (e.g. on WebLogic 12) -> need to merge them here to be on the safe side
	Set<String> paramNames = new LinkedHashSet<String>();
	Enumeration<String> paramEnum = super.getParameterNames();
	while (paramEnum.hasMoreElements()) {
		paramNames.add(paramEnum.nextElement());
	}
	paramNames.addAll(this.multipartParameterNames);
	return Collections.enumeration(paramNames);
}
 
Example 3
Source File: ParserTest.java    From promregator with Apache License 2.0 6 votes vote down vote up
@Test
public void testSimpleWithEFormat() {
	String textToParse = "# Minimalistic line:\n" + 
			"\n"+
			"metric_without_labels 1.7560473e+07\n";
	
	Parser subject = new Parser(textToParse);
	HashMap<String, Collector.MetricFamilySamples> resultMap = subject.parse();
	Enumeration<Collector.MetricFamilySamples> result = Collections.enumeration(resultMap.values());

	// creating expected result
	LinkedList<Collector.MetricFamilySamples> expectedList = new LinkedList<>();

	List<Sample> samples = new LinkedList<>();
	Sample sample = new Sample("metric_without_labels", new LinkedList<String>(), new LinkedList<String>(), 1.7560473e+07);
	samples.add(sample);
	
	Collector.MetricFamilySamples expectedMFS = new Collector.MetricFamilySamples("metric_without_labels", Type.UNTYPED, "", samples);
	expectedList.add(expectedMFS);
	
	Enumeration<Collector.MetricFamilySamples> expected = Collections.enumeration(expectedList);
	
	// compare
	compareEMFS(expected, result);
}
 
Example 4
Source File: ParameterFilter.java    From rice with Educational Community License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings({"rawtypes", "unchecked"})
public Enumeration getParameterNames() {
    List<String> finalParameterNames = new ArrayList<String>();

    ArrayList<String> requestParameterNames = Collections.list(super.getParameterNames());

    for (String parameterName : requestParameterNames) {
        if (!excludeParams.matcher(parameterName).matches()) {
            finalParameterNames.add(parameterName);
        }
    }

    return Collections.enumeration(finalParameterNames);
}
 
Example 5
Source File: PropertyPermission.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Returns an enumeration of all the PropertyPermission objects in the
 * container.
 *
 * @return an enumeration of all the PropertyPermission objects.
 */
@SuppressWarnings("unchecked")
public Enumeration<Permission> elements() {
    // Convert Iterator of Map values into an Enumeration
    synchronized (this) {
        /**
         * Casting to rawtype since Enumeration<PropertyPermission>
         * cannot be directly cast to Enumeration<Permission>
         */
        return (Enumeration)Collections.enumeration(perms.values());
    }
}
 
Example 6
Source File: Event.java    From concierge with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Enumeration<Object> elements() {
	Collection<Object> values = properties.values();
	List<Object> result = new ArrayList<Object>(values.size() + 1);
	result.add(topic);
	result.addAll(values);
	return Collections.enumeration(result);
}
 
Example 7
Source File: PortletRequestWrapperChecker.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public Enumeration<String> getPropertyNames() {
   String meth = "getPropertyNames";
   Object[] args = {};
   String[] strs = { "val1", "val2" };
   Enumeration<String> ret = Collections.enumeration(Arrays.asList(strs));
   retVal = ret;
   checkArgs(meth, args);
   return ret;
}
 
Example 8
Source File: RemoteIpFilter.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public Enumeration<String> getHeaders(String name) {
    Map.Entry<String, List<String>> header = getHeaderEntry(name);
    if (header == null || header.getValue() == null) {
        return Collections.enumeration(Collections.<String>emptyList());
    }
    return Collections.enumeration(header.getValue());
}
 
Example 9
Source File: CloneableTopComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Enumeration of all registered components.
* @return enumeration of CloneableTopComponent
*/
public Enumeration<CloneableTopComponent> getComponents() {
    Set<CloneableTopComponent> components;

    synchronized (LOCK) {
        components = new HashSet<CloneableTopComponent>(componentSet);
    }

    return Collections.enumeration(components);
}
 
Example 10
Source File: FilePermission.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
/**
 * Returns an enumeration of all the FilePermission objects in the
 * container.
 *
 * @return an enumeration of all the FilePermission objects.
 */

public Enumeration elements() {
    // Convert Iterator into Enumeration
    synchronized (this) {
        return Collections.enumeration(perms);
    }
}
 
Example 11
Source File: AuthenticationFrameworkWrapper.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Will return header names which were in original request and will append
 * all the header names which were in authentication request cache entry
 */
@Override
public Enumeration<String> getHeaderNames() {
    List<String> list = new ArrayList<String>();
    for (Enumeration<String> headerNames = super.getHeaderNames(); headerNames.
            hasMoreElements(); ) {
        list.add(headerNames.nextElement());
    }
    for (String keys : modifiableHeaders.keySet()) {
        list.add(keys);
    }
    return Collections.enumeration(list);
}
 
Example 12
Source File: CollectionsTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void test_enumerationLjava_util_Collection() {
    // Test for method java.util.Enumeration
    // java.util.Collections.enumeration(java.util.Collection)
    TreeSet ts = new TreeSet();
    ts.addAll(s);
    Enumeration e = Collections.enumeration(ts);
    int count = 0;
    while (e.hasMoreElements()) {
        assertEquals("Returned incorrect enumeration", e.nextElement(),
                objArray[count++]);
    }
    assertEquals("Enumeration missing elements: " + count, objArray.length,
            count);
}
 
Example 13
Source File: DummyAuthenticationContext.java    From graviteeio-access-management with Apache License 2.0 4 votes vote down vote up
@Override
public Enumeration<String> getAttributeNames() {
    return Collections.enumeration(attributes.keySet());
}
 
Example 14
Source File: VertxVaadinRequest.java    From vertx-vaadin with MIT License 4 votes vote down vote up
@Override
public Enumeration<String> getAttributeNames() {
    return Collections.enumeration(routingContext.data().keySet());
}
 
Example 15
Source File: MockServletContext.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public Enumeration<String> getAttributeNames() {
	return Collections.enumeration(new LinkedHashSet<>(this.attributes.keySet()));
}
 
Example 16
Source File: OrderedProperties.java    From apollo with Apache License 2.0 4 votes vote down vote up
@Override
public Enumeration<?> propertyNames() {
  return Collections.enumeration(propertyNames);
}
 
Example 17
Source File: LocalHttpServletRequest.java    From scipio-erp with Apache License 2.0 4 votes vote down vote up
@Override
public Enumeration<String> getAttributeNames() {
    return Collections.enumeration(attributes.keySet());
}
 
Example 18
Source File: PersonTreeNode.java    From blog with Apache License 2.0 4 votes vote down vote up
public Enumeration<TreeNode> children() {
	List<TreeNode> addressTreeNodes = getAddressTreeNodes();
	return Collections.enumeration(addressTreeNodes);
}
 
Example 19
Source File: MockHttpServletRequest.java    From teammates with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Enumeration<String> getHeaderNames() {
    return Collections.enumeration(this.headers.keySet());
}
 
Example 20
Source File: MockFilterConfig.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public Enumeration<String> getInitParameterNames() {
	return Collections.enumeration(this.initParameters.keySet());
}