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:architecture.ee.web.community.tag.DefaultTagManager.java

@Override
public void removeTag(ContentTag tag, int objectType, long objectId) throws UnAuthorizedException {
    if (objectType < 0 || objectId < 0L)
        throw new IllegalStateException();
    synchronized (getLock(objectType, objectId)) {
        List<Long> tags = getTagIds(objectType, objectId);
        int index = tags.indexOf(Long.valueOf(tag.getTagId()));
        if (index >= 0) {
            tags.remove(index);// ww  w  .ja v a 2  s  .  co  m
            tagContentCache.put(new Element(getCacheKey(objectType, objectId), tags));
        } else {
            throw new IllegalArgumentException("Tag is not associated with this object");
        }
    }

    // fire event..
    removeTagFromDb(tag, objectType, objectId);
}

From source file:architecture.ee.web.community.tag.DefaultTagManager.java

@Override
public void removeAllTags(int objectType, long objectId) throws UnAuthorizedException {
    if (objectType < 0 || objectId < 0L)
        throw new IllegalStateException();
    synchronized (getLock(objectType, objectId)) {
        List<ContentTag> contentTags = new ImmutableList.Builder<ContentTag>()
                .addAll(getTags(objectType, objectId)).build();
        for (ContentTag tag : contentTags) {
            List<Long> tags = getTagIds(objectType, objectId);
            int index = tags.indexOf(Long.valueOf(tag.getTagId()));
            if (index >= 0)
                tags.remove(index);/*w ww. j a v  a2  s. com*/
            else
                throw new IllegalArgumentException("Tag is not associated with this object");
        }
        tagContentCache.remove(getCacheKey(objectType, objectId));
    }
}

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

protected void processSectionItems(final ItemChangedEvent changedEvent, final BrowserSectionModel sectionModel,
        final List<TypedObject> sectionItems) {
    if (!CollectionUtils.isEmpty(sectionItems) && sectionItems.contains(changedEvent.getItem())) {
        final int removedIndex = sectionItems.indexOf(changedEvent.getItem());
        if (sectionModel.getSelectedIndex() != null) {
            if (removedIndex < sectionModel.getSelectedIndex().intValue()) {
                sectionModel.setSelectedIndex(sectionModel.getSelectedIndex().intValue() - 1);
            } else if (removedIndex == sectionModel.getSelectedIndex().intValue()) {
                sectionModel.setSelectedIndexes(Collections.emptyList());
            }/*from   w  w w . jav  a2 s.c o  m*/
        }
        removeComponentFromSlot((TypedObject) sectionModel.getRootItem(), changedEvent.getItem());
        sectionModel.update();
    }
}

From source file:de.thischwa.pmcms.gui.treeview.SiteTreeContextMenuManager.java

private void buildForOrderable(IOrderable<?> orderable) {
    @SuppressWarnings("unchecked")
    List<IOrderable<?>> family = (List<IOrderable<?>>) orderable.getFamily();
    int pos = family.indexOf(orderable);
    logger.debug("Generate context menu for TYPE IOrderables."); //$NON-NLS-1$
    if (OrderableInfo.hasPrevious(orderable) || OrderableInfo.hasNext(orderable))
        new MenuItem(menu, SWT.SEPARATOR);
    if (OrderableInfo.hasPrevious(orderable)) {
        MenuItem menuItemMoveUp = new MenuItem(menu, SWT.PUSH);
        menuItemMoveUp.setText(LabelHolder.get("treecontextmenu.moveup")); //$NON-NLS-1$
        menuItemMoveUp.addSelectionListener(new ListenerMoveOrderabelToPosition(orderable, pos - 1));
    }/*from w  ww .ja  va  2  s  .  c om*/
    int sisterCount = orderable.getFamily().size();
    if (sisterCount > 3) {
        Menu menuMoveTo = new Menu(menu);
        MenuItem menuItemSubPos = new MenuItem(menu, SWT.CASCADE);
        menuItemSubPos.setMenu(menuMoveTo);
        menuItemSubPos.setText(LabelHolder.get("treecontextmenu.moveto")); //$NON-NLS-1$
        for (int i = 0; i < sisterCount; i++) {
            if (i != pos) {
                MenuItem menuItemMoveToPos = new MenuItem(menuMoveTo, SWT.PUSH);
                menuItemMoveToPos.setText(String.valueOf(i));
                menuItemMoveToPos.addSelectionListener(new ListenerMoveOrderabelToPosition(orderable, i));
            }
        }
    }
    if (OrderableInfo.hasNext(orderable)) {
        MenuItem menuItemMoveDown = new MenuItem(menu, SWT.PUSH);
        menuItemMoveDown.setText(LabelHolder.get("treecontextmenu.movedown")); //$NON-NLS-1$
        menuItemMoveDown.addSelectionListener(new ListenerMoveOrderabelToPosition(orderable, pos + 1));
    }
}

