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:app.com.example.wungmathing.sunshine.FetchWeatherTask.java

String[] convertContentValuesToUXFormat(Vector<ContentValues> cvv) {
    // return strings to keep UI functional for now
    String[] resultStrs = new String[cvv.size()];
    for (int i = 0; i < cvv.size(); i++) {
        ContentValues weatherValues = cvv.elementAt(i);
        String highAndLow = formatHighLows(weatherValues.getAsDouble(WeatherEntry.COLUMN_MAX_TEMP),
                weatherValues.getAsDouble(WeatherEntry.COLUMN_MIN_TEMP));
        resultStrs[i] = getReadableDateString(weatherValues.getAsLong(WeatherEntry.COLUMN_DATE)) + " - "
                + weatherValues.getAsString(WeatherEntry.COLUMN_SHORT_DESC) + " - " + highAndLow;
    }/*  w  w w  .  j a v  a 2  s  . c o  m*/
    return resultStrs;
}

From source file:dao.PendingfriendExistsQuery.java

public HashSet run(Connection conn, String loginid, String destloginid) {
    PreparedStatement stmt = null;
    ResultSet rs = null;// w w w.ja  v  a  2s. c om
    String sqlQuery = "select count(*) from pendingfriends where pendingfriends.loginid='" + loginid
            + "' and pendingfriends.destloginid='" + destloginid + "' or pendingfriends.loginid='" + destloginid
            + "' and pendingfriends.destloginid='" + loginid + "'";
    try {
        stmt = conn.prepareStatement(sqlQuery);
        rs = stmt.executeQuery();

        Vector columnNames = null;
        Pendingfriend pendingFriend = null;
        HashSet pendingSet = new HashSet();

        if (rs != null) {
            columnNames = dbutils.getColumnNames(rs);
        } else {
            return null;
        }

        while (rs.next()) {
            pendingFriend = (Pendingfriend) eop.newObject(DbConstants.PENDING_FRIEND);
            for (int j = 0; j < columnNames.size(); j++) {
                logger.debug("columnNames = " + (String) columnNames.elementAt(j));
                pendingFriend.setValue((String) columnNames.elementAt(j),
                        (String) rs.getString((String) columnNames.elementAt(j)));
            }
            pendingSet.add(pendingFriend);
        }
        return pendingSet;
    } catch (Exception e) {
        logger.warn("Error occured while executing pendingfriends run query", e);
        throw new BaseDaoException("Error occured while executing pendingfriends run query " + sqlQuery, e);
    }
}

From source file:dao.PblogSearchQuery.java

/**
 * This method lists all the results for the search text from pblogs
 * @param conn the connection//from  w  w w  . ja  v  a 2 s .  co  m
 * @param sString
 * @return HashSet the set that has the list of moderators for these collabrums.
 * @throws BaseDaoException - when error occurs
 **/
