Example usage for java.util List indexOf

List of usage examples for java.util List indexOf

Introduction

In this page you can find the example usage for java.util List indexOf.

Prototype

int indexOf(Object o);

Source Link

Document

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.

Usage

From source file:gov.nih.nci.caarray.plugins.nimblegen.PairDataHandler.java

private void validateProbeNames(final DelimitedFileReader reader, final ArrayDesign design,
        final FileValidationResult fileValidationResult) throws IOException {
    final ProbeNamesValidator probeNamesValidator = new ProbeNamesValidator(this.arrayDao, design);
    final List<String> probeNamesBatch = new ArrayList<String>();
    int probeCounter = 0;
    final List<String> headers = getHeaders(reader);
    final int seqIdIndex = headers.indexOf(SEQ_ID_HEADER);
    final int probeIdIndex = headers.indexOf(PROBE_ID_HEADER);
    final int containerIndex = headers.indexOf(CONTAINER_HEADER);
    while (reader.hasNextLine()) {
        final List<String> values = reader.nextLine();
        final String probeId = values.get(probeIdIndex);
        final String sequenceId = values.get(seqIdIndex);
        final String container = values.get(containerIndex);
        final String probeName = container + "|" + sequenceId + "|" + probeId;
        probeNamesBatch.add(probeName);// w w  w.j a  va2s  . c o m
        probeCounter++;
        if (0 == probeCounter % BATCH_SIZE) {
            probeNamesValidator.validateProbeNames(fileValidationResult, probeNamesBatch);
            probeNamesBatch.clear();
        }
    }
    if (!probeNamesBatch.isEmpty()) {
        probeNamesValidator.validateProbeNames(fileValidationResult, probeNamesBatch);
    }
}

From source file:com.mobiaware.auction.provider.impl.CSVImportService.java

@Override
public void importUsers(final int auctionUid, final Reader reader) {
    CSVReader cvsreader = null;// ww  w .  j ava2 s. c  o m
    try {
        cvsreader = new CSVReader(reader, CSVParser.DEFAULT_SEPARATOR, CSVParser.DEFAULT_QUOTE_CHARACTER,
                CSVParser.DEFAULT_ESCAPE_CHARACTER, 0, false, false);

        List<String> headers = Arrays.asList(cvsreader.readNext());

        String[] nextLine;
        while ((nextLine = cvsreader.readNext()) != null) {
            User user = User.newBuilder().setAuctionUid(auctionUid)
                    .setBidderNumber(nextLine[headers.indexOf("bidder_number")])
                    .setFirstName(nextLine[headers.indexOf("first_name")])
                    .setLastName(nextLine[headers.indexOf("last_name")]).setRole(Roles.GUEST).build();

            // Last name is used the password.
            String passwordHash = _passwordService.encryptPassword(user.getLastName());
            user.setPasswordHash(passwordHash);

            _dataService.editUser(user);
        }
    } catch (IOException e) {
        LOG.error(Throwables.getStackTraceAsString(e));
    } finally {
        IOUtils.closeQuietly(cvsreader);
    }
}

From source file:adalid.core.Tab.java

/**
 * @return the tab sequence number/*  w  ww  .  ja  va  2 s  .  c o m*/
 */
public int getSequenceNumber() {
    Entity declaringEntityRoot = getDeclaringEntityRoot();
    List<Tab> tabs = declaringEntityRoot == null ? null : declaringEntityRoot.getTabsList();
    return tabs == null || tabs.isEmpty() ? 0 : tabs.indexOf(this) + 1;
}

From source file:com.aw.swing.mvp.action.ActionResolver.java

public void disableAllActionsExcept(List actionsToBeExcluded) {
    for (Iterator iterator = actions.values().iterator(); iterator.hasNext();) {
        Action action = (Action) iterator.next();
        if (actionsToBeExcluded.indexOf(action) == -1) {
            action.setEnabled(false);/*from   w w w .  j a  va2s .  c o m*/
        }
    }
}

From source file:com.mobiaware.auction.provider.impl.CSVImportService.java

@Override
public void importItems(final int auctionUid, final Reader reader) throws IOException {
    CSVReader cvsreader = null;/*from  w w w. j av  a  2  s . c o  m*/
    try {
        cvsreader = new CSVReader(reader, CSVParser.DEFAULT_SEPARATOR, CSVParser.DEFAULT_QUOTE_CHARACTER,
                CSVParser.DEFAULT_ESCAPE_CHARACTER, 0, false, false);

        List<String> headers = Arrays.asList(cvsreader.readNext());

        String[] nextLine;
        while ((nextLine = cvsreader.readNext()) != null) {
            _dataService.editItem(Item.newBuilder().setAuctionUid(auctionUid)
                    .setItemNumber(nextLine[headers.indexOf("number")])
                    .setName(nextLine[headers.indexOf("name")])
                    .setDescription(nextLine[headers.indexOf("description")])
                    .setCategory(nextLine[headers.indexOf("category")])
                    .setSeller(nextLine[headers.indexOf("seller")])
                    .setValPrice(NumberUtils.toDouble(nextLine[headers.indexOf("value")]))
                    .setMinPrice(NumberUtils.toDouble(nextLine[headers.indexOf("minimum")]))
                    .setIncPrice(NumberUtils.toDouble(nextLine[headers.indexOf("increment")]))
                    .setUrl(nextLine[headers.indexOf("image")]).build());
        }
    } finally {
        IOUtils.closeQuietly(cvsreader);
    }
}

