Example usage for java.util ArrayList contains

List of usage examples for java.util ArrayList contains

Introduction

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

Prototype

public boolean contains(Object o) 

Source Link

Document

Returns true if this list contains the specified element.

Usage

From source file:org.cfr.capsicum.test.AbstractCayenneJUnit4DbUnitSpringContextTests.java

private String[] getTableNames(boolean reverse) {
    Collection<DbEntity> entities = getCayenneRuntimeContext().getDataDomain().getEntityResolver()
            .getDbEntities();/*from  w  ww . ja v  a  2  s.  com*/
    ArrayList<String> tables = new ArrayList<String>(entities.size());
    for (DbEntity dbEntity : entities) {
        if (tables.contains(dbEntity.getFullyQualifiedName())) {
            continue;
        }
        addTableName(tables, dbEntity);
    }
    if (reverse) {
        Collections.reverse(tables);
    }
    return tables.toArray(new String[tables.size()]);
}

From source file:edu.kit.scc.ldap.LdapClient.java

/**
 * Generates a non-conflicting group id number.
 * // www  . j  a v  a  2  s .c o  m
 * @return a new int gidNumber
 */
@Deprecated
public int generateGroupIdNumber() {
    int max = 99999;
    int min = 10000;
    Random rand = new Random();
    ArrayList<String> existingGidNumbers = new ArrayList<String>();
    List<PosixGroup> groups = ldapPosixGroup.getAllGroups();
    for (PosixGroup group : groups) {
        existingGidNumbers.add(group.getGidNumber());
    }
    int randomInt = rand.nextInt((max - min) + 1) + min;
    while (existingGidNumbers.contains(String.valueOf(randomInt))) {
        randomInt = rand.nextInt((max - min) + 1) + min;
    }
    return randomInt;
}

From source file:com.pwn9.PwnFilter.minecraft.PwnFilterPlugin.java

/**
 * <p>updateMetrics.</p>/*from  w  w w .j  av a 2  s.  c o  m*/
 */
public void updateMetrics() {
    ArrayList<String> activeListenerNames = FilterEngine.getInstance().getActiveClients().stream()
            .map(FilterClient::getShortName).collect(Collectors.toCollection(ArrayList::new));

    // Remove old plotters
    eventGraph.getPlotters().stream().filter(p -> !activeListenerNames.contains(p.getColumnName()))
            .forEach(p -> eventGraph.removePlotter(p));

    // Add new plotters
    for (final FilterClient f : FilterEngine.getInstance().getActiveClients()) {
        final String eventName = f.getShortName();
        eventGraph.addPlotter(new Metrics.Plotter(eventName) {
            @Override
            public int getValue() {
                RuleChain r = f.getRuleChain();
                if (r != null) {
                    return r.ruleCount(); // Number of rules for this event type
                } else
                    return 0;
            }
        });
    }
}

From source file:com.sec.ose.osi.thread.job.identify.data.CodeMatchIdentify.java

