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:org.apache.tomcat.util.IntrospectionUtils.java

public static String[] findBooleanSetters(Class c) {
    Method m[] = findMethods(c);/*from   ww  w. jav  a 2s .  co  m*/
    if (m == null)
        return null;
    Vector v = new Vector();
    for (int i = 0; i < m.length; i++) {
        if (m[i].getName().startsWith("set") && m[i].getParameterTypes().length == 1
                && "boolean".equalsIgnoreCase(m[i].getParameterTypes()[0].getName())) {
            String arg = m[i].getName().substring(3);
            v.addElement(unCapitalize(arg));
        }
    }
    String s[] = new String[v.size()];
    for (int i = 0; i < s.length; i++) {
        s[i] = (String) v.elementAt(i);
    }
    return s;
}

From source file:com.panet.imeta.job.entries.sftp.SFTPClient.java

public String[] dir() throws KettleJobException {
    String[] fileList = null;/*from   www  .  jav a 2 s  .c o m*/

    try {
        java.util.Vector<?> v = c.ls(".");
        java.util.Vector<String> o = new java.util.Vector<String>();
        if (v != null) {
            for (int i = 0; i < v.size(); i++) {
                Object obj = v.elementAt(i);
                if (obj != null && obj instanceof com.jcraft.jsch.ChannelSftp.LsEntry) {
                    LsEntry lse = (com.jcraft.jsch.ChannelSftp.LsEntry) obj;
                    if (!lse.getAttrs().isDir())
                        o.add(lse.getFilename());
                }
            }
        }
        if (o.size() > 0) {
            fileList = new String[o.size()];
            o.copyInto(fileList);
        }
    } catch (SftpException e) {
        throw new KettleJobException(e);
    }

    return fileList;
}

From source file:org.globus.ftp.test.ByteRangeListTest.java

/**
   Merge vector into a new ByteRangeList.
   Test merge(ByteRange), merge(Vector), toFtpCmdArgument().
 **/// w w  w .java  2s  .  c  o m
private void assertMerge(Vector v, String result) {

    logger.info("merging vector of ranges: " + result);

    ByteRangeList list1 = new ByteRangeList();
    for (int i = 0; i < v.size(); i++) {
        list1.merge((ByteRange) v.elementAt(i));
    }
    logger.debug("    -> " + list1.toFtpCmdArgument());
    assertTrue(list1.toFtpCmdArgument().equals(result));

    logger.debug("merging one by one again..");
    ByteRangeList list3 = new ByteRangeList();
    for (int i = 0; i < v.size(); i++) {
        list3.merge((ByteRange) v.elementAt(i));
    }
    logger.debug(" .. -> " + list3.toFtpCmdArgument());
    assertTrue(list3.toFtpCmdArgument().equals(result));

    logger.debug("merging vector at once");
    ByteRangeList list2 = new ByteRangeList();
    list2.merge(v);
    logger.debug(" .. -> " + list2.toFtpCmdArgument());
    assertTrue(list2.toFtpCmdArgument().equals(result));

}

From source file:dao.PblogMonthlyQuery.java

public HashSet run(Connection conn, String pblogid, String month, String year) {

    //String sqlQuery = "select LEFT(entrydate,10) as entrydate from pblogtopics where pblogid='"+pblogid+"' and MONTH(entrydate)='"+month+"' and year(entrydate)='"+year+"'";
    String sqlQuery = "select LEFT(entrydate,10) as entrydate from pblogtopics where pblogid='" + pblogid
            + "' and MONTH(entrydate)='" + month + "' and year(entrydate)='" + year + "'";

    try {/*w  w w  .  j a va2 s  .c o  m*/
        PreparedStatement stmt = conn.prepareStatement(sqlQuery);
        ResultSet rs = stmt.executeQuery();
        Vector columnNames = null;
        HashSet blogSet = new HashSet();
        Blog blog = null;

        if (rs != null) {
            columnNames = dbutils.getColumnNames(rs);
        }
        while (rs.next()) {
            blog = (Blog) eop.newObject(DbConstants.BLOG);
            for (int j = 0; j < columnNames.size(); j++) {
                blog.setValue((String) columnNames.elementAt(j),
                        (String) rs.getString((String) columnNames.elementAt(j)));
            }
            blogSet.add(blog);
        }
        return blogSet;
    } catch (Exception e) {
        logger.warn("Error occured while executing PblogMonthlyQuery run query" + sqlQuery, e);
        throw new BaseDaoException("Error occured while executing PblogMonthlyQuery run query " + sqlQuery, e);
    }
}