public HashSet run(Connection conn, String sString) throws BaseDaoException {

    if ((RegexStrUtil.isNull(sString) || conn == null)) {
        return null;
    }
    ResultSet rs = null;
    StringBuffer sb = new StringBuffer(
            "select hdlogin.loginid, hdlogin.login, hdlogin.fname, lname, LEFT(message, 160) as info, entrydate, usertags, pblogtopics.tid as ptid, hits from hdlogin left join pblogtopics on hdlogin.loginid=pblogtopics.pblogid left join pblogtags on pblogtopics.tid=pblogtags.tid left join pblog on hdlogin.loginid=pblog.loginid where ");

    // StringBuffer sb = new StringBuffer("select login, fname, lname, hits, membersince, LEFT(description, 160) as info from hdlogin left join usertab on hdlogin.loginid=usertab.loginid left join yourkeywords on hdlogin.loginid=yourkeywords.loginid left join mykeywords on hdlogin.loginid=mykeywords.loginid where ");

    ArrayList columns = new ArrayList();
    columns.add("topic");
    columns.add("message");
    columns.add("usertags");
    sb.append(sqlSearch.getConstraint(columns, sString));
    sb.append(" group by login order by hits DESC");

    logger.info("search query string" + sb.toString());

    try {
        PreparedStatement stmt = conn.prepareStatement(sb.toString());
        rs = stmt.executeQuery();

        Vector columnNames = null;
        Blog pblog = null;
        HashSet pendingSet = new HashSet();

        if (rs != null) {
            columnNames = dbutils.getColumnNames(rs);
        } else {
            return null;
        }

        while (rs.next()) {
            pblog = (Blog) eop.newObject(DbConstants.BLOG);
            for (int j = 0; j < columnNames.size(); j++) {
                if (((String) (columnNames.elementAt(j))).equalsIgnoreCase("entrydate")) {
                    try {
                        pblog.setValue("entrydate",
                                GlobalConst.dncalendar.getDisplayDate(rs.getTimestamp("entrydate")));
                        logger.info("entrydate" + rs.getTimestamp("entrydate"));
                    } catch (ParseException e) {
                        throw new BaseDaoException(
                                "could not parse the date for entrydate in PblogSearchQuery()"
                                        + rs.getTimestamp("entrydate"),
                                e);
                    }
                } else {
                    pblog.setValue((String) columnNames.elementAt(j),
                            (String) rs.getString((String) columnNames.elementAt(j)));
                }
            }
            pendingSet.add(pblog);
        }
        return pendingSet;
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing search in pblog run query ", e);
    }
}

From source file:dao.CollSearchQuery.java

/**
 * This method lists all the results for the search text
 * @param conn the connection/*from w ww  .j ava2s.  c o  m*/
 * @param collabrumId the collabrumid
 * @return HashSet the set that has the list of moderators for these collabrums.
 * @throws BaseDaoException - when error occurs
 **/
public HashSet run(Connection conn, String stext) throws BaseDaoException {

    if ((RegexStrUtil.isNull(stext) || conn == null)) {
        return null;
    }

    ResultSet rs = null;
    StringBuffer sb = new StringBuffer(
            "select distinct collabrumid, name, LEFT(coldesc, 160) as info, hits from collabrum where ");

    ArrayList columns = new ArrayList();
    columns.add("coldesc");
    columns.add("name");
    columns.add("keywords");
    sb.append(sqlSearch.getConstraint(columns, stext));
    sb.append(" order by hits DESC");

    try {
        PreparedStatement stmt = conn.prepareStatement(sb.toString());
        rs = stmt.executeQuery();

        Vector columnNames = null;
        Collabrum collabrum = null;
        HashSet pendingSet = new HashSet();

        if (rs != null) {
            columnNames = dbutils.getColumnNames(rs);
        } else {
            return null;
        }

        while (rs.next()) {
            collabrum = (Collabrum) eop.newObject(DbConstants.COLLABRUM);
            for (int j = 0; j < columnNames.size(); j++) {
                collabrum.setValue((String) columnNames.elementAt(j),
                        (String) rs.getString((String) columnNames.elementAt(j)));
            }
            pendingSet.add(collabrum);
        }
        return pendingSet;
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing search in collabrum run query ", e);
    }
}

From source file:com.example.android.sunshine.data.FetchWeatherTask.java

String[] convertContentValuesToUXFormat(Vector<ContentValues> cvv) {
    // return strings to keep UI functional for now
    String[] resultStrs = new String[cvv.size()];
    for (int i = 0; i < cvv.size(); i++) {
        ContentValues weatherValues = cvv.elementAt(i);
        String highAndLow = formatHighLows(
                weatherValues.getAsDouble(WeatherContract.WeatherEntry.COLUMN_MAX_TEMP),
                weatherValues.getAsDouble(WeatherContract.WeatherEntry.COLUMN_MIN_TEMP));
        resultStrs[i] = getReadableDateString(weatherValues.getAsLong(WeatherContract.WeatherEntry.COLUMN_DATE))
                + " - " + weatherValues.getAsString(WeatherContract.WeatherEntry.COLUMN_SHORT_DESC) + " - "
                + highAndLow;/* w  ww.  j  a  va  2  s  .  c  om*/
    }
    return resultStrs;
}