@Override
public void updateDBnUI(String action) throws SdkFault {

    String optionRefreshMode = Property.getInstance()
            .getProperty(Property.IDENTIFICATION_WITH_SYNCHRONOUS_BOM_REFRESH);
    if ("true".equals(optionRefreshMode.toLowerCase()) == false) {
        return;/*from  w  w  w .  ja va  2s .c o m*/
    }

    /** Code Match **/
    long startTime = Time.startTime("getCodeMatchDiscoveries");
    List<CodeMatchDiscovery> listCodeMatchDiscovery = ProtexSDKAPIManager.getDiscoveryAPI()
            .getCodeMatchDiscoveries(projectID, fileOnlyTree, precisionOnly);
    Time.endTime("getCodeMatchDiscoveries", startTime);

    DCCodeMatch cdc = ((DCCodeMatch) ProjectDiscoveryControllerMap.getDiscoveryController(projectName,
            IdentificationConstantValue.CODE_MATCH_TYPE));

    ArrayList<String> newFileList = null;
    if (!bFile) {
        ComponentVersion cv = ComponentAPIWrapper.getComponentVersionById(currentComponentID, currentVersionID);
        if (cv != null) {
            newFileList = cdc.getUpdateTarget(projectName, curFilePath, cv.getComponentName(),
                    cv.getVersionName());
        }
    }
    boolean isRemain = cdc.updateDB(action, newFileList, listCodeMatchDiscovery, newComponentName,
            isSelected_ThirdForthOption);
    listCodeMatchDiscovery = null;
    log.debug("isRemain : " + isRemain);

    String projectIDFromServer = ProjectAPIWrapper.getProjectID(projectName);

    if (isRemain && projectID != null && projectID.equals(projectIDFromServer)) {
        IdentifyMediator.getInstance().refreshIdentificationInfoForSnippetRefresh(projectName, this.curFilePath,
                IdentificationConstantValue.CODE_MATCH_TYPE);

        AbstractDiscoveryController controller = ProjectDiscoveryControllerMap
                .getDiscoveryController(projectName, IdentificationConstantValue.CODE_MATCH_TYPE);
        ArrayList<String> pendingFilePathList = controller.getPendingFileList();
        String projectNameByUI = IdentifyMediator.getInstance().getSelectedProjectName();
        if ((pendingFilePathList.contains(curFilePath) == true) && (action.equals("identify") == true)
                && (isSelected_ThirdForthOption == false) && (projectNameByUI != null)
                && (projectNameByUI.equals(projectName))) {

            RemainedSnippetAlarmMgr.getInstance().showAlarmMessage(new RemainedSnippetAlarmInfo(
                    DateUtil.getCurrentTime("%1$tm-%1$td %1$tH:%1$tM:%1$tS"), curFilePath, newComponentName));

        }
    }
}

From source file:com.concursive.connect.web.modules.wiki.utils.HTMLToWikiUtils.java

private static boolean getNodes(NodeList nodeList, ArrayList<Node> nodes, String[] tags,
        boolean checkChildren) {
    ArrayList<String> list = new ArrayList<String>(Arrays.asList(tags));
    // Check the immediate node level
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node n = nodeList.item(i);
        if (n != null) {
            if (n.getNodeType() == Node.ELEMENT_NODE) {
                Element element = ((Element) n);
                String tag = element.getTagName();
                if (list.contains(tag)) {
                    nodes.add(n);/*  w  ww . ja v a 2  s  .c  o m*/
                }
            }
        }
    }
    if (nodes.size() > 0) {
        return true;
    }
    // Check the children nodes
    if (checkChildren) {
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node n = nodeList.item(i);
            getNodes(n.getChildNodes(), nodes, tags, checkChildren);
        }
    }
    return nodes.size() > 0;
}

From source file:be.ac.ua.comp.scarletnebula.gui.windows.ServerPropertiesWindow.java

private Component getMultipleServerTagComponent(final Collection<Server> servers) {
    final ArrayList<String> tags = new ArrayList<String>();

    for (final Server server : servers) {
        for (final String tag : server.getTags()) {
            if (!tags.contains(tag)) {
                tags.add(tag);/*from  ww w. j ava2  s  . co  m*/
            }
        }
    }
    return new JLabel(Utils.implode(tags, ", "));
}

From source file:com.bilko.controller.BlogController.java

private ArrayList<String> extractTags(final String tags) {
    final String tagArray[] = tags.replaceAll("\\s", "").split(",");

    final ArrayList<String> cleaned = new ArrayList<>();
    for (final String tag : tagArray) {
        if (isNotBlank(tag) && !cleaned.contains(tag)) {
            cleaned.add(tag);/*  ww  w .j av a2  s  .  c  o m*/
        }
    }
    return cleaned;
}

From source file:fr.eolya.utils.http.HttpUtils.java