From source file:com.eryansky.modules.disk.service.FileShareManager.java

/**
 * ??/*from   ww  w.ja  va2  s. c  o  m*/
 * 
 * @param pageId
 *            Id
 * @param userId
 *            Id
 * @param nodeType
 *            
 * @param nodeId
 *            Id
 */
public void removeReceive(String pageId, String userId, String nodeType, Integer nodeId) {
    Validate.notNull(pageId, "?[pageId]?null.");
    if (NType.FolderAuthorize.toString().equals(nodeType)
            && FolderAuthorize.ReceivePerson.getValue().equals(nodeId)) {// ,?Id
        FileShare fileShare = getById(pageId);
        List<String> sharedUserList = fileShare.getSharedUserList();
        if (Collections3.isNotEmpty(sharedUserList)) {
            int index = sharedUserList.indexOf(userId);
            if (index > -1) {
                sharedUserList.remove(index);
            }
        }
        saveOrUpdate(fileShare);
    } else {//  ,?Id
        FileShare fileShare = this.findUniqueShareByFileId(pageId);
        if (fileShare != null) {
            fileShare.getSharedFileList().remove(pageId);
            saveOrUpdate(fileShare);
            fileManager.deleteFile(pageId);
        }
    }

}

From source file:hydrograph.server.execution.tracking.client.main.HydrographMain.java

/**
 * Gets the tracking socket port number.
 *
 * @param argumentList//from  w  w  w  .j a va2  s  .  c o  m
 *            the argument list
 * @return the job id
 */
private String getTrackingClientSocketPort(List<String> argumentList) {
    if (argumentList.contains(Constants.TRACKING_CLIENT_SOCKET_PORT)) {
        return argumentList.get(argumentList.indexOf(Constants.TRACKING_CLIENT_SOCKET_PORT) + 1);
    }
    return null;
}

From source file:com.blackducksoftware.integration.hub.cli.SimpleScanService.java

/**
 * Code to mask passwords in the logs// w  w w .j  ava 2 s  . c om
 */
private void printCommand(final List<String> cmd) {
    final List<String> cmdToOutput = new ArrayList<>();
    cmdToOutput.addAll(cmd);

    int passwordIndex = cmdToOutput.indexOf("--password");
    if (passwordIndex > -1) {
        // The User's password will be at the next index
        passwordIndex++;
    }

    int proxyPasswordIndex = -1;
    for (int commandIndex = 0; commandIndex < cmdToOutput.size(); commandIndex++) {
        String commandParameter = cmdToOutput.get(commandIndex);
        if (commandParameter.contains("-Dhttp.proxyPassword=")) {
            proxyPasswordIndex = commandIndex;
        }
    }

    maskIndex(cmdToOutput, passwordIndex);
    maskIndex(cmdToOutput, proxyPasswordIndex);

    logger.info("Hub CLI command :");
    for (final String current : cmdToOutput) {
        logger.info(current);
    }
}

From source file:Login.java

private void btnLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoginActionPerformed
    DataAccess da = new DataAccess();
    String uname = un.getText();//w  w w.jav a  2 s  .  c o  m
    String pass = pa.getText();

    if (uname.equals("admin") && pass.equals("admin")) {
        this.setVisible(false);
        new AdminMaster().setVisible(true);
    } else {

        Bank bank = new Bank();
        bank.setUsername(uname);
        bank.setPassword(pass);

        ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
        DataAccessTemplate dat = (DataAccessTemplate) context.getBean("bankJDBCTemplate");

        List<Bank> lst = dat.login(bank);
        if (lst.isEmpty()) {
            JOptionPane.showMessageDialog(null, "Invalid Credentials! OR Admin has blocked You!");
        } else {
            JOptionPane.showMessageDialog(null, "Login Successful!");
            int a = lst.indexOf(bank);
            for (Bank b : lst) {
                bank.setUid(b.getUid());
                bank.setAccount_number(b.getAccount_number());
                bank.setBalance(b.getBalance());
            }
            this.setVisible(false);
            Dashboard db = new Dashboard(bank);
            db.setVisible(true);
        }
    }

}

From source file:de.tsystems.mms.apm.performancesignature.viewer.rest.JenkinsServerConnection.java

