List of usage examples for java.util Collection remove
boolean remove(Object o);
From source file:ubic.gemma.core.analysis.sequence.SequenceManipulation.java
/** * Convert a CompositeSequence's immobilizedCharacteristics into a single sequence, using a simple merge-join * strategy./*from w ww . j a v a 2 s. c o m*/ * * @param sequences sequences * @return BioSequence. Not all fields are filled in and must be set by the caller. */ public static BioSequence collapse(Collection<Reporter> sequences) { Collection<Reporter> copyOfSequences = SequenceManipulation.copyReporters(sequences); BioSequence collapsed = BioSequence.Factory.newInstance(); collapsed.setSequence(""); if (SequenceManipulation.log.isDebugEnabled()) SequenceManipulation.log.debug("Collapsing " + sequences.size() + " sequences"); while (!copyOfSequences.isEmpty()) { Reporter next = SequenceManipulation.findLeftMostProbe(copyOfSequences); int ol = SequenceManipulation.rightHandOverlap(collapsed, next.getImmobilizedCharacteristic()); String nextSeqStr = next.getImmobilizedCharacteristic().getSequence(); collapsed.setSequence(collapsed.getSequence() + nextSeqStr.substring(ol)); if (SequenceManipulation.log.isDebugEnabled()) { SequenceManipulation.log.debug( "New Seq to add: " + nextSeqStr + " Overlap=" + ol + " Result=" + collapsed.getSequence()); } copyOfSequences.remove(next); } collapsed.setIsCircular(false); collapsed.setIsApproximateLength(false); collapsed.setLength((long) collapsed.getSequence().length()); collapsed.setDescription("Collapsed from " + sequences.size() + " reporter sequences"); return collapsed; }
From source file:org.kuali.rice.kew.impl.peopleflow.PeopleFlowMaintainableImpl.java
/** * In the case of edit maintenance deleted the item on the old side. * This method is intended to override the method in MaintainableImpl * but has a different set of parameters, so it is not actually an override. * This was needed to fetch the old collection from a different path * than MaintainableImpl uses. This version has the path (to the newMaintainableObject * provided as a parameter, this is used to generate a path to the oldMaintainableObject * * * @see org.kuali.rice.krad.uif.service.impl.ViewHelperServiceImpl#processAfterDeleteLine(View, * org.kuali.rice.krad.uif.container.CollectionGroup, java.lang.Object, int) */// ww w. ja v a2 s. c om @Override public void processAfterDeleteLine(ViewModel model, String collectionId, String collectionPath, int lineIndex) { // Check for maintenance documents in edit if (model instanceof MaintenanceDocumentForm && KRADConstants.MAINTENANCE_EDIT_ACTION .equals(((MaintenanceDocumentForm) model).getMaintenanceAction())) { // get the old object's collection String oldCollectionPath = collectionPath.replace("newMaintainableObject", "oldMaintainableObject"); Collection<Object> oldCollection = ObjectPropertyUtils.getPropertyValue(model, oldCollectionPath); try { // Remove the object at lineIndex from the collection oldCollection.remove(oldCollection.toArray()[lineIndex]); } catch (Exception e) { throw new RuntimeException("Unable to delete line instance for old maintenance object", e); } } }
From source file:forge.game.mana.ManaPool.java
private void removeMana(final Mana mana) { Collection<Mana> cm = floatingMana.get(mana.getColor()); if (cm.remove(mana)) { owner.updateManaForView();//from w w w . j av a 2s . c o m owner.getGame().fireEvent(new GameEventManaPool(owner, EventValueChangeType.Removed, mana)); } }
From source file:com.tera.common.event.DefaultEventContainer.java
@Override public void fireEvent(String eventType, Event event, Object... args) { Collection<EventCallback> callbacks = callbackMap.get(eventType); List<EventCallback> finishedCallbacks = new ArrayList<EventCallback>(); for (EventCallback cb : callbacks) { cb.handle(event, args);/*from w ww. j a va2 s. c om*/ if (cb.isOneRun()) { finishedCallbacks.add(cb); } } for (EventCallback finished : finishedCallbacks) { callbacks.remove(finished); } }
From source file:org.jactr.io.antlr3.parser.AbstractModelParser.java
synchronized public void removeTreeTracker(ITreeTracker tracker) { if (_treeTrackers == null) return;/*from w ww . j a v a 2 s . co m*/ for (int type : tracker.getRelevantTypes()) { Collection<ITreeTracker> trackers = _treeTrackers.get(type); if (trackers != null) { trackers.remove(tracker); if (trackers.size() == 0) _treeTrackers.remove(type); } } }
From source file:org.eclipse.smila.connectivity.framework.compound.test.TestCompoundManager.java
/** * Test {@link CompoundManager#adaptCompoundRecord(Record, DataSourceConnectionConfig)}. * /*from ww w . ja v a2 s .c o m*/ * @throws Exception * a Exception */ public void testAdaptCompoundRecord() throws Exception { final CompoundManager compoundManager = getService(CompoundManager.class); assertNotNull(compoundManager); final DataSourceConnectionConfig config = ConfigurationLoader.unmarshall( ConfigUtils.getConfigStream("org.eclipse.smila.connectivity.framework", "ZipConfigExample.xml")); assertNotNull(config); final Record record = createRecord(); addAttribute(record, config.getCompoundHandling().getMimeTypeAttribute(), "application/zip"); record.setAttachment("Content", FileUtils.readFileToByteArray(new File("configuration/data/test.zip"))); final Record adaptedRecord = compoundManager.adaptCompoundRecord(record, config); // with the current implementation the record should not be changed assertNotNull(adaptedRecord); assertTrue(adaptedRecord == record); final Collection<String> atts = record.getMetadata().keySet(); assertTrue(atts.contains(config.getCompoundHandling().getMimeTypeAttribute())); // check if this is the only attribute... atts.remove((config.getCompoundHandling().getMimeTypeAttribute())); atts.remove(Record.RECORD_ID); atts.remove(Record.SOURCE); assertTrue(atts.isEmpty()); final Iterator<String> attaches = record.getAttachmentNames(); final String attach = attaches.next(); assertEquals(attach, config.getCompoundHandling().getContentAttachment()); assertFalse(attaches.hasNext()); }
From source file:info.magnolia.security.app.dialog.action.SaveUserDialogAction.java
private void storeRolesCollection(UserManager userManager, User user, Collection<String> newRoles) { Collection<String> oldRoles = new ArrayList<String>(); for (String role : user.getRoles()) { oldRoles.add(role);// w w w . jav a 2 s .c o m } for (String newRole : newRoles) { userManager.addRole(user, newRole); oldRoles.remove(newRole); } for (String oldRole : oldRoles) { userManager.removeRole(user, oldRole); } }
From source file:org.springframework.richclient.form.binding.jide.CheckBoxListSelectableBinding.java
/** * @param values/* w ww . j a v a 2s.c om*/ * @return */ protected int[] determineValueIndexes(Object[] values) { int[] indexes = new int[values.length]; if (values.length == 0) return indexes; Collection lookupValues = new HashSet(Arrays.asList(values)); ListModel model = getList().getModel(); int i = 0; for (int index = 0, size = model.getSize(); index < size && !lookupValues.isEmpty(); index++) { if (lookupValues.remove(model.getElementAt(index))) { indexes[i++] = index; } } int[] result; if (i != values.length) { result = new int[i]; System.arraycopy(indexes, 0, result, 0, i); } else { result = indexes; } return result; }
From source file:org.apache.ode.bpel.engine.DebuggerSupport.java
public void removeBreakpoint(Long pid, Breakpoint breakpoint) { Breakpoint[] bpArr = _instanceBreakPoints.get(pid); if (bpArr != null) { Collection<Breakpoint> c = CollectionUtils.makeCollection(ArrayList.class, bpArr); c.remove(breakpoint); bpArr = c.toArray(new Breakpoint[c.size()]); if (bpArr.length == 0) { _instanceBreakPoints.remove(pid); } else {/*w w w . j a va 2s . co m*/ _instanceBreakPoints.put(pid, bpArr); } } }
From source file:net.ontopia.topicmaps.impl.basic.index.ClassInstanceIndex.java
@Override public Collection<TopicIF> getAssociationRoleTypes() { // Create new collection Collection<TopicIF> result = new ArrayList<TopicIF>(roles.keySet()); result.remove(null); return Collections.unmodifiableCollection(result); }