List of usage examples for java.util Collections enumeration
public static <T> Enumeration<T> enumeration(final Collection<T> c)
From source file:org.java.plugin.standard.StandardPluginClassLoader.java
/** * @see java.lang.ClassLoader#findResources(java.lang.String) *//* w w w .j a v a 2s . c o m*/ public Enumeration findResources(final String name) throws IOException { List result = new LinkedList(); findResources(result, name, this, null); return Collections.enumeration(result); }
From source file:org.apache.openaz.xacml.std.pap.StdEngine.java
private void saveConfiguration() throws PAPException, IOException { ///*from ww w.j a v a2 s . com*/ // Create our properties object // Properties properties = new Properties() { private static final long serialVersionUID = 1L; // For Debugging it is helpful for the file to be in a sorted order, // any by returning the keys in the natural Alpha order for strings we get close enough. // TreeSet is sorted, and this just overrides the normal Properties method to get the keys. @Override public synchronized Enumeration<Object> keys() { return Collections.enumeration(new TreeSet<Object>(super.keySet())); } }; // // Iterate our groups // List<String> ids = new ArrayList<String>(); for (PDPGroup group : this.groups) { ids.add(group.getId()); properties.setProperty(group.getId() + ".name", (group.getName() == null ? "" : group.getName())); properties.setProperty(group.getId() + ".description", (group.getDescription() == null ? "" : group.getDescription())); // // Iterate its PDPs // List<String> pdps = new ArrayList<String>(); for (PDP pdp : group.getPdps()) { pdps.add(pdp.getId()); properties.setProperty(pdp.getId() + ".name", (pdp.getName() == null ? "" : pdp.getName())); properties.setProperty(pdp.getId() + ".description", (pdp.getDescription() == null ? "" : pdp.getDescription())); } String pdpList = ""; if (pdps.size() == 1) { pdpList = pdps.get(0); } else if (pdps.size() > 1) { pdpList = Joiner.on(',').skipNulls().join(pdps); } if (logger.isDebugEnabled()) { logger.debug("Group " + group.getId() + " PDPS: " + pdpList); } properties.setProperty(group.getId() + ".pdps", pdpList); } if (ids.isEmpty()) { throw new PAPException("Inconsistency - we have NO groups. We should have at least one."); } String groupList = ""; if (ids.size() == 1) { groupList = ids.get(0); } else if (ids.size() > 1) { groupList = Joiner.on(',').skipNulls().join(ids); } logger.info("New Group List: " + groupList); properties.setProperty(PROP_PAP_GROUPS, groupList); // // Get the default group // PDPGroup defaultGroup = this.getDefaultGroup(); if (defaultGroup == null) { throw new PAPException("Invalid state - no default group."); } properties.setProperty(PROP_PAP_GROUPS_DEFAULT, defaultGroup.getId()); // // Now we can save the file // Path file = Paths.get(this.repository.toString(), "xacml.properties"); try (OutputStream os = Files.newOutputStream(file)) { properties.store(os, ""); } }
From source file:org.lwes.db.EventTemplateDB.java
/** * Returns a rather long string Representation of the EventTemplateDB * * @return a string Representation of the EventTemplateDB *///from w w w.j a va 2 s .c o m @Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append("\n").append(META_EVENT_INFO).append("\n{\n"); String[] reservedKeys = new String[reservedWords.size()]; int i = 0, j = 0; for (String s1 : reservedWords.keySet()) { reservedKeys[i] = s1; ++i; } Arrays.sort(reservedKeys); for (i = 0; i < reservedKeys.length; ++i) { BaseType tv = reservedWords.get(reservedKeys[i]); FieldType type = tv.getType(); sb.append("\t").append(type).append(" ").append(reservedKeys[i]).append(";\n"); } sb.append("}\n"); String[] eventKeys = new String[events.size()]; i = 0; for (String s : events.keySet()) { eventKeys[i] = s; ++i; } Arrays.sort(eventKeys); for (i = 0; i < eventKeys.length; ++i) { sb.append(eventKeys[i]).append("\n{\n"); if (eventKeys[i] != null) { Map<String, BaseType> event = events.get(eventKeys[i]); j = 0; String[] attributeKeys = new String[event.size()]; for (Enumeration<String> att = Collections.enumeration(event.keySet()); att.hasMoreElements();) { attributeKeys[j] = att.nextElement(); ++j; } Arrays.sort(attributeKeys); for (j = 0; j < attributeKeys.length; ++j) { BaseType tv = event.get(attributeKeys[j]); FieldType type = tv.getType(); sb.append("\t").append(type).append(" ").append(attributeKeys[j]).append(";\n"); } } sb.append("}\n"); } return sb.toString(); }
From source file:com.feilong.core.bean.ConvertUtil.java
/** * ? <code>collection</code> ?. * // ww w .j a v a 2s. c o m * @param <T> * the generic type * @param collection * ? * @return <code>collection</code> null, {@link Collections#emptyEnumeration()}<br> * ?{@link Collections#enumeration(Collection)} * @see Collections#enumeration(Collection) * @since 1.4.0 */ public static <T> Enumeration<T> toEnumeration(final Collection<T> collection) { return null == collection ? Collections.<T>emptyEnumeration() : Collections.enumeration(collection); }
From source file:com.temenos.interaction.media.hal.TestHALProvider.java
private Metadata createNestedMockChildVocabMetadata() { EntityMetadata vocs = new EntityMetadata("Children"); Vocabulary vocId = new Vocabulary(); vocId.setTerm(new TermValueType(TermValueType.TEXT)); vocs.setPropertyVocabulary("name", vocId); Vocabulary vocBody = new Vocabulary(); vocBody.setTerm(new TermValueType(TermValueType.INTEGER_NUMBER)); vocs.setPropertyVocabulary("age", vocBody); Vocabulary vocRides = new Vocabulary(); vocRides.setTerm(new TermComplexType(true)); vocs.setPropertyVocabulary("tuitions", vocRides); Vocabulary vocTutionName = new Vocabulary(); vocTutionName.setTerm(new TermValueType(TermValueType.TEXT)); vocs.setPropertyVocabulary("TutionName", vocTutionName, Collections.enumeration(Collections.singletonList("tuitions"))); Vocabulary vocTutionDuration = new Vocabulary(); vocTutionName.setTerm(new TermValueType(TermValueType.TEXT)); vocs.setPropertyVocabulary("Duration", vocTutionDuration, Collections.enumeration(Collections.singletonList("tuitions"))); Metadata metadata = new Metadata("Family"); metadata.setEntityMetadata(vocs);// w ww.j ava 2 s . c o m return metadata; }
From source file:com.temenos.interaction.media.hal.TestHALProvider.java
private Metadata createNestedMockStudentsVocabMetadata() { EntityMetadata vocs = new EntityMetadata("students"); Vocabulary vocId = new Vocabulary(); vocId.setTerm(new TermValueType(TermValueType.TEXT)); vocs.setPropertyVocabulary("name", vocId); Vocabulary vocBody = new Vocabulary(); vocBody.setTerm(new TermValueType(TermValueType.INTEGER_NUMBER)); vocs.setPropertyVocabulary("age", vocBody); Vocabulary vocRides = new Vocabulary(); vocRides.setTerm(new TermComplexType(true)); vocs.setPropertyVocabulary("tuitions", vocRides); Vocabulary vocTutionName = new Vocabulary(); vocTutionName.setTerm(new TermValueType(TermValueType.TEXT)); vocs.setPropertyVocabulary("TutionName", vocTutionName, Collections.enumeration(Collections.singletonList("tuitions"))); Vocabulary vocTutionDuration = new Vocabulary(); vocTutionName.setTerm(new TermValueType(TermValueType.TEXT)); vocs.setPropertyVocabulary("Duration", vocTutionDuration, Collections.enumeration(Collections.singletonList("tuitions"))); Metadata metadata = new Metadata("Faculty"); metadata.setEntityMetadata(vocs);//ww w.j a va 2 s. c om return metadata; }
From source file:net.lightbody.bmp.proxy.jetty.jetty.servlet.ServletHandler.java
/** Get context attribute names. * Combines ServletHandler and HttpContext attributes. */// ww w . j av a 2 s.c o m protected Enumeration getContextAttributeNames() { if (_attributes.size() == 0) return getHttpContext().getAttributeNames(); HashSet set = new HashSet(_attributes.keySet()); Enumeration e = getHttpContext().getAttributeNames(); while (e.hasMoreElements()) set.add(e.nextElement()); return Collections.enumeration(set); }
From source file:com.temenos.interaction.media.hal.TestHALProvider.java
private Metadata createMoreComplexNestedMockStudentVocabMetadata() { EntityMetadata vocs = new EntityMetadata("students"); Vocabulary vocId = new Vocabulary(); vocId.setTerm(new TermValueType(TermValueType.TEXT)); vocs.setPropertyVocabulary("name", vocId); Vocabulary vocBody = new Vocabulary(); vocBody.setTerm(new TermValueType(TermValueType.INTEGER_NUMBER)); vocs.setPropertyVocabulary("age", vocBody); Vocabulary vocRides = new Vocabulary(); vocRides.setTerm(new TermComplexType(true)); vocs.setPropertyVocabulary("tuitions", vocRides); Vocabulary vocTeachers = new Vocabulary(); vocTeachers.setTerm(new TermComplexType(true)); vocs.setPropertyVocabulary("Teachers", vocTeachers, Collections.enumeration(Collections.singletonList("tuitions"))); Vocabulary vocTutionName = new Vocabulary(); vocTutionName.setTerm(new TermValueType(TermValueType.TEXT)); vocs.setPropertyVocabulary("TutionName", vocTutionName, Collections.enumeration(Collections.singletonList("tuitions"))); Vocabulary vocTutionDuration = new Vocabulary(); vocTutionName.setTerm(new TermValueType(TermValueType.TEXT)); vocs.setPropertyVocabulary("Duration", vocTutionDuration, Collections.enumeration(Collections.singletonList("tuitions"))); Vocabulary vocTeacherName = new Vocabulary(); vocTeacherName.setTerm(new TermValueType(TermValueType.TEXT)); vocs.setPropertyVocabulary("Name", vocTeacherName, Collections.enumeration(Arrays.asList(new String[] { "tuitions", "Teachers" }))); Vocabulary vocAddress = new Vocabulary(); vocAddress.setTerm(new TermComplexType(true)); vocs.setPropertyVocabulary("address", vocAddress); Vocabulary vocAddressHouseNumber = new Vocabulary(); vocAddressHouseNumber.setTerm(new TermValueType(TermValueType.NUMBER)); vocs.setPropertyVocabulary("houseNumber", vocAddressHouseNumber, Collections.enumeration(Arrays.asList(new String[] { "address" }))); Vocabulary vocAddressRoadName = new Vocabulary(); vocAddressRoadName.setTerm(new TermValueType(TermValueType.NUMBER)); vocs.setPropertyVocabulary("roadName", vocAddressRoadName, Collections.enumeration(Arrays.asList(new String[] { "address" }))); Metadata metadata = new Metadata("Faculty"); metadata.setEntityMetadata(vocs);//from ww w .j av a 2 s. c o m return metadata; }
From source file:org.ireland.jnetty.http.HttpServletRequestImpl.java
@Override // OK/*from w w w . j av a 2 s . co m*/ public Enumeration<String> getParameterNames() { if (!_paramsExtracted) extractParameters(); return Collections.enumeration(_parameters.keySet()); }
From source file:org.openmrs.module.ModuleClassLoader.java
/** * @see java.lang.ClassLoader#findResources(java.lang.String) *///from w ww .ja v a2 s. c o m @Override public Enumeration<URL> findResources(final String name) throws IOException { List<URL> result = new LinkedList<URL>(); findResources(result, name, this, null); // expand all of the "jar" urls for (URL url : result) { url = expandIfNecessary(url); } return Collections.enumeration(result); }