public boolean downloadPDFReports(final int buildNumber, final FilePath dir, final PrintStream logger) {
    boolean result = true;
    try {//from  w ww.ja  v  a  2 s . co  m
        for (ReportType reportType : ReportType.values()) {
            List reportlist = getReportList(reportType, buildNumber);
            for (Object report : reportlist) {
                URL url = new URL(getJenkinsJob().getUrl() + buildNumber + "/performance-signature/get"
                        + reportType + "Report?number=" + reportlist.indexOf(report));
                result &= downloadArtifact(new FilePath(dir, report + ".pdf"), url, logger);
            }
        }
        return result;
    } catch (IOException e) {
        throw new CommandExecutionException("error downloading PDF Reports: " + e.getMessage(), e);
    }
}

From source file:com.opengamma.master.region.impl.RegionFileReader.java

/**
 * Parses the specified file to populate the master.
 * //  ww w .  j a va 2s .  co  m
 * @param in  the input reader to read, not closed, not null
 */
public void parse(Reader in) {
    String name = null;
    try {
        Map<String, ManageableRegion> regions = new HashMap<String, ManageableRegion>();
        Map<UniqueId, Set<String>> subRegions = new HashMap<UniqueId, Set<String>>();

        // open CSV file
        @SuppressWarnings("resource")
        CSVReader reader = new CSVReader(in);
        List<String> columns = Arrays.asList(reader.readNext());

        // identify columns
        final int nameColumnIdx = columns.indexOf(NAME_COLUMN);
        final int formalNameColumnIdx = columns.indexOf(FORMAL_NAME_COLUMN);
        final int classificationColumnIdx = columns.indexOf(CLASSIFICATION_COLUMN);
        final int sovereignityColumnIdx = columns.indexOf(SOVEREIGNITY_COLUMN);
        final int countryColumnIdx = columns.indexOf(ISO_COUNTRY_2_COLUMN);
        final int currencyColumnIdx = columns.indexOf(ISO_CURRENCY_3_COLUMN);
        final int subRegionsColumnIdx = columns.indexOf(SUB_REGIONS_COLUMN);

        // parse
        String[] row = null;
        while ((row = reader.readNext()) != null) {
            name = row[nameColumnIdx].trim(); // the primary key
            String fullName = StringUtils.trimToNull(row[formalNameColumnIdx]);
            if (fullName == null) {
                fullName = name;
            }
            RegionClassification classification = RegionClassification
                    .valueOf(row[classificationColumnIdx].trim());
            String sovereignity = StringUtils.trimToNull(row[sovereignityColumnIdx]);
            String countryISO = StringUtils.trimToNull(row[countryColumnIdx]);
            String currencyISO = StringUtils.trimToNull(row[currencyColumnIdx]);
            Set<String> rowSubRegions = new HashSet<String>(Arrays.asList(row[subRegionsColumnIdx].split(";")));
            rowSubRegions = trim(rowSubRegions);

            ManageableRegion region = new ManageableRegion();
            region.setClassification(classification);
            region.setName(name);
            region.setFullName(fullName);
            if (countryISO != null) {
                region.setCountry(Country.of(countryISO));
                region.addExternalId(ExternalSchemes.financialRegionId(countryISO)); // TODO: looks odd
            }
            if (currencyISO != null) {
                region.setCurrency(Currency.of(currencyISO));
            }
            if (sovereignity != null) {
                ManageableRegion parent = regions.get(sovereignity);
                if (parent == null) {
                    throw new OpenGammaRuntimeException(
                            "Cannot find parent '" + sovereignity + "'  for '" + name + "'");
                }
                region.getParentRegionIds().add(parent.getUniqueId());
            }
            for (Entry<UniqueId, Set<String>> entry : subRegions.entrySet()) {
                if (entry.getValue().remove(name)) {
                    region.getParentRegionIds().add(entry.getKey());
                }
            }

            // store
            RegionDocument doc = getRegionMaster().add(new RegionDocument(region));
            if (rowSubRegions.size() > 0) {
                subRegions.put(doc.getUniqueId(), rowSubRegions);
            }
            regions.put(name, region);
        }
        for (Set<String> set : subRegions.values()) {
            if (set.size() > 0) {
                throw new OpenGammaRuntimeException("Cannot find children: " + set);
            }
        }

    } catch (Exception ex) {
        String detail = (name != null ? " while processing " + name : "");
        throw new OpenGammaRuntimeException("Cannot open region data file (or file I/O problem)" + detail, ex);
    }
}