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:edu.ku.brc.af.core.expresssearch.QueryForIdResultsSQL.java

public String getSQL(final String searchTermArg, final Vector<Integer> ids) {
    if (StringUtils.isNotEmpty(overrideSQL)) {
        return overrideSQL;
    }/*from  w  w  w. jav  a2s.  co m*/

    Vector<Integer> tempIds = ids == null ? recIds : ids;
    // else
    StringBuilder idsStr = new StringBuilder(recIds.size() * 8);
    for (int i = 0; i < tempIds.size(); i++) {
        if (i > 0)
            idsStr.append(',');
        idsStr.append(tempIds.elementAt(i).toString());
    }

    String sqlStr;
    if (getJoinColTableId() != null) {
        String joinIdName = null;
        for (ERTIJoinColInfo jci : tableInfo.getJoins()) {
            if (joinColTableId == jci.getJoinTableIdAsInt()) {
                joinIdName = jci.getColName();
            }
        }

        String critiera = (tableInfo.isFieldNameOnlyForSQL() ? StringUtils.substringAfterLast(joinIdName, ".") //$NON-NLS-1$
                : joinIdName) + " in (" + idsStr.toString() + ")"; //$NON-NLS-1$ //$NON-NLS-2$

        //System.out.println("["+critiera+"]");
        sqlStr = String.format(tableInfo.getViewSql(), new Object[] { joinIdName, critiera });
        //System.out.println("["+sqlStr+"]");
        sqlStr = QueryAdjusterForDomain.getInstance().adjustSQL(sqlStr);

    } else {
        String vsql = getTableInfo().getViewSql();
        sqlStr = idsStr.length() > 0 ? vsql.replace("%s", idsStr.toString()) : vsql; //$NON-NLS-1$
    }
    return sqlStr;
}

From source file:com.dimdim.conference.application.portal.PortalServerAdapter.java

public boolean timerCall() {
    Vector v = null;
    synchronized (this) {
        if (this.urlQueue != null && this.urlQueue.size() > 0) {
            v = this.urlQueue;
            this.urlQueue = new Vector();
        }//from ww  w. ja  v  a 2 s  .  c o m
    }
    if (v != null) {
        int num = v.size();
        for (int i = 0; i < num; i++) {
            String url = (String) v.elementAt(i);
            this.getURL_String(this.httpClient, url);
        }
    }
    return true;
}

From source file:FileTree3.java

public boolean expand(DefaultMutableTreeNode parent) {
    DefaultMutableTreeNode flag = (DefaultMutableTreeNode) parent.getFirstChild();
    if (flag == null) // No flag
        return false;
    Object obj = flag.getUserObject();
    if (!(obj instanceof Boolean))
        return false; // Already expanded

    parent.removeAllChildren(); // Remove Flag

    File[] files = listFiles();//ww  w.  ja v  a2 s.c  o m
    if (files == null)
        return true;

    Vector v = new Vector();

    for (int k = 0; k < files.length; k++) {
        File f = files[k];
        if (!(f.isDirectory()))
            continue;

        FileNode newNode = new FileNode(f);

        boolean isAdded = false;
        for (int i = 0; i < v.size(); i++) {
            FileNode nd = (FileNode) v.elementAt(i);
            if (newNode.compareTo(nd) < 0) {
                v.insertElementAt(newNode, i);
                isAdded = true;
                break;
            }
        }
        if (!isAdded)
            v.addElement(newNode);
    }

    for (int i = 0; i < v.size(); i++) {
        FileNode nd = (FileNode) v.elementAt(i);
        IconData idata = new IconData(FileTree3.ICON_FOLDER, FileTree3.ICON_EXPANDEDFOLDER, nd);
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(idata);
        parent.add(node);

        if (nd.hasSubDirs())
            node.add(new DefaultMutableTreeNode(new Boolean(true)));
    }

    return true;
}

From source file:org.esupportail.portal.ws.groups.PortalGroups.java

/**
 * Recupere recursivement les groupes contenant un groupe donne, jusque la racine
 * @param igm un groupe sous la forme IGroupMember
 * @param allGroups vecteur contenant la liste de tous les groupes de l'utilisateur donne. Il peut etre agrandi au cours de la recursivite au cas ou un groupe est rattache a plusieurs groupes en meme temps
 * @param v le vecteur a remplir a chaque etape de la recursivite
 * @throws GroupsException/*from  w  w w. j a v  a2 s  . co  m*/
 */
