Example usage for java.util Vector contains

List of usage examples for java.util Vector contains

Introduction

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

Prototype

public boolean contains(Object o) 

Source Link

Document

Returns true if this vector contains the specified element.

Usage

From source file:org.ecoinformatics.seek.ecogrid.EcoGridServicesController.java

/**
 * Filters out the non-query services given a list of EcoGridServices
 * //from w  w  w  .j av a2 s . c o  m
 * @param list
 *            of many different kinds of services
 * @return list of EcoGridService objects for querying
 */
public static Vector filterQueryServicesList(Vector inputServices) {
    Vector types = new Vector();
    types.add(AUTHENTICATEDQUERYSERVICETYPE);
    types.add(QUERYSERVICETYPE);

    Vector retList = new Vector();
    for (int i = 0; i < inputServices.size(); i++) {
        EcoGridService service = (EcoGridService) inputServices.get(i);
        if (types.contains(service.getServiceType())) {
            retList.add(service);
        }
    }
    return retList;
}

From source file:org.kepler.sms.SemanticTypeManager.java

/**
 * Remove a concept id from the given object.
 * /*from  w  ww.  j  a va 2 s . c om*/
 * @param obj
 *            the object to remove the concept from
 * @param concept
 *            the concept to remove
 */
public void removeType(Object obj, String concept) {
    if (!isObject(obj) || concept == null)
        return;
    Vector<Object> types = getTypes(obj);
    if (types.contains(concept))
        types.remove(concept);
}

From source file:org.kepler.sms.SemanticTypeManager.java

/**
 * Assign a concept id to the given object.
 * //  ww w  .  j  a  va2 s  .co m
 * @param obj
 *            the object to assign the concept to
 * @param concept
 *            the concept (class) to assign to the object
 */
public void addType(Object obj, Object concept) {
    if (!isObject(obj) || concept == null)
        return;
    Vector<Object> types = getTypes(obj);
    if (!types.contains(concept))
        types.add(concept);
}

From source file:de.xirp.ui.widgets.dialogs.ProfileLookupDialog.java

/**
 * Opens the dialog.//from   w  w  w . j  a  va 2 s .  c o  m
 * 
 * @return The chosen profile.
 * 
 * @see de.xirp.profile.Profile
 */