From source file:dao.DirSearchQuery.java

/**
 * This method lists all the results for the search text from directories
 * @param conn the connection//from www.j a va2  s. co m
 * @param collabrumId the collabrumid
 * @return HashSet the set that has the list of moderators for these collabrums.
 * @throws BaseDaoException - when error occurs
 **/
public HashSet run(Connection conn, String stext) throws BaseDaoException {

    if ((RegexStrUtil.isNull(stext) || conn == null)) {
        return null;
    }
    ResultSet rs = null;

    StringBuffer sb = new StringBuffer(
            "select distinct directoryid, dirname, LEFT(dirdesc, 160) as info, hits, creationdate from directory where ");

    ArrayList columns = new ArrayList();
    columns.add("dirdesc");
    columns.add("dirname");
    columns.add("keywords");
    sb.append(sqlSearch.getConstraint(columns, stext));
    sb.append(" order by hits DESC");
    logger.info("search = " + sb.toString());

    try {
        PreparedStatement stmt = conn.prepareStatement(sb.toString());
        rs = stmt.executeQuery();

        Vector columnNames = null;
        Directory directory = null;
        HashSet pendingSet = new HashSet();

        if (rs != null) {
            columnNames = dbutils.getColumnNames(rs);
        } else {
            return null;
        }

        while (rs.next()) {
            directory = (Directory) eop.newObject(DbConstants.DIRECTORY);
            for (int j = 0; j < columnNames.size(); j++) {
                if (((String) (columnNames.elementAt(j))).equalsIgnoreCase("creationdate")) {
                    try {
                        directory.setValue("creationdate",
                                GlobalConst.dncalendar.getDisplayDate(rs.getTimestamp("creationdate")));
                    } catch (ParseException e) {
                        throw new BaseDaoException(
                                "could not parse the date for creationdate in DirSearchQuery()"
                                        + rs.getTimestamp("creationdate"),
                                e);
                    }
                } else {
                    directory.setValue((String) columnNames.elementAt(j),
                            (String) rs.getString((String) columnNames.elementAt(j)));
                }
            }
            pendingSet.add(directory);
        }
        return pendingSet;
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing search in directory run query ", e);
    }
}

From source file:dao.VisitTrafficCityCountryQuery.java

/**
 * This method lists all the results for the geotarget text from directories
 * @param conn the connection//w w w.j  a v  a  2s. com
 * @param collabrumId the collabrumid
 * @return HashSet the set that has the list of moderators for these collabrums.
 * @throws BaseDaoException - when error occurs
 **/
public List run(Connection conn, String ipAddress) throws BaseDaoException {

    if (RegexStrUtil.isNull(ipAddress) || conn == null) {
        return null;
    }

    List ip = GlobalConst.httputil.parseIP4(ipAddress);
    StringBuffer iptable = new StringBuffer("ip4_");
    iptable.append(ip.get(0));

    int b = new Integer((String) ip.get(1)).intValue();
    int c = new Integer((String) ip.get(2)).intValue();

    Statement stmt = null;
    ResultSet rs = null;

    /*        String sb = select c3.b, c3.c, c1.name, c2.name as country, c1.state from geodb.cityByCountry c1, geodb.ip4_192 c3 left join geodb.countries c2 on c3.country=c2.id where b=(select substring_index(substring_index(kailash.visittraffic.ipaddress,'.',-3), '.', 1) as visitb from kailash.visittraffic) and c=0 limit 10; */

    String sb = "select state from cityByCountry as geo, " + iptable.toString() + " as iptable where b=" + b
            + " and c=" + c
            + " and geo.country=iptable.country and geo.city=iptable.city and (geo.state like '%New York%' or geo.state like '%California%') limit 1";

    /*
    "b" = select substring_index(substring_index(ipaddress, '.', -3), '.', 1) from visittraffic limit 3;
    "c" = select substring_index(substring_index(ipaddress, '.', -2), '.', 1) from visittraffic limit 3;
            
    iptable= select c4.ipaddress, CONCAT("ip_4",(substring_index(substring_index(c4.ipaddress,'.', 1), '.',1))) as iptable from kailash.visittraffic c4 ;
    */
    try {
        stmt = conn.createStatement();
        if (stmt == null) {
            return null;
        }

        rs = stmt.executeQuery(sb);

        Vector columnNames = null;
        Userpage userpage = null;
        List pendingList = new ArrayList();

        if (rs != null) {
            columnNames = dbutils.getColumnNames(rs);
        } else {
            return null;
        }

        while (rs.next()) {
            userpage = (Userpage) eop.newObject(DbConstants.USER_PAGE);
            for (int j = 0; j < columnNames.size(); j++) {
                userpage.setValue((String) columnNames.elementAt(j),
                        (String) rs.getString((String) columnNames.elementAt(j)));
            }
            pendingList.add(userpage);
        }
        return pendingList;
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing geotarget run query ", e);
    }
}