private void getRecurContainingGroups(IGroupMember igm, Vector allGroups, Vector v) throws GroupsException {

    // recupere les groupes contenant le groupe passe en parametre
    Iterator iter = igm.getContainingGroups();

    // pour savoir combien on a d'elements, on recopie cette iteration dans un vecteur
    Vector containingGroups = new Vector();
    while (iter.hasNext()) {
        containingGroups.addElement(iter.next());
    }

    // pour chacun, on l'ajoute dans la liste
    for (int i = 0; i < containingGroups.size(); i++) {

        // on recupere le groupe courant dans l'iteration      
        IEntityGroup egi = (IEntityGroup) containingGroups.elementAt(i);

        // clone du vecteur passe en parametre, ou le vecteur lui meme
        Vector v2 = null;
        if (i == containingGroups.size() - 1) {
            v2 = v;
        } else {
            v2 = (Vector) v.clone();
            //System.out.println(v2+" clone de "+v);
        }

        // on ajoute la clef de ce groupe
        v2.add(0, egi.getKey());
        //System.out.println("Add "+egi.getName());

        // appel a la recursivite
        getRecurContainingGroups(egi, allGroups, v2);

        // on ajoute cette hierarchie a tous les groupes
        if (i < containingGroups.size() - 1) {
            allGroups.addElement(v2);
            //System.out.println("AddAll "+v2);
        }
    }

}

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

public String getFocusCode(String ontology_node_id) {
    if (ontology_node_id == null)
        return null;
    if (ontology_node_id.indexOf("_dot_") == -1) {
        return ontology_node_id;
    }/*from www .  j av  a 2 s .c  o m*/
    Vector v = parseData(ontology_node_id, "_");
    for (int i = 0; i < v.size(); i++) {
        String t = (String) v.elementAt(i);
    }
    if (v.contains("root")) {
        return restoreNodeID((String) v.elementAt(1));
    }
    return restoreNodeID((String) v.elementAt(0));
}

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

private void initRowHeight(Vector factorList) {
    if (factorList != null) {
        int rowNumber = table.getRowCount();
        int listSize = factorList.size();
        if (rowNumber <= 0) {
            table.setRowHeight(CELLHEIGHT);
        } // if//from w ww.  j  av a 2  s  .  c o m
        else {
            for (int i = 0; i < rowNumber; i++) {
                if (i < listSize) {
                    int factor = ((Integer) factorList.elementAt(i)).intValue();
                    log.debug("The factor for row " + i + " is " + factor);
                    table.setRowHeight(i, factor * CELLHEIGHT);
                } else {
                    table.setRowHeight(i, CELLHEIGHT);
                }
            } // for
        } // else
    } // if
    else {
        table.setRowHeight(CELLHEIGHT);
    } //
}

From source file:dao.DirectoryListAuthorQuery.java

/** 
  * This method lists all the authors for a directory
  * @param conn the connection/*from w w w . ja  v a2 s .  c om*/
  * @param directoryId the directory id
  * @return HashSet the set that has the list of authors for this directory.
  * @throws BaseDaoException
  * @author Smitha Gudur (smitha@redbasin.com)
  * @version $Revision: 1.1 $
  */

/* Uses tables - directory, diradmin, hdlogin  */
public HashSet run(Connection conn, String directoryid) throws BaseDaoException {

    String sqlQuery = "select distinct CONCAT(hd.fname,' ',hd.lname) AS membername, "
            + "hd.login, hd.loginid, d1.directoryid, d1.dirname from directory d1, "
            + "diradmin d2, hdlogin hd where d2.ownerid=hd.loginid "
            + "and d1.directoryid=d2.directoryid and d1.directoryid=" + directoryid + " order by hd.login ASC";
    logger.info("sqlQuery = " + sqlQuery);
    try {
        PreparedStatement stmt = conn.prepareStatement(sqlQuery);
        ResultSet rs = stmt.executeQuery();
        Vector columnNames = null;
        Directory directory = null;
        HashSet dirSet = new HashSet();

        if (rs != null) {
            // get column names and types from rsmd and save to local array in object
            //DbUtils dbutils = new DbUtils();
            columnNames = dbutils.getColumnNames(rs);
        } else {
            return null;
        }

        while (rs.next()) {
            directory = (Directory) eop.newObject(DbConstants.DIRECTORY);
            for (int j = 0; j < columnNames.size(); j++) {
                directory.setValue((String) columnNames.elementAt(j),
                        (String) rs.getString((String) columnNames.elementAt(j)));
            }
            dirSet.add(directory);
        }
        return dirSet;
    } catch (Exception e) {
        throw new BaseDaoException(
                "Error occured while executing directory moderatorslist run query " + sqlQuery, e);
    }
}