public Profile open() {
    dialogShell = new XShell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);

    dialogShell.addShellListener(new ShellAdapter() {

        /* (non-Javadoc)
         * @see org.eclipse.swt.events.ShellAdapter#shellClosed(org.eclipse.swt.events.ShellEvent)
         */
        @Override
        public void shellClosed(ShellEvent e) {
            SWTUtil.secureDispose(dialogShell);
        }
    });

    dialogShell.setSize(WIDTH, HEIGHT);
    dialogShell.setTextForLocaleKey("ProfileLookupDialog.gui.title"); //$NON-NLS-1$
    image = ImageManager.getSystemImage(SystemImage.QUESTION);
    dialogShell.setImage(image);

    SWTUtil.setGridLayout(dialogShell, 2, true);

    list = new XList(dialogShell, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);

    SWTUtil.setGridData(list, true, true, SWT.FILL, SWT.FILL, 2, 1);
    profiles = new ArrayList<Profile>(ProfileManager.getProfiles());
    profiles.addAll(ProfileManager.getIncompleteProfiles());

    for (Profile p : profiles) {
        Vector<String> itm = new Vector<String>();
        CollectionUtils.addAll(itm, list.getItems());
        if (!itm.contains(p)) {
            if (p.isComplete()) {
                list.add(p.getName() + I18n.getString("ProfileLookupDialog.list.postfix.complete")); //$NON-NLS-1$
            } else {
                list.add(p.getName() + I18n.getString("ProfileLookupDialog.list.postfix.incomplete")); //$NON-NLS-1$
            }
        }
    }
    list.addSelectionListener(new SelectionAdapter() {

        /* (non-Javadoc)
         * @see org.eclipse.swt.events.ShellAdapter#shellClosed(org.eclipse.swt.events.ShellEvent)
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (list.getSelectionCount() > 0) {
                ok.setEnabled(true);
            } else {
                ok.setEnabled(false);
            }
        }
    });

    ok = new XButton(dialogShell, XButtonType.OK);
    ok.setEnabled(false);
    SWTUtil.setGridData(ok, true, false, SWT.FILL, SWT.CENTER, 1, 1);
    ok.addSelectionListener(new SelectionAdapter() {

        /* (non-Javadoc)
         * @see org.eclipse.swt.events.ShellAdapter#shellClosed(org.eclipse.swt.events.ShellEvent)
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            int idx = list.getSelectionIndex();
            profile = profiles.get(idx);
            dialogShell.close();
        }
    });

    cancel = new XButton(dialogShell, XButtonType.CANCEL);
    SWTUtil.setGridData(cancel, true, false, SWT.FILL, SWT.CENTER, 1, 1);
    cancel.addSelectionListener(new SelectionAdapter() {

        /* (non-Javadoc)
         * @see org.eclipse.swt.events.ShellAdapter#shellClosed(org.eclipse.swt.events.ShellEvent)
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            dialogShell.close();
        }
    });

    dialogShell.setDefaultButton(ok);
    list.setSelectionWithEvent(0);

    dialogShell.layout();
    SWTUtil.centerDialog(dialogShell);
    dialogShell.open();

    SWTUtil.blockDialogFromReturning(dialogShell);

    return profile;
}

From source file:org.kepler.gui.OntLibrarySearcher.java

private void hashTablePut(String id, TreePath path) {
    if (!_hashTable.containsKey(id)) {
        Vector<TreePath> paths = new Vector<TreePath>();
        paths.add(path);/*ww  w.j av  a  2s. c om*/
        _hashTable.put(id, paths);
    } else {
        Vector<TreePath> paths = _hashTable.get(id);
        if (!paths.contains(path)) {
            paths.add(path);
        }
    }
}

From source file:org.scantegrity.openstv.m32ostv.java

/**
 * Creates a BLT File./*from w  w  w.  j  a va 2s.  co  m*/
 * @param p_contest the contest to use
 * @param p_ballots the ballot store
 * @throws IOException
 */
public static void createBLT(Contest p_contest, Vector<Ballot> p_ballots) throws IOException {
    System.out.println("Saving Contest" + p_contest.getId() + ".xml");

    Vector<Ballot> l_ballot = new Vector<Ballot>();

    //Pull out all the ballots which contain this contest
    for (Ballot l_b : p_ballots) {
        if (l_b.hasContest(p_contest.getId()))
            l_ballot.add(l_b);
    }

    //TODO: Should "clean" the ballots here.

    FileWriter l_file = new FileWriter("Contest" + p_contest.getId() + ".blt");
    BufferedWriter l_out = new BufferedWriter(l_file);
    BufferedWriter l_log = new BufferedWriter(new FileWriter("log.txt"));
    l_out.write(p_contest.getContestants().size() + " 1");
    l_out.newLine();

    for (Ballot l_b : l_ballot) {
        Integer[][] l_cData = l_b.getContestData(p_contest.getId());
        //System.out.println(java.util.Arrays.deepToString(l_cData));

        Vector<Integer> l_rankOrder = new Vector<Integer>();
        int l_skip = 0;
        for (int l_rank = 0; l_rank < l_cData[0].length; l_rank++) {
            int l_printCan = 0;
            for (int l_can = 0; l_can < l_cData.length; l_can++) {
                if (l_cData[l_can][l_rank] == 1) {
                    if (l_printCan != 0) {
                        l_log.write("Ballot " + l_b.getId() + ": " + "Overvote on Rank " + (l_rank + 1));
                        l_log.newLine();
                        System.out.println("Ballot " + l_b.getId() + ": " + "Overvote on Rank " + (l_rank + 1));
                        l_printCan = -1;
                    } else {
                        l_printCan = l_can + 1;
                    }
                }
            }
            if (l_printCan != 0) {
                l_skip = 0;
                if (l_printCan != -1) {
                    if (l_rankOrder.contains(l_printCan)) {
                        l_log.write("Ballot " + l_b.getId() + ": " + "Multipl candidates for same Rank");
                        l_log.newLine();
                        System.out
                                .println("Ballot " + l_b.getId() + ": " + "Multiple candidates for same Rank");

                    } else {
                        l_rankOrder.add(l_printCan);
                    }
                }
            } else {
                if (l_skip == 0)
                    l_skip++;
                else
                    break; //NOTE: This condition is typically NOT reported.
            }
        }
        //System.out.println(l_rankOrder.toString());
        //Print this ballot
        l_out.write("1 ");
        for (Integer l_j : l_rankOrder)
            l_out.write(l_j + " ");
        l_out.write("0");
        l_out.newLine();
    }

    l_out.write("0");
    l_out.newLine();

    for (Contestant l_cname : p_contest.getContestants()) {
        l_out.write("\"" + l_cname.getName() + "\"");
        l_out.newLine();
    }

    l_out.write("\"" + p_contest.getContestName() + "\"");
    l_out.newLine();

    l_out.close();
    l_log.close();
    //l_file.close();
}