From source file:dao.PblogDateQuery.java

public HashSet run(Connection conn, String pblogid, String month, String year, String day) {

    //String sqlQuery = "select LEFT(entrydate,10) as entrydate from pblogtopics where pblogid='"+pblogid+"' and MONTH(entrydate)='"+month+"' and year(entrydate)='"+year+"'";
    String sqlQuery = "select LEFT(entrydate,10) as entrydate from pblogtopics where pblogid='" + pblogid
            + "' and MONTH(entrydate)='" + month + "' and year(entrydate)='" + year + "' and day(entrydate)='"
            + day + "'";
    logger.info("sqlQuery = " + sqlQuery);

    try {/*from   w ww .  j av  a 2 s.co m*/
        PreparedStatement stmt = conn.prepareStatement(sqlQuery);
        ResultSet rs = stmt.executeQuery();
        Vector columnNames = null;
        HashSet blogSet = new HashSet();
        Blog blog = null;

        if (rs != null) {
            columnNames = dbutils.getColumnNames(rs);
        }
        while (rs.next()) {
            blog = (Blog) eop.newObject(DbConstants.BLOG);
            for (int j = 0; j < columnNames.size(); j++) {
                blog.setValue((String) columnNames.elementAt(j),
                        (String) rs.getString((String) columnNames.elementAt(j)));
            }
            blogSet.add(blog);
        }
        return blogSet;
    } catch (Exception e) {
        logger.warn("Error occured while executing pblogdailyQuery run query", e);
        throw new BaseDaoException("Error occured while executing pblogdailyQuery run query " + sqlQuery, e);
    }
}

From source file:eionet.meta.DDUser.java

/**
 *
 * @return//from   w w w  .j ava2s  .c o m
 */
public String[] getUserRoles() {

    if (roles == null) {
        try {

            Vector v = DirectoryService.getRoles(username);
            roles = new String[v.size()];
            for (int i = 0; i < v.size(); i++) {
                roles[i] = (String) v.elementAt(i);
            }
            LOGGER.debug("Found " + roles.length + " roles for user (" + username + ")");
        } catch (Exception e) {
            LOGGER.error("Unable to get any role for loggedin user (" + username + "). DirServiceException: "
                    + e.getMessage());
            roles = new String[] {};
        }
    }

    return roles;
}

From source file:dao.CarryonEntryIdQuery.java

public List run(Connection conn, String loginid) {
    String sqlQuery = "select entryid from carryon where loginid=" + loginid
            + " order by entrydate DESC limit 1";
    try {/*  w  w w.  j  a  va 2 s.c om*/
        PreparedStatement stmt = conn.prepareStatement(sqlQuery);
        ResultSet rs = stmt.executeQuery();

        Vector columnNames = null;
        Photo photo = null;
        List photosList = new ArrayList();

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

        while (rs.next()) {
            photo = (Photo) eop.newObject(DbConstants.PHOTO);
            for (int j = 0; j < columnNames.size(); j++) {
                photo.setValue((String) columnNames.elementAt(j),
                        (String) rs.getString((String) columnNames.elementAt(j)));
            }
            photosList.add(photo);
        }
        return photosList;
    } catch (Exception e) {
        logger.warn("Error occured while executing CarryonEntryIdQuery run query", e);
        throw new BaseDaoException("Error occured while executing CarryonEntryIdQuery run query " + sqlQuery,
                e);
    }
}

From source file:com.sittinglittleduck.DirBuster.workGenerators.WorkerGeneratorURLFuzz.java