From source file:org.glite.slcs.pki.bouncycastle.X509PrincipalUtil.java

/**
 * Builds a {@link X509Principal}, based on the given vectors.
 * /*from w  w  w .  jav  a  2 s.  co m*/
 * @param ordering
 * @param values
 * @param added
 * @return the {@link X509Principal} or <code>null</code> if an error
 *         occurs.
 * @throws IOException
 *             if a DER encoding error occurs.
 */
private X509Principal buildX509Principal(Vector<DERObjectIdentifier> ordering, Vector<Object> values,
        Vector<Boolean> added) throws IOException {
    X509NameEntryConverter converter = new X509DefaultEntryConverter();
    ASN1EncodableVector vec = new ASN1EncodableVector();
    ASN1EncodableVector sVec = new ASN1EncodableVector();
    DERObjectIdentifier lstOid = null;
    // Bouncycastle's code
    for (int i = 0; i != ordering.size(); i++) {
        ASN1EncodableVector v = new ASN1EncodableVector();
        DERObjectIdentifier oid = ordering.elementAt(i);
        v.add(oid);
        String str = (String) values.elementAt(i);
        v.add(converter.getConvertedValue(oid, str));
        if (lstOid == null || added.elementAt(i)) {
            sVec.add(new DERSequence(v));
        } else {
            vec.add(new DERSet(sVec));
            sVec = new ASN1EncodableVector();
            sVec.add(new DERSequence(v));
        }

        lstOid = oid;
    }
    vec.add(new DERSet(sVec));
    DERSequence seq = new DERSequence(vec);
    byte[] bytes = seq.getDEREncoded();
    return new X509Principal(bytes);
}

From source file:org.apache.axis.client.AdminClient.java

/**
 * submit the input stream's contents to the endpoint, return the results as a string.
 * The input stream is always closed after the call, whether the request worked or not
 * @param opts options -can be null/*from  w w w  . j  a  v a  2  s.c  o  m*/
 * @param input -input stream for request
 * @return
 * @throws Exception if the call was null
 * @throws AxisFault if the invocation returned an empty response
 */
public String process(Options opts, InputStream input) throws Exception {
    try {
        if (call == null) {
            //validate that the call is not null
            throw new Exception(Messages.getMessage("nullCall00"));
        }

        if (opts != null) {
            //process options if supplied
            processOpts(opts);
        }

        call.setUseSOAPAction(true);
        call.setSOAPActionURI("urn:AdminService");

        Vector result = null;
        Object[] params = new Object[] { new SOAPBodyElement(input) };
        result = (Vector) call.invoke(params);

        if (result == null || result.isEmpty()) {
            throw new AxisFault(Messages.getMessage("nullResponse00"));
        }

        SOAPBodyElement body = (SOAPBodyElement) result.elementAt(0);
        return body.toString();
    } finally {
        input.close();
    }
}

From source file:net.nosleep.superanalyzer.analysis.views.GrowthView.java

private void refreshDataset() {
    TimeSeries series1 = new TimeSeries(Misc.getString("SONGS_IN_LIBRARY"));

    Hashtable addedHash = null;//from   www .  j a va2 s.c  o  m

    if (_comboBox == null) {
        addedHash = _analysis.getDatesAdded(Analysis.KIND_TRACK, null);
    } else {
        ComboItem item = (ComboItem) _comboBox.getSelectedItem();
        addedHash = _analysis.getDatesAdded(item.getKind(), item.getValue());
    }

    Vector items = new Vector();

    Enumeration e = addedHash.keys();
    while (e.hasMoreElements()) {

        Day day = (Day) e.nextElement();
        Integer count = (Integer) addedHash.get(day);

        if (count.intValue() > 0) {
            items.addElement(new GrowthItem(day, count));
        }
    }

    Collections.sort(items, new GrowthComparator());

    double value = 0.0;
    for (int i = 0; i < items.size(); i++) {
        GrowthItem item = (GrowthItem) items.elementAt(i);

        value += item.Count;

        series1.add(item.Day, value);

    }

    _dataset.removeAllSeries();
    _dataset.addSeries(series1);
}