public static List<String> extractLinksFromFeed(String rawPage) {
    final ArrayList<String> list = new ArrayList<String>();

    try {//from  w w  w.j  a  va  2 s.c  o  m
        XmlReader xmlReader = new XmlReader(new ByteArrayInputStream(rawPage.getBytes()));
        SyndFeedInput input = new SyndFeedInput();
        SyndFeed feed = input.build(xmlReader);

        Object[] arraySyndEntry = feed.getEntries().toArray();
        for (int k = arraySyndEntry.length - 1; k >= 0; k--) {
            SyndEntryImpl syndEntry = (SyndEntryImpl) arraySyndEntry[k];
            String link = strLinkCleanup(syndEntry.getLink());
            if (!list.contains(link))
                list.add(link);
        }
        return list;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

From source file:at.ait.dme.yuma.server.enrichment.SemanticEnrichmentServiceImpl.java

private List<String> parseOpenCalaisResponse(String xml) throws Exception {
    DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    Document doc = builder.parse(new ByteArrayInputStream(xml.getBytes("UTF-8")));

    ArrayList<String> namedEntities = new ArrayList<String>();
    NodeList nodes = doc.getElementsByTagName("c:name");
    String name;//  w w  w  .  j ava2  s .  c  o  m
    for (int i = 0; i < nodes.getLength(); i++) {
        name = nodes.item(i).getTextContent();
        if (!name.contains(",") && !namedEntities.contains(name))
            namedEntities.add(name);
    }
    return namedEntities;
}

From source file:com.yoctopuce.YoctoAPI.YFirmwareUpdate.java

private void _processMore(int start) {
    synchronized (this) {
        if (start > 0) {
            if (_thread == null || !_thread.isAlive()) {
                _progress(0, "Firmware update started");
                _thread = new Thread(new Runnable() {
                    @Override/*from  w  w w.  ja va 2  s  .  c  o m*/
                    public void run() {
                        YFirmwareFile firmware;
                        try {
                            //1% -> 5%
                            _progress(1, "Loading firmware");
                            if (_firmwarepath.startsWith("www.yoctopuce.com")
                                    || _firmwarepath.startsWith("http://www.yoctopuce.com")) {
                                byte[] bytes = YFirmwareUpdate._downloadfile(_firmwarepath);
                                firmware = YFirmwareFile.Parse(_firmwarepath, bytes);
                            } else {
                                firmware = YFirmwareUpdate._loadFirmwareFile(new File(_firmwarepath));
                            }

                            //5% -> 10%
                            _progress(5, "check if module is already in bootloader");
                            YGenericHub hub = null;
                            YModule module = YModule.FindModule(_serial + ".module");
                            if (module.isOnline()) {
                                YDevice yDevice = module.getYDevice();
                                hub = yDevice.getHub();
                            } else {
                                // test if already in bootloader
                                for (YGenericHub h : SafeYAPI()._hubs) {
                                    ArrayList<String> bootloaders = h.getBootloaders();
                                    if (bootloaders.contains(_serial)) {
                                        hub = h;
                                        break;

                                    }
                                }
                            }
                            if (hub == null) {
                                throw new YAPI_Exception(YAPI.DEVICE_NOT_FOUND,
                                        "device " + _serial + " is not detected");
                            }

                            hub.firmwareUpdate(_serial, firmware, _settings, new YGenericHub.UpdateProgress() {
                                @Override
                                public void firmware_progress(int percent, String message) {
                                    _progress(5 + percent * 80 / 100, message);
                                }
                            });
                            //80%-> 98%
                            _progress(80, "wait to the device restart");
                            long timeout = YAPI.GetTickCount() + 30000;
                            while (!module.isOnline() && timeout > YAPI.GetTickCount()) {
                                Thread.sleep(500);
                                try {
                                    YAPI.UpdateDeviceList();
                                } catch (YAPI_Exception ignore) {
                                }
                            }
                            if (module.isOnline()) {
                                if (_settings != null) {
                                    module.set_allSettings(_settings);
                                }
                                _progress(100, "Success");
                            } else {
                                _progress(-1, "Device did not reboot correctly");
                            }
                        } catch (YAPI_Exception e) {
                            _progress(e.errorType, e.getLocalizedMessage());
                            e.printStackTrace();
                        } catch (InterruptedException ignore) {
                        }

                    }
                }, "Update" + _serial);
                _thread.start();
            }
        }
    }
}