From source file:com.wallabystreet.kinjo.common.transport.ws.WSEngine.java

private void process(Element wsdd) throws DeploymentException {
    Service svc = new Service(server.getConfig(), (AxisClient) server.getClientEngine());

    Call call = null;// w  ww .ja v a  2s . c o m
    try {
        call = (org.apache.axis.client.Call) svc.createCall();
    } catch (ServiceException e) {
        log.error("", e);
        throw new DeploymentException(e);
    }

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

    Vector result = null;
    Object[] params = new Object[] { new SOAPBodyElement(wsdd) };
    try {
        result = (Vector) call.invoke(params);
    } catch (RemoteException e) {
        /* since this runs locally, this exception shouldn't ever raise */
        throw new DeploymentException(e);
    }

    if (result == null || result.isEmpty()) {
        log.debug("result message of call is empty");
    } else {
        SOAPBodyElement body = (SOAPBodyElement) result.elementAt(0);
        log.debug("result message of call is: \n" + body.toString());
    }
}

From source file:dao.UserSearchQuery.java

/**
 * This method lists all the results for the search text from directories
 * @param conn the connection//w  ww  .  j  av a  2s  . c  o  m
 * @param collabrumId the collabrumid
 * @return HashSet the set that has the list of moderators for these collabrums.
 * @throws BaseDaoException - when error occurs
 **/
public HashSet run(Connection conn, String sString) throws BaseDaoException {

    if ((RegexStrUtil.isNull(sString) || conn == null)) {
        return null;
    }

    ResultSet rs = null;
    StringBuffer sb = new StringBuffer(
            "select hdlogin.loginid, login, fname, lname, hits, membersince, LEFT(description, 160) as info from hdlogin left join usertab on hdlogin.loginid=usertab.loginid left join yourkeywords on hdlogin.loginid=yourkeywords.loginid left join mykeywords on hdlogin.loginid=mykeywords.loginid where ");

    ArrayList columns = new ArrayList();
    columns.add("login");
    columns.add("email");
    columns.add("description");
    columns.add("fname");
    columns.add("lname");
    columns.add("interests");
    columns.add("yourkeyword");
    columns.add("keyword");
    //columns.add("industry");
    columns.add("city");
    sb.append(sqlSearch.getConstraint(columns, sString));
    sb.append(" group by login order by hits DESC");
    logger.info("search query string" + sb.toString());

    try {
        PreparedStatement stmt = conn.prepareStatement(sb.toString());
        rs = stmt.executeQuery();

        Vector columnNames = null;
        Userpage userpage = null;
        HashSet pendingSet = new HashSet();

        if (rs != null) {
            columnNames = dbutils.getColumnNames(rs);
        } else {
            return null;
        }

        while (rs.next()) {
            userpage = (Userpage) eop.newObject(DbConstants.USER_PAGE);
            for (int j = 0; j < columnNames.size(); j++) {
                if (((String) (columnNames.elementAt(j))).equalsIgnoreCase("membersince")) {
                    try {
                        userpage.setValue(DbConstants.DATE,
                                GlobalConst.dncalendar.getDisplayDate(rs.getTimestamp("membersince")));
                    } catch (ParseException e) {
                        throw new BaseDaoException(
                                "could not parse the date for membersince in UserSearchQuery()"
                                        + rs.getTimestamp("membersince"),
                                e);
                    }
                } else {
                    userpage.setValue((String) columnNames.elementAt(j),
                            (String) rs.getString((String) columnNames.elementAt(j)));
                }
            }
            pendingSet.add(userpage);
        }
        return pendingSet;
    } catch (Exception e) {
        throw new BaseDaoException(
                "Error occured while executing search in userpage run query " + sb.toString(), e);
    }
}

