Example usage for java.util Vector elementAt

List of usage examples for java.util Vector elementAt

Introduction

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

Prototype

public synchronized E elementAt(int index) 

Source Link

Document

Returns the component at the specified index.

Usage

From source file:gov.nih.nci.evs.browser.utils.DataUtils.java

public static boolean containSource(Vector sources, String source) {
    if (sources == null || sources.size() == 0)
        return false;
    String s = null;/*  w w w  . jav a  2s  .  c  o  m*/
    for (int i = 0; i < sources.size(); i++) {
        s = (String) sources.elementAt(i);
        if (s.compareTo(source) == 0)
            return true;
    }
    return false;
}

From source file:gov.nih.nci.evs.browser.utils.DataUtils.java

protected static NameAndValueList createNameAndValueList(Vector names, Vector values) {
    if (names == null)
        return null;
    NameAndValueList nvList = new NameAndValueList();
    for (int i = 0; i < names.size(); i++) {
        String name = (String) names.elementAt(i);
        String value = (String) values.elementAt(i);
        NameAndValue nv = new NameAndValue();
        nv.setName(name);//from  w ww .  jav a 2 s.  com
        if (value != null) {
            nv.setContent(value);
        }
        nvList.addNameAndValue(nv);
    }
    return nvList;
}

From source file:gov.nih.nci.evs.browser.utils.DataUtils.java

public static BySourceTabResults findHighestRankedAtom(Vector<BySourceTabResults> v, String source) {
    if (v == null)
        return null;
    if (v.size() == 0)
        return null;
    if (v.size() == 1)
        return (BySourceTabResults) v.elementAt(0);

    BySourceTabResults target = null;//from w  w w.ja  va 2  s .  c om
    for (int i = 0; i < v.size(); i++) {
        BySourceTabResults r = (BySourceTabResults) v.elementAt(i);
        if (source != null) {
            if (r.getSource().compareTo(source) == 0) {
                if (target == null) {
                    target = r;
                } else {
                    // select the higher ranked one as target
                    String idx_target = NCImBrowserProperties.getRank(target.getType(), target.getSource());
                    String idx_atom = NCImBrowserProperties.getRank(r.getType(), r.getSource());
                    if (idx_atom != null && idx_atom.compareTo(idx_target) > 0) {
                        target = r;
                    }
                }
            }
        } else {
            return r;
        }
    }
    return target;
}

From source file:gov.nih.nci.evs.browser.utils.DataUtils.java

public static Vector<String> getSupportedPropertyNames(CodingScheme cs) {
    Vector w = getSupportedProperties(cs);
    if (w == null)
        return null;

    Vector<String> v = new Vector<String>();
    for (int i = 0; i < w.size(); i++) {
        SupportedProperty sp = (SupportedProperty) w.elementAt(i);
        v.add(sp.getLocalId());/*from w  w  w  .  j ava 2s. c o  m*/
    }
    return v;
}

From source file:gov.nih.nci.evs.browser.utils.DataUtils.java

public static Vector getMetadataValues(String scheme, String propertyName) {
    Vector v = new Vector();
    /*/*from w w w .  java  2  s . c o  m*/
     * if (formalName2MetadataHashMap == null) {
     * //formalName2MetadataHashMap = getFormalName2MetadataHashMap();
     * MetadataUtils.setSAB2FormalNameHashMap(); }
     */

    if (_formalName2MetadataHashMap == null) {
        //LexBIGService lbSvc = RemoteServerUtil.createLexBIGService();
        //NCImMetadataUtils util = new NCImMetadataUtils(lbSvc);
        _formalName2MetadataHashMap = NCImMetadataUtils.getFormalName2MetadataHashMap();

    }

    Vector metadataProperties = (Vector) _formalName2MetadataHashMap.get(scheme);
    if (metadataProperties != null) {
        for (int i = 0; i < metadataProperties.size(); i++) {
            String t = (String) metadataProperties.elementAt(i);
            Vector w = parseData(t, "|");
            String t1 = (String) w.elementAt(0);
            String t2 = (String) w.elementAt(1);
            if (t1.compareTo(propertyName) == 0)
                v.add(t2);
        }
    }
    return v;
}

