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:com.sec.ose.osi.report.standard.data.BillOfMaterialsRowGenerator.java

private ArrayList<String> getCategorySet(ArrayList<IdentifiedFilesRow> fileEntList) {
    if (fileEntList == null || fileEntList.size() == 0)
        return null;

    ArrayList<String> categoryList = new ArrayList<String>();

    for (IdentifiedFilesRow ent : fileEntList) {
        String root = getRoot(ent.getFullPath());
        if (!categoryList.contains(root))
            categoryList.add(root);//  w  w w.  j  ava 2 s  .c om
    }

    return categoryList;
}

From source file:com.amazon.carbonado.repo.jdbc.JDBCStorableIntrospector.java

private static void addToSet(ArrayList<String> list, String value) {
    if (!list.contains(value)) {
        list.add(value);//w w w . ja va  2 s.co  m
    }
}

From source file:de.ellpeck.actuallyadditions.mod.gen.OreGen.java

private void generateRice(DecorateBiomeEvent event) {
    if (ConfigBoolValues.DO_RICE_GEN.isEnabled()) {
        for (int i = 0; i < ConfigIntValues.RICE_AMOUNT.getValue(); i++) {
            if (event.getRand().nextInt(50) == 0) {
                BlockPos randomPos = new BlockPos(event.getPos().getX() + event.getRand().nextInt(16) + 8, 0,
                        event.getPos().getZ() + event.getRand().nextInt(16) + 8);
                randomPos = event.getWorld().getTopSolidOrLiquidBlock(randomPos);
                if (event.getWorld().getBlockState(randomPos).getMaterial() == Material.WATER) {
                    ArrayList<Material> blocksAroundBottom = WorldUtil.getMaterialsAround(event.getWorld(),
                            randomPos);/*ww w  .  ja  v  a2s. c om*/
                    BlockPos posToGenAt = randomPos.up();
                    ArrayList<Material> blocksAroundTop = WorldUtil.getMaterialsAround(event.getWorld(),
                            posToGenAt);
                    if (blocksAroundBottom.contains(Material.GRASS)
                            || blocksAroundBottom.contains(Material.GROUND)
                            || blocksAroundBottom.contains(Material.ROCK)
                            || blocksAroundBottom.contains(Material.SAND)) {
                        if (!blocksAroundTop.contains(Material.WATER)
                                && event.getWorld().getBlockState(posToGenAt).getMaterial() == Material.AIR) {
                            event.getWorld().setBlockState(posToGenAt,
                                    InitBlocks.blockWildPlant.getStateFromMeta(TheWildPlants.RICE.ordinal()),
                                    2);
                        }
                    }
                }
            }
        }
    }
}

From source file:com.bayontechnologies.bi.pentaho.plugin.openflashchart.OpenFlashChartComponent.java

public static Map<String, ArrayList<String>> parseString(final String template) {
    Map<String, ArrayList<String>> map = new HashMap<String, ArrayList<String>>();
    ArrayList<String> columns = new ArrayList<String>();
    ArrayList<String> headers = new ArrayList<String>();
    ArrayList<String> maxs = new ArrayList<String>();
    ArrayList<String> mins = new ArrayList<String>();
    ArrayList<String> customs = new ArrayList<String>();

    String token1 = "{";
    String token2 = "}";
    String tmpTemplate = template;

    int index = tmpTemplate.indexOf(token1);
    int index2 = tmpTemplate.indexOf(token2);
    while (index != -1) {
        String tmpStr = tmpTemplate.substring(index + 1, index2);
        //check the illegal token
        if (tmpStr.indexOf(":") != -1 || tmpStr.indexOf(";") != -1) {
            tmpTemplate = tmpTemplate.substring(0, index - 1 >= 0 ? index - 1 : 0)
                    + tmpTemplate.substring(index2 + 1);
            index = tmpTemplate.indexOf(token1);
            index2 = tmpTemplate.indexOf(token2);
            continue;
        }//from www.ja va2  s.c o m

        if (tmpStr.indexOf("col") != -1) {
            if (!columns.contains(tmpStr))
                columns.add(tmpStr);
        } else if (tmpStr.indexOf("head") != -1) {
            if (!headers.contains(tmpStr))
                headers.add(tmpStr);
        } else if (tmpStr.indexOf("max") != -1) {
            if (!maxs.contains(tmpStr))
                maxs.add(tmpStr);
        } else if (tmpStr.indexOf("min") != -1) {
            if (!mins.contains(tmpStr))
                mins.add(tmpStr);
        } else //any other my custom variable
        {
            if (!customs.contains(tmpStr))
                customs.add(tmpStr);
        }

        tmpTemplate = tmpTemplate.substring(0, index - 1 >= 0 ? index - 1 : 0)
                + tmpTemplate.substring(index2 + 1);
        index = tmpTemplate.indexOf(token1);
        index2 = tmpTemplate.indexOf(token2);
    }

    map.put("colN", columns);
    map.put("headN", headers);
    map.put("maxN", maxs);
    map.put("minN", mins);
    map.put("customs", customs);
    return map;
}