From source file:it.tidalwave.northernwind.frontend.ui.component.gallery.htmltemplate.bluette.BluetteGalleryAdapter.java

/*******************************************************************************************************************
 *
 * {@inheritDoc}// www. j  av a  2s.  c o m
 *
 ******************************************************************************************************************/
@Override
public void renderFallback(final @Nonnull GalleryView view, final @Nonnull Item item,
        final @Nonnull List<Item> items) {
    final TextHolder textHolder = (TextHolder) view;
    final int itemCount = items.size();
    final int index = items.indexOf(item);
    final Site site = siteProvider.get().getSite();
    final ResourcePath baseUrl = context.getSiteNode().getRelativeUri().prependedWith(site.getContextPath());
    final String redirectUrl = site
            .createLink(baseUrl.appendedWith("#!").appendedWith(item.getId().stringValue()))
            .replaceAll("/$", "");
    final String previousUrl = site.createLink(
            baseUrl.appendedWith(items.get((index - 1 + itemCount) % itemCount).getId().stringValue()));
    final String nextUrl = site
            .createLink(baseUrl.appendedWith(items.get((index + 1) % itemCount).getId().stringValue()));
    final String lightboxUrl = site.createLink(baseUrl.appendedWith("lightbox"));
    final String redirectScript = "<script type=\"text/javascript\">\n" + "//<![CDATA[\n"
            + "window.location.replace('" + redirectUrl + "');\n" + "//]]>\n" + "</script>\n";
    final ST t = new ST(fallbackTemplate, '$', '$').add("caption", item.getDescription())
            .add("previous", previousUrl).add("next", nextUrl).add("lightbox", lightboxUrl).add("home", "/blog") // FIXME
            .add("imageUrl", "/media/stillimages/800/" + item.getId().stringValue() + ".jpg")
            .add("copyright", copyright);
    textHolder.addAttribute("content", t.render());
    // FIXME: it would be better to change the properties rather than directly touch the template attributes
    textHolder.addAttribute("description", item.getDescription());
    textHolder.addAttribute("inlinedScripts", redirectScript);
    textHolder.addAttribute("scripts", "");
}

From source file:appInterface.AppFrame.java

/**
 * It chooses a random Module from all the modules
 * /*  ww  w  .  j  av  a2 s.  co m*/
 * @return the choosen Module
 */
public Module getRandomModule() {
    Random random = new Random();
    List<String> keys = new ArrayList<String>(modules.keySet());
    String randomKey = keys.get(random.nextInt(keys.size()));

    _mainToolBar.moduleComboBox.setSelectedIndex(keys.indexOf(randomKey));

    Module module = modules.get(randomKey);

    return module;
}

From source file:com.capgemini.b2bassets.cockpits.cmscockpit.session.impl.DefaultCmsPageBrowserModel.java

protected void processBrowserSectionModel(final ItemChangedEvent changedEvent, final TypedObject createdItem) {
    final BrowserSectionModel sectionModel = (BrowserSectionModel) changedEvent.getSource();
    final List<TypedObject> sectionItems = sectionModel.getItems();

    if (!CollectionUtils.isEmpty(sectionItems)) {
        final int itemIndex = sectionItems.indexOf(createdItem);
        if (itemIndex != -1) {
            sectionModel.update();//from   w  w w . ja  v  a2  s .co  m
            sectionModel.setSelectedIndex(itemIndex);

            getContentEditorSection().setRootItem(createdItem);
            getContentEditorSection().setVisible(true);
            getContentEditorSection().update();
        }
    }
}

From source file:hu.bme.mit.trainbenchmark.benchmark.orientdb.driver.OrientDbDriver.java

public List<Row> runQuery(final List<String> lines) throws IOException {
    OGremlinHelper.global().create();//w  ww  .  j av  a  2s . c  o  m
    final OCommandGremlin gremcomm = new OCommandGremlin();
    List<Row> result = new ArrayList<Row>();
    for (final String line : lines) {
        if (lines.indexOf(line) != lines.size() - 1) {
            gremcomm.setText(line).execute();
        } else {
            result = gremcomm.setText(line).execute();
        }
    }
    return result;
}

From source file:ch.oakmountain.tpa.solver.MacroscopicTopology.java

protected List<List<SystemNode>> getRoutes(List<List<SystemNode>> routes, SystemNode from, SystemNode to) {
    List<List<SystemNode>> routesFound = new LinkedList<List<SystemNode>>();
    for (List<SystemNode> route : routes) {
        int fromIndex = route.indexOf(from);
        int toIndex = route.indexOf(to);
        if (fromIndex >= 0 && toIndex >= 0 && toIndex > fromIndex) {
            routesFound.add(route.subList(fromIndex, toIndex + 1));
        }/*www.  j a  v a2 s .c om*/
    }
    return removeDuplicateRoutes(routesFound);
}