From source file:gov.nih.nci.evs.browser.utils.SourceTreeUtils.java

public HashMap getSourceRoots(String CUI, String SAB) {
    HashSet hset = new HashSet();
    HashMap hmap = new HashMap();
    TreeItem ti = null;/*from w w w  .  ja  va 2  s . c  om*/
    Vector v = new Vector();
    String childNavText = "CHD";
    boolean hasMoreChildren = false;
    try {
        MetaBrowserService mbs = (MetaBrowserService) lbSvc.getGenericExtension("metabrowser-extension");
        MetaTree tree = mbs.getMetaNeighborhood(CUI, SAB);
        MetaTreeNode focus = tree.getCurrentFocus();
        ti = new TreeItem(focus.getCui(), focus.getName());
        if (isLeaf(focus)) {
            ti._expandable = false;
            hmap.put(ti._code, ti);
            return hmap;
        } else {
            ti._expandable = true;
        }

        Iterator iterator = focus.getChildren();
        if (iterator == null) {
            hmap.put(ti._code, ti);
            return hmap;
        }

        int knt = 0;
        hasMoreChildren = false;
        while (iterator.hasNext()) {
            MetaTreeNode child = (MetaTreeNode) iterator.next();
            if (!hset.contains(child.getCui())) {
                TreeItem childItem = new TreeItem(child.getCui(), child.getName());
                childItem._expandable = true;
                if (isLeaf(child)) {
                    childItem._expandable = false;
                }
                v.add(childItem);
                hset.add(child.getCui());
            }
        }
    } catch (Exception e) {

    }
    v = SortUtils.quickSort(v);
    for (int i = 0; i < v.size(); i++) {
        TreeItem childItem = (TreeItem) v.elementAt(i);
        ti.addChild(childNavText, childItem);
    }
    if (ti != null) {
        hmap.put(ti._code, ti);
    }
    return hmap;
}

From source file:de.juwimm.cms.remote.ViewServiceSpringImpl.java

/**
 * Get parents to a viewComponent unit, excluding the viewCcomponent, which has a unit.
 * /*from www .  j a  va 2 s .  co  m*/
 * @param viewComponent
 * @return String with path to this viewComponent
 */