From source file:dao.UserSearchBizAwareQuery.java

/**
 * This method lists all the results for the search text from directories
 * @param conn the connection//from   w  ww.java2  s. co  m
 * @param collabrumId the collabrumid
 * @return HashSet the set that has the list of moderators for these collabrums.
 * @throws BaseDaoException - when error occurs
 **/
public HashSet run(Connection conn, String sString, String bid) throws BaseDaoException {

    if (RegexStrUtil.isNull(sString) || conn == null || RegexStrUtil.isNull(bid)) {
        return null;
    }

    ResultSet rs = null;
    //StringBuffer sb = new StringBuffer("select distinct c2.login, c2.fname, c2.lname, c1.hits, c1.membersince, LEFT(c1.description, 160) as info from usertab c1 left outer join hdlogin c2 on c1.loginid=c2.loginid where "); 

    StringBuffer sb = new StringBuffer(
            "select login, fname, lname, hits, membersince, LEFT(description, 160) as info, hdlogin.bid, bsearch from business, hdlogin left join usertab on hdlogin.loginid=usertab.loginid left join yourkeywords on hdlogin.loginid=yourkeywords.loginid left join mykeywords on hdlogin.loginid=mykeywords.loginid where business.bid=hdlogin.bid and (");

    ArrayList columns = new ArrayList();
    columns.add("description");
    columns.add("fname");
    columns.add("lname");
    columns.add("interests");
    columns.add("yourkeyword");
    columns.add("keyword");
    //columns.add("industry");
    columns.add("city");
    sb.append(sqlSearch.getConstraint(columns, sString));
    sb.append(") group by login order by hits DESC");
    logger.info("search query string" + sb.toString());

    try {
        PreparedStatement stmt = conn.prepareStatement(sb.toString());
        rs = stmt.executeQuery();

        Vector columnNames = null;
        Userpage userpage = null;
        HashSet pendingSet = new HashSet();

        if (rs != null) {
            columnNames = dbutils.getColumnNames(rs);
        } else {
            return null;
        }

        while (rs.next()) {
            userpage = (Userpage) eop.newObject(DbConstants.USER_PAGE);
            for (int j = 0; j < columnNames.size(); j++) {
                if (((String) (columnNames.elementAt(j))).equalsIgnoreCase("membersince")
                        && (rs.getTimestamp("membersince") != null)) {
                    try {
                        userpage.setValue(DbConstants.DATE,
                                GlobalConst.dncalendar.getDisplayDate(rs.getTimestamp("membersince")));
                    } catch (ParseException e) {
                        throw new BaseDaoException(
                                "could not parse the date for membersince in UserSearchBizAwareQuery()"
                                        + rs.getTimestamp("membersince"),
                                e);
                    }
                } else {
                    userpage.setValue((String) columnNames.elementAt(j),
                            (String) rs.getString((String) columnNames.elementAt(j)));
                }
            }
            pendingSet.add(userpage);
        }
        return pendingSet;
    } catch (Exception e) {
        throw new BaseDaoException(
                "Error occured while executing search in userpage run query " + sb.toString(), e);
    }
}