From source file:de.xirp.ui.widgets.dialogs.CommSpecsLookupDialog.java

/**
 * Opens the dialog. The flag <code>multi</code> indicates the
 * selection mode. <code>true</code>: multi select allowed.
 * //from  w w  w . jav  a 2  s.com
 * @param multi
 *            <code>true</code>: multi select allowed.<br>
 *            <code>false</code>: single select allowed.
 * @return The selection result comm-spec-file file names.
 */
private List<String> open(boolean multi) {
    dialogShell = new XShell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);

    dialogShell.addShellListener(new ShellAdapter() {

        /**
         * @see org.eclipse.swt.events.ShellAdapter#shellClosed(org.eclipse.swt.events.ShellEvent)
         */
        @Override
        public void shellClosed(ShellEvent e) {
            SWTUtil.secureDispose(dialogShell);
        }
    });

    dialogShell.setSize(WIDTH, HEIGHT);
    if (multi) {
        dialogShell.setTextForLocaleKey("CommSpecsLookupDialog.gui.title.multi"); //$NON-NLS-1$
    } else {
        dialogShell.setTextForLocaleKey("CommSpecsLookupDialog.gui.title.single"); //$NON-NLS-1$
    }
    Image image = ImageManager.getSystemImage(SystemImage.QUESTION);
    dialogShell.setImage(image);

    SWTUtil.setGridLayout(dialogShell, 2, true);

    if (multi) {
        list = new XList(dialogShell, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    } else {
        list = new XList(dialogShell, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
    }
    SWTUtil.setGridData(list, true, true, SWT.FILL, SWT.FILL, 2, 1);

    File dir = new File(Constants.CONF_COMMSPECS_DIR);
    File[] cmsFiles = dir.listFiles(new FilenameFilter() {

        public boolean accept(File dir, String name) {
            return name.endsWith(Constants.COMM_SPEC_POSTFIX);
        }

    });

    for (File f : cmsFiles) {
        Vector<String> itm = new Vector<String>();
        CollectionUtils.addAll(itm, list.getItems());
        if (!itm.contains(f.getName())) {
            list.add(f.getName());
        }
    }
    list.addSelectionListener(new SelectionAdapter() {

        /**
         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (list.getSelectionCount() > 0) {
                ok.setEnabled(true);
            } else {
                ok.setEnabled(false);
            }
        }
    });

    ok = new XButton(dialogShell, XButtonType.OK);
    ok.setEnabled(false);
    SWTUtil.setGridData(ok, true, false, SWT.FILL, SWT.CENTER, 1, 1);
    ok.addSelectionListener(new SelectionAdapter() {

        /**
         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            commspecFileNames = Arrays.asList(list.getSelection());
            dialogShell.close();
        }
    });

    cancel = new XButton(dialogShell, XButtonType.CANCEL);
    SWTUtil.setGridData(cancel, true, false, SWT.FILL, SWT.CENTER, 1, 1);
    cancel.addSelectionListener(new SelectionAdapter() {

        /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.swt.events.ShellAdapter#shellClosed(org.eclipse.swt.events.ShellEvent)
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            commspecFileNames.clear();
            dialogShell.close();
        }
    });

    dialogShell.setDefaultButton(ok);
    list.setSelectionWithEvent(0);

    dialogShell.layout();
    SWTUtil.centerDialog(dialogShell);
    dialogShell.open();

    SWTUtil.blockDialogFromReturning(dialogShell);

    return Collections.unmodifiableList(commspecFileNames);
}

From source file:de.xirp.ui.widgets.dialogs.PluginLookupDialog.java

/**
 * Opens the class lookup dialog with the fully qualified class
 * names of the loaded plugins. Corresponding to the requested
 * type(s) or all types.//from  w w  w . j  a va  2 s. c o m
 * 
 * @return The chosen class name(s).
 */
public java.util.List<String> open() {
    dialogShell = new XShell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);

    dialogShell.addShellListener(new ShellAdapter() {

        /**
         * @see org.eclipse.swt.events.ShellAdapter#shellClosed(org.eclipse.swt.events.ShellEvent)
         */
        @Override
        public void shellClosed(ShellEvent e) {
            SWTUtil.secureDispose(dialogShell);
        }
    });

    dialogShell.setSize(WIDTH, HEIGHT);
    dialogShell.setTextForLocaleKey("ClassLookupDialog.gui.dialogTitle.chooseClass"); //$NON-NLS-1$
    image = ImageManager.getSystemImage(SystemImage.QUESTION);
    dialogShell.setImage(image);

    SWTUtil.setGridLayout(dialogShell, 2, true);

    if (multi) {
        list = new XList(dialogShell, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    } else {
        list = new XList(dialogShell, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
    }
    SWTUtil.setGridData(list, true, true, SWT.FILL, SWT.FILL, 2, 1);
    for (String s : pluginNameLookup()) {
        Vector<String> itm = new Vector<String>();
        CollectionUtils.addAll(itm, list.getItems());
        if (!itm.contains(s)) {
            list.add(s);
        }
    }
    list.addSelectionListener(new SelectionAdapter() {

        /**
         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (list.getSelectionCount() > 0) {
                ok.setEnabled(true);
            } else {
                ok.setEnabled(false);
            }
        }
    });

    ok = new XButton(dialogShell, XButtonType.OK);
    ok.setEnabled(false);
    SWTUtil.setGridData(ok, true, false, SWT.FILL, SWT.CENTER, 1, 1);
    ok.addSelectionListener(new SelectionAdapter() {

        /**
         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            CollectionUtils.addAll(classes, list.getSelection());
            dialogShell.close();
        }
    });

    cancel = new XButton(dialogShell, XButtonType.CANCEL);
    SWTUtil.setGridData(cancel, true, false, SWT.FILL, SWT.CENTER, 1, 1);
    cancel.addSelectionListener(new SelectionAdapter() {

        /**
         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            dialogShell.close();
        }
    });

    dialogShell.setDefaultButton(ok);

    dialogShell.layout();
    SWTUtil.centerDialog(dialogShell);
    dialogShell.open();

    SWTUtil.blockDialogFromReturning(dialogShell);

    return Collections.unmodifiableList(classes);
}

From source file:de.xirp.ui.widgets.dialogs.RobotLookupDialog.java

/**
 * Opens the dialog. The flag <code>multi</code> indicates the
 * selection mode. <code>true</code>: multi select allowed.
 * // w ww . j  av  a 2 s  .c  o m
 * @param multi
 *            <code>true</code>: multi select allowed.<br>
 *            <code>false</code>: single select allowed.
 * @return The selection result robot-file file names.
 */
private List<String> open(boolean multi) {
    dialogShell = new XShell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);

    dialogShell.addShellListener(new ShellAdapter() {

        /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.swt.events.ShellAdapter#shellClosed(org.eclipse.swt.events.ShellEvent)
         */
        @Override
        public void shellClosed(ShellEvent e) {
            SWTUtil.secureDispose(dialogShell);
        }
    });

    dialogShell.setSize(WIDTH, HEIGHT);
    if (multi) {
        dialogShell.setTextForLocaleKey("RobotLookupDialog.gui.title.multi"); //$NON-NLS-1$
    } else {
        dialogShell.setTextForLocaleKey("RobotLookupDialog.gui.title.single"); //$NON-NLS-1$
    }
    Image image = ImageManager.getSystemImage(SystemImage.QUESTION);// /$NON-NLS-1$
    dialogShell.setImage(image);

    SWTUtil.setGridLayout(dialogShell, 2, true);

    if (multi) {
        list = new XList(dialogShell, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    } else {
        list = new XList(dialogShell, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
    }
    SWTUtil.setGridData(list, true, true, SWT.FILL, SWT.FILL, 2, 1);

    File dir = new File(Constants.CONF_ROBOTS_DIR);
    File[] robotFiles = dir.listFiles(new FilenameFilter() {

        public boolean accept(File dir, String name) {
            return name.endsWith(Constants.ROBOT_POSTFIX);
        }

    });

    for (File f : robotFiles) {
        Vector<String> itm = new Vector<String>();
        CollectionUtils.addAll(itm, list.getItems());
        if (!itm.contains(f.getName())) {
            list.add(f.getName());
        }
    }
    list.addSelectionListener(new SelectionAdapter() {

        /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.swt.events.ShellAdapter#shellClosed(org.eclipse.swt.events.ShellEvent)
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (list.getSelectionCount() > 0) {
                ok.setEnabled(true);
            } else {
                ok.setEnabled(false);
            }
        }
    });

    ok = new XButton(dialogShell, XButtonType.OK);
    ok.setEnabled(false);
    SWTUtil.setGridData(ok, true, false, SWT.FILL, SWT.CENTER, 1, 1);
    ok.addSelectionListener(new SelectionAdapter() {

        /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.swt.events.ShellAdapter#shellClosed(org.eclipse.swt.events.ShellEvent)
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            robotFileNames = Arrays.asList(list.getSelection());
            dialogShell.close();
        }
    });

    cancel = new XButton(dialogShell, XButtonType.CANCEL);
    SWTUtil.setGridData(cancel, true, false, SWT.FILL, SWT.CENTER, 1, 1);
    cancel.addSelectionListener(new SelectionAdapter() {

        /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.swt.events.ShellAdapter#shellClosed(org.eclipse.swt.events.ShellEvent)
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            robotFileNames.clear();
            dialogShell.close();
        }
    });

    dialogShell.setDefaultButton(ok);
    list.setSelectionWithEvent(0);

    dialogShell.layout();
    SWTUtil.centerDialog(dialogShell);
    dialogShell.open();

    SWTUtil.blockDialogFromReturning(dialogShell);

    return Collections.unmodifiableList(robotFileNames);
}

From source file:de.escidoc.core.test.om.container.ContainerReferenceIT.java

/**
 * Check the references of an Container for the REST representation.
 *
 * @param containerXml The XML of the Container.
 * @throws Exception Thrown if retrieve or ID extracting failed.
 *///from www  .  j  a va 2  s . c o  m
private void checkRestReferences(final String containerXml) throws Exception {

    Document containerDoc = EscidocAbstractTest.getDocument(containerXml);

    NodeList hrefs = selectNodeList(containerDoc, "//@href");
    List<String> refList = nodeList2List(hrefs);

    // retrieve each single ref from framework
    // prevent duplicate href checking
    Vector<String> checkedRefs = new Vector<String>();

    Iterator<String> refIt = refList.iterator();

    while (refIt.hasNext()) {
        String ref = refIt.next();

        if (!checkedRefs.contains(ref) && !skipRefCheck(ref)) {
            call(ref);
            checkedRefs.add(ref);
        }
    }
}