enumeration ( )源码实例Demo

java.util.Collections#enumeration ( )源码实例Demo

下面列出了java.util.Collections#enumeration ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: IoTgo_Android_App   文件: HttpFields.java
/**
 * 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();
        }
    }; 
}
 
@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);
}
 
源代码3 项目: promregator   文件: ParserTest.java
@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);
}
 
源代码4 项目: rice   文件: ParameterFilter.java
@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);
}
 
源代码5 项目: JDKSourceCode1.8   文件: PropertyPermission.java
/**
 * 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());
    }
}
 
源代码6 项目: concierge   文件: Event.java
@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);
}
 
@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;
}
 
源代码8 项目: Tomcat8-Source-Read   文件: RemoteIpFilter.java
@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());
}
 
源代码9 项目: netbeans   文件: CloneableTopComponent.java
/** 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);
}
 
/**
 * 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);
}
 
源代码11 项目: j2objc   文件: CollectionsTest.java
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);
}
 
源代码12 项目: jdk-1.7-annotated   文件: FilePermission.java
/**
 * 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);
    }
}
 
源代码13 项目: vertx-vaadin   文件: VertxVaadinRequest.java
@Override
public Enumeration<String> getAttributeNames() {
    return Collections.enumeration(routingContext.data().keySet());
}
 
源代码14 项目: java-technology-stack   文件: MockFilterConfig.java
@Override
public Enumeration<String> getInitParameterNames() {
	return Collections.enumeration(this.initParameters.keySet());
}
 
源代码15 项目: teammates   文件: MockHttpServletRequest.java
@Override
public Enumeration<String> getHeaderNames() {
    return Collections.enumeration(this.headers.keySet());
}
 
源代码16 项目: blog   文件: PersonTreeNode.java
public Enumeration<TreeNode> children() {
	List<TreeNode> addressTreeNodes = getAddressTreeNodes();
	return Collections.enumeration(addressTreeNodes);
}
 
源代码17 项目: scipio-erp   文件: LocalHttpServletRequest.java
@Override
public Enumeration<String> getAttributeNames() {
    return Collections.enumeration(attributes.keySet());
}
 
源代码18 项目: apollo   文件: OrderedProperties.java
@Override
public Enumeration<?> propertyNames() {
  return Collections.enumeration(propertyNames);
}
 
源代码19 项目: spring-analysis-note   文件: MockServletContext.java
@Override
public Enumeration<String> getAttributeNames() {
	return Collections.enumeration(new LinkedHashSet<>(this.attributes.keySet()));
}
 
@Override
public Enumeration<String> getAttributeNames() {
    return Collections.enumeration(attributes.keySet());
}