From source file:de.ellpeck.actuallyadditions.mod.gen.AAWorldGen.java

private void generateRice(DecorateBiomeEvent event) {
    if (ConfigBoolValues.DO_RICE_GEN.isEnabled()) {
        for (int i = 0; i < ConfigIntValues.RICE_AMOUNT.getValue(); i++) {
            if (event.getRand().nextInt(3) == 0) {
                BlockPos randomPos = event.getChunkPos().getBlock(event.getRand().nextInt(16) + 8, 0,
                        event.getRand().nextInt(16) + 8);
                randomPos = event.getWorld().getTopSolidOrLiquidBlock(randomPos);
                if (event.getWorld().getBlockState(randomPos).getMaterial() == Material.WATER) {
                    ArrayList<Material> blocksAroundBottom = WorldUtil.getMaterialsAround(event.getWorld(),
                            randomPos);/*from w  ww .j  av a2 s  . co m*/
                    BlockPos posToGenAt = randomPos.up();
                    ArrayList<Material> blocksAroundTop = WorldUtil.getMaterialsAround(event.getWorld(),
                            posToGenAt);
                    if (blocksAroundBottom.contains(Material.GRASS)
                            || blocksAroundBottom.contains(Material.GROUND)
                            || blocksAroundBottom.contains(Material.ROCK)
                            || blocksAroundBottom.contains(Material.SAND)) {
                        if (!blocksAroundTop.contains(Material.WATER)
                                && event.getWorld().getBlockState(posToGenAt).getMaterial() == Material.AIR) {
                            event.getWorld().setBlockState(posToGenAt, InitBlocks.blockWildPlant
                                    .getDefaultState().withProperty(BlockWildPlant.TYPE, TheWildPlants.RICE),
                                    2);
                        }
                    }
                }
            }
        }
    }
}

From source file:userinterface.StateNetworkAdminRole.StateReportsJPanel.java

private CategoryDataset createDataSetForDonorReports() {
    ArrayList<String> cityList = new ArrayList<>();

    DefaultCategoryDataset barChartData = new DefaultCategoryDataset();
    for (Donor donor : donorDirectory.getDonorList()) {
        if (!cityList.contains(donor.getDonorAddress()) && !cityList.contains(donor.getDonorAddress() + " ")) {

            cityList.add(donor.getDonorAddress());
        }//from ww  w. ja  v a 2s .co m
    }

    for (String city : cityList) {
        Map<Integer, Integer> yearDonorMap = new HashMap<>();
        for (Donor donor : donorDirectory.getDonorList()) {
            if (donor.getDonorAddress().trim().equalsIgnoreCase(city.trim())) {
                int counter = 1;
                Date regDate = donor.getDonorRegisterationDate();
                Calendar cal = Calendar.getInstance();
                cal.setTime(regDate);

                int year = cal.get(Calendar.YEAR);
                if (yearDonorMap.containsKey(year)) {
                    counter = yearDonorMap.get(year);
                    counter++;
                    yearDonorMap.put(year, counter);
                } else {
                    yearDonorMap.put(year, counter);
                }
            }
        }
        for (Map.Entry<Integer, Integer> entryset : yearDonorMap.entrySet()) {
            barChartData.addValue(entryset.getValue(), city, entryset.getKey());
        }
    }

    return barChartData;
}

From source file:com.yahoo.athenz.zts.store.impl.S3ChangeLogStoreTest.java

@Test
public void testListObjectsAllObjectsNoPage() {

    MockS3ChangeLogStore store = new MockS3ChangeLogStore(null);

    ArrayList<S3ObjectSummary> objectList = new ArrayList<>();
    S3ObjectSummary objectSummary = new S3ObjectSummary();
    objectSummary.setKey("iaas");
    objectList.add(objectSummary);//from w  w  w  .java 2 s . c om
    objectSummary = new S3ObjectSummary();
    objectSummary.setKey("iaas.athenz");
    objectList.add(objectSummary);

    ObjectListing objectListing = mock(ObjectListing.class);
    when(objectListing.getObjectSummaries()).thenReturn(objectList);
    when(objectListing.isTruncated()).thenReturn(false);
    when(store.s3.listObjects(any(ListObjectsRequest.class))).thenReturn(objectListing);

    ArrayList<String> domains = new ArrayList<>();
    store.listObjects(store.s3, domains, 0);

    assertEquals(domains.size(), 2);
    assertTrue(domains.contains("iaas"));
    assertTrue(domains.contains("iaas.athenz"));
}

