List of usage examples for java.util List clear
void clear();
From source file:edu.northwestern.bioinformatics.studycalendar.xml.writers.AmendmentXmlValidationTest.java
public void testValidateForWrongNumberOfStudySegments() throws IOException, SAXException { amendment.getDeltas().add(plannedCalendarDelta); eAmendment = amendmentSerializer.createElement(amendment); List<StudySegment> studySegments = ((Epoch) add1.getChild()).getStudySegments(); studySegments.clear(); studySegments.add(studySegment2);/* w w w.j a va 2s . c o m*/ String message = amendmentSerializer.validate(amendment, eAmendment); assertTrue(message.contains( "Epoch present in the system and in the imported document must have identical number of study segments")); }
From source file:com.nextep.datadesigner.vcs.impl.MergerWithMultilineAttributes.java
/** * Removes all sub items of the specified attribute * // w w w . ja va2 s .c o m * @param result * result to clean * @param multilineAttributeName * attribute name where multiline sub items are populated */ protected void removeMergedSubItems(IComparisonItem result, String multilineAttributeName) { final IComparisonItem attribute = result.getAttribute(multilineAttributeName); // Securing this section as part of the DES-710 bugfix if (attribute != null) { final List<IComparisonItem> subItems = attribute.getSubItems(); if (subItems != null) { subItems.clear(); } } }
From source file:com.sshdemo.common.schedule.manage.SchedulingFac.java
protected List<JobInfo> removeDuplicateAndSort(List<JobInfo> list) { // ??/*from w w w . ja v a 2 s . c o m*/ HashSet<JobInfo> h = new HashSet<JobInfo>(list); list.clear(); list.addAll(h); // ? Collections.sort(list, new Comparator<Object>() { public int compare(Object o1, Object o2) { JobInfo p1 = (JobInfo) o1; JobInfo p2 = (JobInfo) o2; if (p1.getId() > p2.getId()) return 1; else return 0; } }); return list; }
From source file:mitm.common.extractor.impl.UnicodeTextExtractorTest.java
private void cleanParts(List<ExtractedPart> parts) throws IOException { for (ExtractedPart part : parts) { part.close();// ww w . j a va 2 s. c om } parts.clear(); }
From source file:com.mozilla.bagheera.hazelcast.persistence.ElasticSearchIndexMapStore.java
@Override public void store(String key, String value) { LOG.debug("calling store method"); LOG.info("mapstore: received something in queue for store:" + key); List<String> rowIds = new ArrayList<String>(); if (StringUtils.isNotBlank(key)) { rowIds.add(key);/*from www . ja v a2 s . c o m*/ indexJsons(rowIds); rowIds.clear(); } }
From source file:com.amazonaws.mobileconnectors.kinesis.kinesisrecorder.AbstractKinesisRecorder.java
/** * Reads a batch of records belong to the same stream into a list. If data * is read successfully, the stream name is returned. * * @param iterator record iterator/*w w w. j av a2 s . c o m*/ * @param data a list to hold data. * @param maxCount maximum number of records in a batch * @param maxSize a threshold that concludes a batch. It allows one extra * record that brings the total size over this threshold. * @return the stream name that the batch belongs to */ protected String nextBatch(RecordIterator iterator, List<byte[]> data, int maxCount, int maxSize) { data.clear(); String lastStreamName = null; int size = 0; int count = 0; final FileRecordParser frp = new FileRecordParser(); while (iterator.hasNext() && count < maxCount && size < maxSize) { final String line = iterator.peek(); if (line == null || line.isEmpty()) { continue; } // parse a line. Skip in case of corrupted data try { frp.parse(line); } catch (final Exception e) { LOGGER.warn("Failed to read line. Skip.", e); continue; } // check whether it belongs to previous batch if (lastStreamName == null || lastStreamName.equals(frp.streamName)) { data.add(frp.bytes); // update counter count++; size += frp.bytes.length; lastStreamName = frp.streamName; iterator.next(); } else { break; } } return lastStreamName; }
From source file:eu.annocultor.converters.solr.SolrDocumentTagger.java
private void flush(List<SolrInputDocument> destDocs) throws Exception { if (destDocs.size() > DOCUMENT_QUEUE_SIZE_TO_FLUSH) { solrServerTo.add(destDocs);/*from ww w .j a v a 2s .co m*/ destDocs.clear(); } }
From source file:it.cnr.isti.thematrix.scripting.sys.DatasetSchema.java
/** * Check if a set of attributes can be added to a dataset without duplication in the Schema, return null if no * issues are found. The method checks both duplication with the existing schema and duplicate name in the list of * attributes to be added. If passed a null or empty list of attributes, the method will warn in the logs but return * true. A detailed error message is returned if issues are found. * * @param schema/*from w w w.java 2s .com*/ * the schema to extend * @param newAttributes * the List of new attributes as Symbol<?> * @return either a String with detailed error messages about all conflicting new attributes, or null if there are * none. */ public static String canExtend(DatasetSchema schema, List<Symbol<?>> newAttributes) { if (newAttributes == null || newAttributes.size() == 0) { LogST.logP(0, "WARNING DatasetSchema.canExtend() called with empty or null newAttributes"); return null; } String result = null; List<String> duplicates = new ArrayList<String>(); for (Symbol<?> attribute : newAttributes) { if (schema.containsKey(attribute.name)) duplicates.add(attribute.name); } if (duplicates.size() > 0) result = " new attributes duplicate existing attributes: " + duplicates.toString() + ";"; /** * sort the List of new attributes, so that we can check with the existing ones and between them. * We copy the list for sorting it, but we do not modify its elements. * FIXME the comparator for Symbol<?> should be in Symbol **/ ArrayList<Symbol<?>> copyNewAttributes = new ArrayList(newAttributes); Collections.sort(copyNewAttributes, new Comparator<Symbol<?>>() { public int compare(Symbol<?> s1, Symbol<?> s2) { return s1.name.compareTo(s2.name); } }); Iterator<Symbol<?>> i = copyNewAttributes.iterator(); Symbol<?> s = i.next(); // we know the list is not empty Symbol<?> prev = null; duplicates.clear(); while (i.hasNext()) { prev = s; s = i.next(); if (s.name.equals(prev.name)) duplicates.add(s.name); } if (duplicates.size() > 0) { if (result == null) result = ""; result = result + " new attributes duplicate each other: " + duplicates.toString() + ";"; } return result == null ? null : "DatasetSchema : " + result; }
From source file:hivemall.ftvec.hashing.FeatureHashingUDF.java
@Nonnull private List<Text> evaluateList(@Nonnull final Object arg0) { final int len = _listOI.getListLength(arg0); List<Text> list = _returnObj; if (list == null) { list = new ArrayList<Text>(len); this._returnObj = list; } else {/*from w ww .ja v a 2 s . c o m*/ list.clear(); } final int numFeatures = _numFeatures; for (int i = 0; i < len; i++) { Object obj = _listOI.getListElement(arg0, i); if (obj == null) { continue; } String fv = obj.toString(); Text t = new Text(featureHashing(fv, numFeatures)); list.add(t); } return list; }
From source file:org.eurekastreams.server.domain.GadgetDefinitionTest.java
/** * Very basic test to ensure that the gadget constructor stores parameters correctly. *///www. j av a2s .c o m @Test public void sutinitionConstructor() { String message = "accessor parameters should be stored and accessible via getters/setters"; /** fixture. */ String gadgetUrl = "http://www.example.com"; GadgetDefinition sut = new GadgetDefinition(gadgetUrl, UUID.randomUUID().toString(), new GalleryItemCategory("somecategory")); assertEquals("gadget url does not match url passed into the constructor.", gadgetUrl, sut.getUrl()); List<Gadget> gadgets = new ArrayList<Gadget>(); GadgetDefinition def = new GadgetDefinition(gadgetUrl, UUID.randomUUID().toString(), new GalleryItemCategory("somecategory")); Gadget gadget = new Gadget(def, 1, 0, new Person(), ""); gadgets.clear(); gadgets.add(gadget); sut.setGadgets(gadgets); sut.setNumberOfUsers(gadgets.size()); sut.getUrl(); sut.getUUID(); sut.getCategory(); sut.getNumberOfUsers(); assertEquals(message, gadgets, sut.getGadgets()); }