List of usage examples for java.util Collection clear
void clear();
From source file:org.carewebframework.vista.ui.notification.NotificationService.java
/** * Returns all scheduled notifications for the current user. * /*from ww w .j a va2 s. c o m*/ * @param result The list to receive the results. */ public void getScheduledNotifications(Collection<ScheduledNotification> result) { List<String> lst = broker.callRPCList("RGCWXQ SCHLIST", null, scheduledPrefix); result.clear(); for (String data : lst) { result.add(new ScheduledNotification(data)); } }
From source file:com.github.ziplet.filter.compression.CompressingStreamFactory.java
private static String selectBestEncoding(String acceptEncodingHeader) { // multiple encodings are accepted; determine best one Collection<String> bestEncodings = new HashSet<String>(3); double bestQ = 0.0; Collection<String> unacceptableEncodings = new HashSet<String>(3); boolean willAcceptAnything = false; for (String token : COMMA.split(acceptEncodingHeader)) { ContentEncodingQ contentEncodingQ = parseContentEncodingQ(token); String contentEncoding = contentEncodingQ.getContentEncoding(); double q = contentEncodingQ.getQ(); if (ANY_ENCODING.equals(contentEncoding)) { willAcceptAnything = q > 0.0; } else if (supportedEncodings.contains(contentEncoding)) { if (q > 0.0) { if (q == bestQ) { bestEncodings.add(contentEncoding); } else if (q > bestQ) { bestQ = q;//ww w . j av a2 s. com bestEncodings.clear(); bestEncodings.add(contentEncoding); } } else { unacceptableEncodings.add(contentEncoding); } } } if (bestEncodings.isEmpty()) { // nothing was acceptable to us if (willAcceptAnything) { if (unacceptableEncodings.isEmpty()) { return supportedEncodings.get(0); } else { for (String encoding : supportedEncodings) { if (!unacceptableEncodings.contains(encoding)) { return encoding; } } } } } else { for (String encoding : supportedEncodings) { if (bestEncodings.contains(encoding)) { return encoding; } } } return NO_ENCODING; }
From source file:org.hyperic.hq.measurement.agent.server.MeasurementSchedule.java
/** * Reads all the records from the measurement_schedule storage list and writes * them into the collection//from w ww . j a v a 2s . com * @param records - adds all the records from the storage to this collection */ private void readRecordsFromStorage(Collection<String> records) { Iterator<String> i; records.clear(); i = store.getListIterator(MeasurementSchedule.PROP_MSCHED); for (; i != null && i.hasNext();) { String value = i.next(); records.add(value); } }
From source file:com.adaptris.core.marshaller.xstream.XStreamUtilsTest.java
@Test public void testSetContainsAnyOf() { Set<String> testSet = new HashSet<>(); testSet.add("cat"); testSet.add("dog"); testSet.add("fish"); Collection<String> searchCollection = new HashSet<String>(); searchCollection.add("horse"); assertFalse(XStreamUtils.setContainsAnyOf(testSet, searchCollection)); searchCollection.add("cat"); assertTrue(XStreamUtils.setContainsAnyOf(testSet, searchCollection)); searchCollection.clear(); searchCollection.add("fish"); assertTrue(XStreamUtils.setContainsAnyOf(testSet, searchCollection)); }
From source file:com.smartitengineering.cms.api.impl.type.FieldDefImpl.java
@Override public void setVariations(Collection<? extends VariationDef> variationDefs) { if (variationDefs != null) { this.variationDefs.clear(); this.variationDefs.addAll(variationDefs); } else {// ww w . j a va 2 s.co m variationDefs.clear(); } }
From source file:com.anrisoftware.prefdialog.fields.listbox.AbstractListBoxField.java
/** * Sets the values as the selected values of the list. * /*from w w w . j a v a 2 s . c o m*/ * @param values * the values array. * * @throws PropertyVetoException */ @SuppressWarnings({ "rawtypes", "unchecked" }) public void setValues(Object[] values) throws PropertyVetoException { Object value = getValue(); if (value.getClass().isArray()) { setValue(values); } else if (value instanceof Collection) { Collection collection = (Collection) value; collection.clear(); collection.addAll(asList(values)); setValue(collection); } }
From source file:org.apache.axis2.jaxws.utility.PropertyDescriptorPlus.java
/** * Set the property value for the collection case. * * @param targetBean/* ww w .j av a 2s .c o m*/ * @param propValue * @throws InvocationTargetException * @throws IllegalAccessException * @throws JAXBWrapperException */ private void setList(Object targetBean, Object propValue) throws InvocationTargetException, IllegalAccessException, JAXBWrapperException { // For the List<T> case, there is no setter. // You are supposed to use the getter to obtain access to the collection and then add the collection Collection value = asCollection(propValue, descriptor.getPropertyType()); Collection collection = (Collection) get(targetBean); // Now add our our object to the collection collection.clear(); if (propValue != null) { collection.addAll(value); } }
From source file:org.sipfoundry.sipxconfig.phone.yealink.YealinkDirectoryConfiguration.java
void transformPhoneBook(Collection<PhonebookEntry> phonebookEntries, Collection<YealinkPhonebookEntry> yealinkEntries) { for (PhonebookEntry entry : phonebookEntries) { yealinkEntries.add(new YealinkPhonebookEntry(entry)); }//from w ww. j a va2s . c o m List<YealinkPhonebookEntry> tmp = Collections.list(Collections.enumeration(yealinkEntries)); Collections.sort(tmp); yealinkEntries.clear(); for (YealinkPhonebookEntry entry : tmp) { yealinkEntries.add(entry); } }
From source file:slash.navigation.download.tools.ScanWebsite.java
private void addUrisInChunks(DataSource dataSource, Collection<String> uris) throws IOException { Collection<String> chunk = new HashSet<>(); for (String uri : uris) { chunk.add(uri);/*from w w w. j a va2s.c om*/ if (chunk.size() >= MAXIMUM_UPDATE_COUNT) { addUris(dataSource, chunk); chunk.clear(); } } if (chunk.size() > 0) addUris(dataSource, chunk); }
From source file:org.alfresco.repo.content.transform.TransformerConfigDynamicTransformers.java
private void createDynamicTransformers(TransformerConfig transformerConfig, TransformerProperties transformerProperties, MimetypeService mimetypeService, ContentService contentService, ContentTransformerRegistry transformerRegistry, TransformerDebug transformerDebug, ModuleService moduleService, DescriptorService descriptorService, Properties globalProperties) { Collection<String> SUFFIXES = Arrays.asList(new String[] { FAILOVER, PIPELINE, AVAILABLE, EDITION, AMP }); Map<TransformerSourceTargetSuffixKey, TransformerSourceTargetSuffixValue> transformerSourceTargetSuffixValues = getTransformerSourceTargetValuesMap( SUFFIXES, true, true, false, transformerProperties, mimetypeService); Collection<TransformerSourceTargetSuffixValue> properties = transformerSourceTargetSuffixValues.values(); // Repeat until we cannot create any more transformers or all have been created Collection<TransformerSourceTargetSuffixValue> processed = new ArrayList<TransformerSourceTargetSuffixValue>(); do {//from ww w.ja v a 2 s. c o m processed.clear(); for (TransformerSourceTargetSuffixValue property : properties) { if (property.suffix.equals(PIPELINE) || property.suffix.equals(FAILOVER)) { try { String edition = getProperty(property.transformerName, null, null, EDITION, null, transformerSourceTargetSuffixValues); String moduleId = getProperty(property.transformerName, null, null, AMP, null, transformerSourceTargetSuffixValues); if (!supportedEdition(descriptorService, edition)) { processed.add(property); logger.debug(property.transformerName + " ignored. As it is an " + edition + " only transformer."); } else if (!supportedModule(moduleService, moduleId)) { processed.add(property); logger.debug(property.transformerName + " ignored. As the AMP " + moduleId + " is not installed."); } else { String availableStr = getProperty(property.transformerName, null, null, AVAILABLE, null, transformerSourceTargetSuffixValues); boolean available = availableStr == null || "true".equalsIgnoreCase(availableStr); AbstractContentTransformer2 transformer = property.suffix.equals(PIPELINE) ? createComplexTransformer(property, transformerConfig, mimetypeService, contentService, transformerRegistry, transformerDebug, available, globalProperties) : createFailoverTransformer(property, transformerConfig, mimetypeService, contentService, transformerRegistry, transformerDebug, available, globalProperties); transformer.register(); processed.add(property); dynamicTransformers.add(transformer); logger.debug(property.transformerName + " added"); } } catch (IllegalArgumentException e) { // Thrown if unknown sub transformer name - it might be dynamic } catch (AlfrescoRuntimeException e) { // Thrown if the mimetype is invalid or the transformer already exists processed.add(property); error(e.getMessage()); } } } } while (properties.removeAll(processed) && properties.size() > 0); for (TransformerSourceTargetSuffixValue property : properties) { if (property.suffix.equals(PIPELINE) || property.suffix.equals(FAILOVER)) { error("Cannot create dynamic transformer " + property.transformerName + " as sub transformers could not be found or created (\"" + property.value + "\")."); } } }