From source file:de.indiplex.javapt.JavAPT.java

private void getDepends(String packagename, ArrayList<String> depends) throws IOException, SQLException {
    if (packagename.equals("")) {
        return;//ww w  .j av a2 s  . c o m
    }
    if (depends.contains(packagename)) {
        depends.remove(packagename);
        depends.add(packagename);
        return;
    }
    DEB deb = hashDEB.get(packagename);
    if (deb == null) {
        ResultSet rs = db.getStat()
                .executeQuery("SELECT name FROM packages WHERE provides LIKE '%" + packagename + "%'");
        int i = 0;
        while (rs.next()) {
            getDepends(rs.getString("name"), depends);
            i++;
        }
        if (i == 0) {
            System.out.println("Can't find " + packagename);
        }
        return;
    }
    depends.add(packagename);
    String[] deps = deb.depends.split("\\,");
    for (String dep : deps) {
        dep = dep.trim();
        getDepends(dep, depends);
    }
}

From source file:de.micmun.android.workdaystarget.DayCalculator.java

/**
 * Returns the number of days between today and target, skipped days in
 * appliance of checkedDays.//from   w  w  w  .j  a  v  a2 s .c o  m
 *
 * @param t           Date of the target, to which to calculate the working days.
 * @param checkedDays Array with boolean flags, which says if a weekday should count
 *                    or not.
 * @return days to target.
 * @throws JSONException if an error occurs while getting the holidays from web service.
 */
public int getDaysLeft(Date t, boolean[] checkedDays) throws JSONException {
    // sets target time at midnight
    target.setTime(t);
    setMidnight(target);

    int sign = 1;

    if (target.getTimeInMillis() < today.getTimeInMillis()) {
        Calendar tmp = Calendar.getInstance();
        tmp.setTimeInMillis(target.getTimeInMillis());
        target.setTimeInMillis(today.getTimeInMillis());
        today.setTimeInMillis(tmp.getTimeInMillis());
        sign = -1; // negative days in the past
    }

    // Holidays
    ArrayList<Date> holidays = getHolidays();

    // current time
    Calendar curr = Calendar.getInstance();
    curr.setTime(today.getTime());

    int count = 0;

    while (curr.getTimeInMillis() != target.getTimeInMillis()) {
        curr.add(Calendar.DAY_OF_MONTH, 1);
        int dayOfWeek = curr.get(Calendar.DAY_OF_WEEK);

        if (!checkedDays[POS_HOLIDAY] && holidays.contains(curr.getTime())) {
            continue;
        } else if (!checkedDays[POS_SUNDAY] && dayOfWeek == Calendar.SUNDAY) {
            continue;
        } else if (dayOfWeek != Calendar.SUNDAY && !checkedDays[dayOfWeek - Calendar.MONDAY]) {
            continue;
        }
        count++;
    }

    count *= sign; // if target is in the past, sign == -1

    return count;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.config.fileextension.FileExtensionMainHandler.java

private void checkExtention() {
    String[] extensions = { "htm", "html", "shtml", "jhtml", "txt", "css", "js", "properties", "cfm", "cfml",
            "asp", "jsp", "xml", "doc", "xls", "ppt", "fm", "qxd", "cpp", "java", "pdf", "indd", "ai", "docx",
            "xlsx", "pptx", "rtf", "inx", "xlf", "xliff", "rc" };
    String currentId = CompanyThreadLocal.getInstance().getValue();
    long companyId = Long.parseLong(currentId);
    String sql = "from FileExtensionImpl f where f.companyId=:companyId";
    Map map = new HashMap();
    map.put("companyId", companyId);

    List extentionList = HibernateUtil.search(sql, map);
    ArrayList nameList = new ArrayList();

    for (int i = 0; i < extentionList.size(); i++) {
        nameList.add(((FileExtensionImpl) extentionList.get(i)).getName());
    }/*from  www.j a v  a  2 s. c om*/

    ArrayList exCol = new ArrayList();

    for (int i = 0; i < extensions.length; i++) {
        if (!nameList.contains(extensions[i])) {
            FileExtensionImpl fe = new FileExtensionImpl();
            fe.setCompanyId(companyId);
            fe.setName(extensions[i]);
            exCol.add(fe);
        }
    }

    try {
        HibernateUtil.save(exCol);
    } catch (Exception e) {
    }
    ;
}