Example usage for java.util LinkedList contains

List of usage examples for java.util LinkedList contains

Introduction

In this page you can find the example usage for java.util LinkedList contains.

Prototype

public boolean contains(Object o) 

Source Link

Document

Returns true if this list contains the specified element.

Usage

From source file:com.haulmont.cuba.gui.data.impl.DsContextImpl.java

protected void addDatasourceToResume(LinkedList<CollectionDatasource.Suspendable> list, Datasource datasource) {
    if (list.contains(datasource)) {
        return;//from   w  ww . jav  a2s . c om
    }

    if (dependencies.containsKey(datasource)) {
        Datasource master = dependencies.get(datasource);
        addDatasourceToResume(list, master);
    }
    if (datasource instanceof CollectionDatasource.Suspendable
            && ((CollectionDatasource.Suspendable) datasource).isSuspended()) {
        list.add((CollectionDatasource.Suspendable) datasource);
    }
}

From source file:org.pentaho.repo.controller.RepositoryBrowserController.java

public LinkedList<String> storeRecentSearch(String recentSearch) {
    LinkedList<String> recentSearches = getRecentSearches();
    try {/*from   w w  w.  j  a v a  2  s . com*/
        if (recentSearch == null || recentSearches.contains(recentSearch)) {
            return recentSearches;
        }
        recentSearches.push(recentSearch);
        if (recentSearches.size() > 5) {
            recentSearches.pollLast();
        }

        JSONArray jsonArray = new JSONArray();
        CollectionUtils.addAll(jsonArray, recentSearches.toArray());

        PropsUI props = PropsUI.getInstance();
        String jsonValue = props.getRecentSearches();
        JSONParser jsonParser = new JSONParser();
        JSONObject jsonObject = jsonValue != null ? (JSONObject) jsonParser.parse(jsonValue) : new JSONObject();

        String login = "file_repository_no_login";
        if (Spoon.getInstance().rep.getUserInfo() != null) {
            login = Spoon.getInstance().rep.getUserInfo().getLogin();
        }

        jsonObject.put(login, jsonArray);
        props.setRecentSearches(jsonObject.toJSONString());
    } catch (Exception e) {
        // Log error in console
    }

    return recentSearches;
}

From source file:modmanager.backend.ModificationOption.java

/**
 * updates the status of contained files in this modification
 *
 * @param status/*from  ww  w  . j  av  a 2 s.co m*/
 */
public void updateStatus(ModificationStatus status) {
    logger.log(Level.INFO, "Updating status of option ...");

    LinkedList<File> installed = getOrLoadInstalledFiles();
    status.set(this, isInstalled(installed), installed.size());

    for (File file : files) {
        /**
         * ! O(n)
         */
        status.set(file, installed.contains(file));
    }
}

From source file:at.ac.tuwien.inso.subcat.miner.MinerRunner.java

private MinerRunner(ModelPool pool, Project project, Settings settings, Reporter reporter)
        throws MinerException {
    assert (settings != null);
    assert (project != null);
    assert (settings != null);
    assert (reporter != null);

    init();//  w ww .  java  2 s  . c  o  m

    Model model = null;
    try {
        model = pool.getModel();
    } catch (SQLException e) {
        throw new MinerException("SQL-Error: " + e.getMessage(), e);
    } finally {
        if (model != null) {
            model.close();
            model = null;
        }
    }

    LinkedList<Miner.MinerType> foundMinerTypes = new LinkedList<Miner.MinerType>();

    for (MetaData meta : registeredMiner) {
        if (foundMinerTypes.contains(meta.getType())) {
            continue;
        }

        if (meta.is(project, settings)) {
            Miner miner = meta.create(settings, project, pool, reporter);
            miner.addListener(listeners);
            this.miners.add(new RunnableMiner(this, miner));
            foundMinerTypes.add(meta.getType());
        }
    }

    if (settings.bugRepository != null || settings.bugProductName != null) {
        if (!foundMinerTypes.contains(Miner.MinerType.BUG)) {
            throw new MinerException("No fitting bug repository miner found.");
        }
    }
    if (settings.srcLocalPath != null) {
        if (!foundMinerTypes.contains(Miner.MinerType.SOURCE)) {
            throw new MinerException("No fitting source repository miner found.");
        }
    }
}

From source file:org.nekorp.workflow.desktop.view.CobranzaView.java

@Override
public void updateModel(Object origen, String property, Object value) {
    if (!ignore.remove(value)) {
        LinkedList<PagoCobranzaVB> param = (LinkedList<PagoCobranzaVB>) value;
        LinkedList<PagoCobranzaVB> borrar = new LinkedList<>();
        for (PagoCobranzaVB obj : modelo) {
            if (!param.contains(obj)) {
                borrar.add(obj);//from   w w  w  .j a  v  a  2  s.c  om
            }
        }
        for (PagoCobranzaVB x : borrar) {
            removePago(x);
        }
        for (int i = 0; i < param.size(); i++) {
            if (this.modelo.size() > i) {
                if (!param.get(i).equals(this.modelo.get(i))) {
                    this.modelo.add(i, param.get(i));
                    addPagoView(this.modelo.get(i), i);
                }
            } else {
                this.modelo.add(param.get(i));
                addPagoView(this.modelo.get(i), i);
            }
        }
        this.updateUI();
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                jScrollPane1.getVerticalScrollBar().setValue(jScrollPane1.getVerticalScrollBar().getMaximum());
            }
        });
    }
}

