Example usage for java.util Collection clear

List of usage examples for java.util Collection clear

Introduction

In this page you can find the example usage for java.util Collection clear.

Prototype

void clear();

Source Link

Document

Removes all of the elements from this collection (optional operation).

Usage

From source file:org.apache.wicket.markup.html.form.upload.MultiFileUploadField.java

/**
 * @see org.apache.wicket.Component#onDetach()
 *//*from w w w  .  j a  va  2  s  .  c om*/
@Override
protected void onDetach() {
    if (forceCloseStreamsOnDetach()) {
        // cleanup any opened filestreams
        Collection<FileUpload> uploads = getConvertedInput();
        if (uploads != null) {
            for (FileUpload upload : uploads) {
                upload.closeStreams();
            }
        }

        // cleanup any caches
        inputArrayCache = null;

        // clean up the model because we don't want FileUpload objects in session
        Collection<FileUpload> modelObject = getModelObject();
        if (modelObject != null) {
            modelObject.clear();
        }
    }

    super.onDetach();
}

From source file:org.sipfoundry.sipxconfig.acd.AcdQueue.java

public void cleanAgents() {
    Collection agents = getAgents();
    for (Iterator i = agents.iterator(); i.hasNext();) {
        AcdAgent agent = (AcdAgent) i.next();
        agent.removeFromQueue(this);
    }//w w w  . j  ava  2s .  com
    agents.clear();
}

From source file:op.tools.SYSTools.java

public static void clear(Collection coll) {
    if (coll != null) {
        coll.clear();
    }
}

From source file:edu.scripps.fl.pubchem.app.RelationDownloader.java

protected void update(long fromId, String name, Collection<Relation> relations) {
    Session session = PubChemDB.getSession();
    Transaction trx = session.beginTransaction();

    Query query = session.createQuery("delete from Relation where fromId = ? and relationName = ?");
    query.setLong(0, fromId);/*  ww  w  . j  a  va  2  s  .  c  o  m*/
    query.setString(1, name);
    query.executeUpdate();

    for (Relation relation : relations) {
        session.save(relation);
    }
    relations.clear();

    session.flush();
    trx.commit();
}

From source file:org.jactr.core.model.six.DefaultCycleProcessor6.java

private void execute(Collection<Runnable> source) {
    FastList<Runnable> container = FastList.newInstance();
    synchronized (source) {
        container.addAll(source);/* w ww .j av  a 2s .co m*/
        source.clear();
    }

    for (Runnable runner : container)
        try {
            runner.run();
        } catch (Exception e) {
            LOGGER.error("Failed to execute " + runner, e);
        }

    FastList.recycle(container);
}

From source file:com.samsung.sjs.theorysolver.TheorySolver.java

public static <Constraint, Model> void enumerateFixingSets(FixingSetFinder<Constraint> fixingSetFinder,
        Theory<Constraint, Model> theorySolver, Collection<Constraint> hardConstraints,
        Collection<Constraint> softConstraints, FixingSetListener<Constraint, Model> listener) {

    Collection<Constraint> constraints = new ArrayList<>();
    Collection<Constraint> core = new ArrayList<>();
    Collection<Constraint> fixingSet = new LinkedHashSet<>();
    for (;;) {/*ww w  .  j  a v a 2  s .c  om*/

        if (fixingSetFinder.currentFixingSet(fixingSet, listener) == FixingSetListener.Action.STOP) {
            return;
        }

        constraints.addAll(hardConstraints);
        softConstraints.stream().filter(c -> !fixingSet.contains(c)).forEach(constraints::add);
        Either<Model, Collection<Constraint>> result = theorySolver.check(constraints);
        if (result.left != null) {
            if (listener.onFixingSet(result.left, fixingSet) == FixingSetListener.Action.STOP) {
                return;
            }
            fixingSetFinder.addCore(
                    constraints.stream().filter(softConstraints::contains).collect(Collectors.toList()));
        } else {
            result.right.stream().filter(softConstraints::contains).forEach(core::add);
            if (listener.onCore(core) == FixingSetListener.Action.STOP) {
                return;
            }
            assert core.stream().allMatch(c -> !fixingSet.contains(c));
            fixingSetFinder.addCore(core);
        }
        core.clear();
        constraints.clear();
        fixingSet.clear();

    }

}

From source file:org.hyperic.hq.hqu.server.session.UIPluginManagerImpl.java

public void updatePlugin(UIPlugin p, String version) {
    // On update, we need to clean the previous views out and recreate.
    // Recreation of views will be done when deploy is called on the plugin.
    Collection views = p.getViewsBag();
    if (!views.isEmpty()) {
        for (Object viewObject : views) {
            ((View) viewObject).getAttachmentsBag().clear();
        }/*from ww w . j  a va 2s  . c  om*/
        views.clear();
        // need to flush the session to allow for adding the views back during deploy
        // within the same transaction.
        uiPluginDAO.flushSession();
    }
    if (!p.getPluginVersion().equals(version)) {
        log.info("Updating plugin version to " + version);
        p.setPluginVersion(version);
    }
}

From source file:ome.util.ContextFilter.java

protected void doFilter(String fieldId, Collection c) {
    List copy = new ArrayList();
    for (Iterator iter = c.iterator(); iter.hasNext();) {
        Object item = iter.next();
        Object result = filter(fieldId, item);
        copy.add(result);/*from ww w . j a  v  a2s. c  om*/
    }
    try {
        c.clear();
        c.addAll(copy);
    } catch (UnsupportedOperationException uoe) {
        // This should only happen for the primitive
        // array types like Namespace.keywords.
        // Do nothing.
    }
}

From source file:org.cyberoam.iview.utility.MultiHashMap.java

/**
 * Clear the map.//from   w w  w .  j  a va  2  s  .com
 * <p>
 * This clears each collection in the map, and so may be slow.
 */
public void clear() {
    // For gc, clear each list in the map
    Set pairs = super.entrySet();
    Iterator pairsIterator = pairs.iterator();
    while (pairsIterator.hasNext()) {
        Map.Entry keyValuePair = (Map.Entry) pairsIterator.next();
        Collection coll = (Collection) keyValuePair.getValue();
        coll.clear();
    }
    super.clear();
}