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

The following examples show how to use java.util.Collections#enumeration() . These examples are extracted from open source projects. 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 Project: IoTgo_Android_App   File: HttpFields.java    License: 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
@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 Project: promregator   File: ParserTest.java    License: 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
@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 Project: JDKSourceCode1.8   File: PropertyPermission.java    License: 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 Project: concierge   File: Event.java    License: 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
@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 Project: Tomcat8-Source-Read   File: RemoteIpFilter.java    License: 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 Project: netbeans   File: CloneableTopComponent.java    License: 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
/**
 * 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 11
Source Project: j2objc   File: CollectionsTest.java    License: 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 12
/**
 * 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 13
Source Project: vertx-vaadin   File: VertxVaadinRequest.java    License: MIT License 4 votes vote down vote up
@Override
public Enumeration<String> getAttributeNames() {
    return Collections.enumeration(routingContext.data().keySet());
}
 
Example 14
Source Project: java-technology-stack   File: MockFilterConfig.java    License: MIT License 4 votes vote down vote up
@Override
public Enumeration<String> getInitParameterNames() {
	return Collections.enumeration(this.initParameters.keySet());
}
 
Example 15
@Override
public Enumeration<String> getHeaderNames() {
    return Collections.enumeration(this.headers.keySet());
}
 
Example 16
Source Project: blog   File: PersonTreeNode.java    License: Apache License 2.0 4 votes vote down vote up
public Enumeration<TreeNode> children() {
	List<TreeNode> addressTreeNodes = getAddressTreeNodes();
	return Collections.enumeration(addressTreeNodes);
}
 
Example 17
@Override
public Enumeration<String> getAttributeNames() {
    return Collections.enumeration(attributes.keySet());
}
 
Example 18
Source Project: apollo   File: OrderedProperties.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Enumeration<?> propertyNames() {
  return Collections.enumeration(propertyNames);
}
 
Example 19
@Override
public Enumeration<String> getAttributeNames() {
	return Collections.enumeration(new LinkedHashSet<>(this.attributes.keySet()));
}
 
Example 20
@Override
public Enumeration<String> getAttributeNames() {
    return Collections.enumeration(attributes.keySet());
}