/** Thread run method */
public void run() {

    /*//from   w  w w . jav a  2 s .  c o m
     * Read in all the items and create all the work we need to.
     */

    BufferedReader d = null;
    try {
        manager.setURLFuzzGenFinished(false);
        String currentDir = "/";
        int failcode = 404;
        String line;
        Vector extToCheck = new Vector(10, 5);
        boolean recursive = true;
        int passTotal = 0;

        try {
            d = new BufferedReader(new InputStreamReader(new FileInputStream(inputFile)));
            passTotal = 0;
            while ((line = d.readLine()) != null) {
                if (!line.startsWith("#")) {
                    passTotal++;
                }
            }
            manager.setTotalPass(passTotal);
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        if (manager.getAuto()) {
            try {
                URL headurl = new URL(firstPart);
                HeadMethod httphead = new HeadMethod(headurl.toString());
                Vector HTTPheaders = manager.getHTTPHeaders();
                for (int a = 0; a < HTTPheaders.size(); a++) {
                    HTTPHeader httpHeader = (HTTPHeader) HTTPheaders.elementAt(a);
                    httphead.setRequestHeader(httpHeader.getHeader(), httpHeader.getValue());
                }
                httphead.setFollowRedirects(Config.followRedirects);
                int responceCode = httpclient.executeMethod(httphead);
                if (Config.debug) {
                    System.out.println("DEBUG WokerGen: responce code for head check = " + responceCode);
                }
                if (responceCode == 501 || responceCode == 400 || responceCode == 405) {
                    if (Config.debug) {
                        System.out.println(
                                "DEBUG WokerGen: Changing to GET only HEAD test returned 501(method no implmented) or a 400");
                    }
                    manager.setAuto(false);
                }
            } catch (MalformedURLException e) {
            } catch (IOException e) {
            }
        }

        d = new BufferedReader(new InputStreamReader(new FileInputStream(inputFile)));
        System.out.println("Starting fuzz on " + firstPart + urlFuzzStart + "{dir}" + urlFuzzEnd);
        int filesProcessed = 0;

        BaseCase baseCaseObj = GenBaseCase.genURLFuzzBaseCase(manager, firstPart + urlFuzzStart, urlFuzzEnd);

        while ((line = d.readLine()) != null) {
            if (stopMe) {
                return;
            }

            if (!line.startsWith("#")) {
                String method;
                if (manager.getAuto() && !baseCaseObj.useContentAnalysisMode()
                        && !baseCaseObj.isUseRegexInstead()) {
                    method = "HEAD";
                } else {
                    method = "GET";
                }

                // url encode all the items
                line = URLEncoder.encode(line);

                URL currentURL = new URL(firstPart + urlFuzzStart + line + urlFuzzEnd);
                // BaseCase baseCaseObj = new BaseCase(currentURL, failcode, true, failurl,
                // baseResponce);
                // if the base case is null then we need to switch to content anylsis mode
                workQueue.put(new WorkUnit(currentURL, true, method, baseCaseObj, line));
            }

            Thread.sleep(3);
        }
    } catch (InterruptedException ex) {
        Logger.getLogger(WorkerGeneratorURLFuzz.class.getName()).log(Level.SEVERE, null, ex);
    } catch (MalformedURLException ex) {
        Logger.getLogger(WorkerGeneratorURLFuzz.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(WorkerGeneratorURLFuzz.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        try {
            d.close();
            manager.setURLFuzzGenFinished(true);
        } catch (IOException ex) {
            Logger.getLogger(WorkerGeneratorURLFuzz.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:com.cohort.util.String2LogFactory.java

/**
 * Return an array containing the names of all currently defined
 * configuration attributes.  If there are no such attributes, a zero
 * length array is returned./*from w w  w. j  a  v  a 2 s .c om*/
 */
public String[] getAttributeNames() {
    synchronized (attributes) {
        Vector names = new Vector();
        Enumeration keys = attributes.keys();
        while (keys.hasMoreElements()) {
            names.addElement((String) keys.nextElement());
        }
        String results[] = new String[names.size()];
        for (int i = 0; i < results.length; i++) {
            results[i] = (String) names.elementAt(i);
        }
        return (results);
    }
}

From source file:dao.CarryonHitsQuery.java

/**
 * This constructor is called when the bean makes a 
 * call to query.execute(). //w w  w .j  a  v  a2s . co  m
 */
public List run(Connection conn) throws BaseDaoException {

    if (conn == null) {
        return null;
    }

    try {
        PreparedStatement stmt = conn.prepareStatement(
                "select hdlogin.login, carryonhits.loginid,carryonhits.entryid,carryonhits.btitle,carryonhits.hits,carryontag.usertags from carryonhits left join carryontag on carryonhits.loginid=carryontag.ownerid and carryontag.entryid=carryonhits.entryid left join hdlogin on carryonhits.loginid=hdlogin.loginid group by carryonhits.entryid order by hits DESC limit 20");

        if (stmt == null) {
            return null;
        }

        ResultSet rs = stmt.executeQuery();
        Vector columnNames = null;
        Photo photo = null;
        List photoList = new ArrayList();

        if (rs != null) {
            columnNames = dbutils.getColumnNames(rs);
            while (rs.next()) {
                photo = (Photo) eop.newObject(DbConstants.PHOTO);
                for (int j = 0; j < columnNames.size(); j++) {
                    photo.setValue((String) columnNames.elementAt(j),
                            (String) rs.getString((String) columnNames.elementAt(j)));
                }
                photoList.add(photo);
            }
        }
        return photoList;
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing carryonhits run query ", e);
    }
}