From source file:hsa.awp.scire.procedureLogic.DrawProcedureLogic.java

@Override
public synchronized void register(Set<PriorityList> lists) {

    if (drawn) {/*from w  ww  .java 2 s  . co  m*/
        throw new IllegalStateException("cannot register anymore : already drawn");
    } else if (lists == null || lists.size() == 0) {
        throw new IllegalArgumentException("no priorityList set given");
    }

    Long initiator = null;
    Long participant = null;
    for (PriorityList list : lists) {
        if (initiator == null) {
            if (list.getInitiator() == null) {
                throw new IllegalArgumentException("no initiator given (:null)");
            } else if (list.getParticipant() == null) {
                throw new IllegalArgumentException("no participant given (:null)");
            } else {
                initiator = list.getInitiator();
                participant = list.getParticipant();
            }
        } else if (initiator != list.getInitiator()) {
            throw new IllegalArgumentException("different initiators given");
        } else if (participant != list.getParticipant()) {
            throw new IllegalArgumentException("different participants given");
        }
    }

    // check whether an Event was added two times.
    LinkedList<Long> events = new LinkedList<Long>();
    for (PriorityList list : lists) {
        for (PriorityListItem item : getSortedPriorityListItemsOfPriorityList(list)) {
            if (events.contains(item.getEvent())) {
                throw new DuplicatePriorityListElementException(item.getEvent().toString());
            }
            events.add(item.getEvent());
        }
    }

    for (PriorityList list : lists) {
        register(list);
    }
}

From source file:org.agnitas.web.MailingStatAction.java

/**
 * Loads mailing statistics./*w w  w . ja va 2  s . co  m*/
 */
protected void loadMailingStat(MailingStatForm aForm, HttpServletRequest req) {
    //set variables from form:

    MailingStat aMailStat = (MailingStat) getBean("MailingStat");
    aMailStat.setCompanyID(getCompanyID(req));
    int tid = aForm.getTargetID();
    aMailStat.setTargetID(tid);
    int mid = aForm.getMailingID();
    aMailStat.setMailingID(mid);

    if (aForm.getTargetIDs() != null) {
        LinkedList targets = aForm.getTargetIDs();
        int atid = aForm.getNextTargetID();
        if (targets.contains(new Integer(atid)) == false) {
            targets.add(new Integer(atid));
        }

        if (req.getParameter("delTargetID") != null) {
            if (targets.contains(new Integer(req.getParameter("delTargetID"))) && targets.size() > 1) {
                targets.remove(new Integer(req.getParameter("delTargetID")));
            }
        }
        aMailStat.setTargetIDs(targets);
    } else {
        LinkedList targets = new LinkedList();
        targets.add(new Integer(0));
        aMailStat.setTargetIDs(targets);
    }

    // if we come from the mailstat page itself, pass statValues data:
    if (req.getParameter("add.x") != null) {
        aMailStat.setStatValues(aForm.getStatValues());
    } else if (req.getParameter("delTargetID") != null) {
        // delete MailingStatEntry for targetID to be deleted:
        Hashtable tmpStatVal = aForm.getStatValues();
        if (tmpStatVal.containsKey(new Integer(req.getParameter("delTargetID")))) {
            tmpStatVal.remove(new Integer(req.getParameter("delTargetID")));
        }
        // and put the statValues in the MailingStat class:
        aMailStat.setStatValues(tmpStatVal);
    } else {
        // delete all stat info:
        LinkedList targets = new LinkedList();
        targets.add(new Integer(0));
        aMailStat.setTargetIDs(targets);
        Hashtable tmpStatVal = new Hashtable();
        aMailStat.setStatValues(tmpStatVal);
    }

    if (aMailStat.getMailingStatFromDB(this.getWebApplicationContext(),
            (Locale) req.getSession().getAttribute(org.apache.struts.Globals.LOCALE_KEY)) == true) {
        // write results back to form:
        aForm.setCsvfile(aMailStat.getCsvfile());
        aForm.setClickSubscribers(aMailStat.getClickSubscribers());
        aForm.setClicks(aMailStat.getClicks());
        aForm.setOpenedMails(aMailStat.getOpenedMails());
        aForm.setOptOuts(aMailStat.getOptOuts());
        aForm.setBounces(aMailStat.getBounces());
        aForm.setTotalSubscribers(aMailStat.getTotalSubscribers());
        aForm.setValues(aMailStat.getValues());
        aForm.setMailingShortname(aMailStat.getMailingShortname());
        aForm.setMailingID(mid);
        aForm.setStatValues(aMailStat.getStatValues());
        aForm.setTargetIDs(aMailStat.getTargetIDs());
        aForm.setUrlNames(aMailStat.getUrls());
        aForm.setUrlShortnames(aMailStat.getUrlShortnames());
        aForm.setMaxblue(aMailStat.getMaxblue());
        aForm.setMaxNRblue(aMailStat.getMaxNRblue());
        aForm.setMaxSubscribers(aMailStat.getMaxSubscribers());
        aForm.setClickedUrls(aMailStat.getClickedUrls());
        aForm.setNotRelevantUrls(aMailStat.getNotRelevantUrls());
    } else {
        AgnUtils.logger().error("loadMailingStat: could not load mailing stats.");
    }
}