private String getParents4View(ViewComponentHbm viewComponent) {
    try {
        if (viewComponent.getParent().isRoot()) {
            return "\\";
        }
    } catch (Exception ex) {
        return "\\";
    }
    Vector<ViewComponentHbm> vec = new Vector<ViewComponentHbm>();
    ViewComponentHbm parentView = viewComponent.getParent();

    while (parentView.getAssignedUnit() == null) {
        vec.addElement(parentView);
        parentView = parentView.getParent();
        try {
            if (parentView.isRoot()) {
                break;
            }
        } catch (Exception ex) {
            break;
        }
    }
    if (parentView.getAssignedUnit() != null) {
        vec.addElement(parentView);
    }
    StringBuffer sb = new StringBuffer("\\");

    for (int i = vec.size() - 1; i > -1; i--) {
        sb.append((vec.elementAt(i)).getUrlLinkName());
        if (i != 0) {
            sb.append("\\");
        }
    }
    sb.append("\\").append(viewComponent.getUrlLinkName());
    return sb.toString();
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.DataImportDialog.java

/**
 * Parses the given import file according to the users selection and creates/updates the Preview table,
 * showing the user how the import options effect the way the data will be imported into the spreadsheet.
 * @param table - the table to display the data
 * @return/*from   ww w  .j  a  v a 2 s. co  m*/
 * JTable - the table to display the data
 */
private JTable setCSVTableData(final JTable table) {
    try {
        log.debug("setTableData - file - " + configCSV.getFile().toString());
        CsvReader csv = new CsvReader(new FileInputStream(configCSV.getFile()), configCSV.getDelimiter(),
                configCSV.getCharset());
        csv.setEscapeMode(configCSV.getEscapeMode());
        csv.setTextQualifier(configCSV.getTextQualifier());

        String[] headers = {};
        Vector<String[]> tableDataVector = new Vector<String[]>();

        highestColumnCount = getLargestColumnCountFromCSV();

        if (configCSV.getFirstRowHasHeaders()) {
            csv.readHeaders();
            headers = csv.getHeaders();
        }

        int rowColumnCount = 0;
        while (csv.readRecord()) {
            //how many columns does this row of data contain
            rowColumnCount = csv.getColumnCount();
            //create an array that contains teh row data
            String[] rowData = new String[csv.getColumnCount()];
            for (int col = 0; col < csv.getColumnCount(); col++) {
                rowData[col] = csv.get(col);
            }
            //if the column count in this row of data is not as large
            //as the column header count, then "insert" blank string into the cells
            String[] newArray = padArray(highestColumnCount, rowData, false);
            //stick the row data into a vector because we do not know how many
            //rows of data there are
            tableDataVector.add(newArray);
        }

        if (!configCSV.getFirstRowHasHeaders() || headers == null) {
            //create headers with names Column1, Column2...
            headers = createDummyHeaders(rowColumnCount);
        }

        //if the header count is not as large as the longest column count in the data set
        //create dummy headers and append to end of table.
        headers = padArray(highestColumnCount, headers, true);

        log.debug("---------------------------------------------------");
        printArray(headers);
        log.debug("---------------------------------------------------");

        //pull row data out of vector and stick into an array for table model.
        String[][] tableData = new String[tableDataVector.size()][rowColumnCount];
        for (int i = 0; i < tableData.length; i++) {
            tableData[i] = tableDataVector.elementAt(i);
            printArray(tableData[i]);
        }

        if (checkForErrors(headers, tableData)) {
            errorPanel.showDataImportStatusPanel(true);
        } else {
            errorPanel.showDataImportStatusPanel(false);
        }

        if ((doesFirstRowHaveHeaders ? tableDataVector.size() - 1
                : tableDataVector.size()) > WorkbenchTask.MAX_ROWS) {
            hasTooManyRows = true;
            showTooManyRowsErrorDialog();
        } else {
            hasTooManyRows = false;
        }
        model = new PreviewTableModel(headers, tableData);
        table.setModel(model);
        table.setColumnSelectionAllowed(false);
        table.setRowSelectionAllowed(false);
        table.setCellSelectionEnabled(false);
        table.getTableHeader().setReorderingAllowed(false);
        table.setPreferredScrollableViewportSize(new Dimension(500, 100));
        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        table.setDefaultRenderer(String.class, new BiColorTableCellRenderer(false));

        model.fireTableDataChanged();
        model.fireTableStructureChanged();
        return table;

    } catch (IOException ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(DataImportDialog.class, ex);
        log.error("Error attempting to parse input csv file:" + ex);
    }
    return null;
}

From source file:gov.nih.nci.evs.browser.utils.DataUtils.java

public static Vector getSources(String scheme, String version, String tag, String code) {
    Vector sources = getSynonyms(scheme, version, tag, code);
    // GLIOBLASTOMA MULTIFORME|DI|DXP|U000721
    HashSet hset = new HashSet();
    Vector source_vec = new Vector();
    for (int i = 0; i < sources.size(); i++) {
        String s = (String) sources.elementAt(i);
        Vector ret_vec = parseData(s, "|");
        String name = (String) ret_vec.elementAt(0);
        String type = (String) ret_vec.elementAt(1);
        String src = (String) ret_vec.elementAt(2);
        String srccode = (String) ret_vec.elementAt(3);
        if (!hset.contains(src)) {
            hset.add(src);//from w w w. j av  a2s.  co  m
            source_vec.add(src);
        }
    }
    SortUtils.quickSort(source_vec);
    return source_vec;
}

From source file:gov.nih.nci.evs.browser.utils.DataUtils.java

public static String getMetadataValue(String scheme, String propertyName) {
    Vector v;
    try {/*from   w ww  . j  a v  a 2s .c  o m*/
        v = getMetadataValues(scheme, propertyName);
    } catch (Exception e) {
        _logger.error(e.getMessage());
        return null;
    }
    if (v == null || v.size() == 0)
        return null;
    return (String) v.elementAt(0);
}