From source file:nl.nn.adapterframework.extensions.tibco.GetTibcoQueues.java

private Map getConnectedConsumersMap(TibjmsAdmin admin) throws TibjmsAdminException {
    Map connectionMap = new HashMap();
    ConnectionInfo[] connectionInfos = admin.getConnections();
    for (int i = 0; i < connectionInfos.length; i++) {
        ConnectionInfo connectionInfo = connectionInfos[i];
        long id = connectionInfo.getID();
        String clientId = connectionInfo.getClientID();
        if (StringUtils.isNotEmpty(clientId)) {
            connectionMap.put(id, clientId);
        }/*  w  w w.  j  a  v  a 2s  .  co m*/
    }

    Map consumerMap = new HashMap();
    ConsumerInfo[] consumerInfos = admin.getConsumers();
    for (int i = 0; i < consumerInfos.length; i++) {
        ConsumerInfo consumerInfo = consumerInfos[i];
        String destinationName = consumerInfo.getDestinationName();
        long connectionId = consumerInfo.getConnectionID();
        if (connectionMap.containsKey(connectionId)) {
            String ci = (String) connectionMap.get(connectionId);
            if (consumerMap.containsKey(destinationName)) {
                LinkedList consumers = (LinkedList) consumerMap.get(destinationName);
                if (!consumers.contains(ci)) {
                    consumers.add(ci);
                    consumerMap.remove(consumers);
                    consumerMap.put(destinationName, consumers);
                }
            } else {
                LinkedList consumers = new LinkedList();
                consumers.add(ci);
                consumerMap.put(destinationName, consumers);
            }
        }
    }
    return consumerMap;
}

From source file:com.launcher.silverfish.AppDrawerTabFragment.java

/**
 * Loads apps from the database//from w w  w.  j a  v  a 2  s. c  om
 */
private void loadApps() {

    Intent i = new Intent(Intent.ACTION_MAIN, null);
    i.addCategory(Intent.CATEGORY_LAUNCHER);

    switch (tabId) {
    case 1:
        // Tab 1 is a special tab and includes all except for the once in other tabs
        // so we retrieve all apps that are in the database
        LinkedList<String> ordered_apps = sqlHelper.getAllApps();

        // And all installed apps on the device
        List<ResolveInfo> availableActivities = mPacMan.queryIntentActivities(i, 0);

        // And only add those that are not in the database
        for (int j = 0; j < availableActivities.size(); j++) {
            ResolveInfo ri = availableActivities.get(j);

            // Skip the apps that are in the database
            if (ordered_apps.contains(ri.activityInfo.packageName)) {
                continue;
            }

            AppDetail app = new AppDetail();
            app.label = ri.loadLabel(mPacMan);
            app.name = ri.activityInfo.packageName;

            // Load the icon later in an async task.
            app.icon = null;

            appsList.add(app);
        }
        break;
    default:
        // All other tabs just query the apps from the database
        LinkedList<String> app_names = sqlHelper.getAppsForTab(tabId);
        for (String app_name : app_names) {

            boolean success = addAppToList(app_name);
            // If the app could not be added then it was probably uninstalled,
            // so we have to remove it from the database
            if (!success) {
                Log.d("DB", "Removing app " + app_name + " from db");
                sqlHelper.removeAppFromTab(app_name, this.tabId);
            }
        }

        // show the empty category notice if this tab is empty
        if (app_names.size() == 0) {
            showEmptyCategoryNotice();
        }
    }
}

From source file:org.videolan.vlc.gui.PlaylistActivity.java

protected void deleteMedia(final MediaLibraryItem mw) {
    VLCApplication.runBackground(new Runnable() {
        @Override/*www. j  a va2s  .  c  o  m*/
        public void run() {
            final LinkedList<String> foldersToReload = new LinkedList<>();
            final LinkedList<String> mediaPaths = new LinkedList<>();
            for (MediaWrapper media : mw.getTracks(mMediaLibrary)) {
                String path = media.getUri().getPath();
                mediaPaths.add(media.getLocation());
                String parentPath = FileUtils.getParent(path);
                if (FileUtils.deleteFile(path) && media.getId() > 0L && !foldersToReload.contains(parentPath))
                    foldersToReload.add(parentPath);
            }
            for (String folder : foldersToReload)
                mMediaLibrary.reload(folder);
            if (mService != null) {
                VLCApplication.runOnMainThread(new Runnable() {
                    @Override
                    public void run() {
                        for (String path : mediaPaths)
                            mService.removeLocation(path);
                    }
                });
            }
        }
    });
}