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:nl.nn.adapterframework.util.StringTagger.java

/**
 * Returns the first value as a <code>String</code>.
 * In case of a single value, it returns that value. In case of multiple values,
 * it returns the//from  ww w  .  j  ava2  s  .  c o  m
 * Use {@link #get} to get the list of values as a <code>String</code><br>
 * Use {@link #Values} to get a list of multi-values as a <code>Vector</code>.<br>
 * @param token the key of the value to retrieve
 */
public String Value(String token) {
    String val;
    Vector tmp = (Vector) multitokens.get(token);
    if (tmp != null && tmp.size() > 0) {
        val = (String) tmp.elementAt(0);
        if (val != null) {
            val = StringUtils.strip(val, "\""); // added stripping daniel
            return val;
        } else {
            return null;
        }
    } else {
        return null;
    }
}

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

public void run() {
    boolean recursive = true;

    // checks if the server surports heads requests

    if (manager.getAuto()) {
        try {/* www  . ja  va 2  s  .  c om*/
            URL headurl = new URL(firstPart);

            HeadMethod httphead = new HeadMethod(headurl.toString());

            // set the custom HTTP headers
            Vector HTTPheaders = manager.getHTTPHeaders();
            for (int a = 0; a < HTTPheaders.size(); a++) {
                HTTPHeader httpHeader = (HTTPHeader) HTTPheaders.elementAt(a);
                httphead.setRequestHeader(httpHeader.getHeader(), httpHeader.getValue());
            }
            int responceCode = httpclient.executeMethod(httphead);

            // if the responce code is method not implemented or fails
            if (responceCode == 501 || responceCode == 400) {
                // switch the mode to just GET requests
                manager.setAuto(false);
            }
        } catch (MalformedURLException e) {
            // TODO deal with error
        } catch (IOException e) {
            // TODO deal with error
        }
    }

    while ((!dirQueue.isEmpty() || !workQueue.isEmpty()) && recursive) {
        recursive = manager.isRecursive();
        // deal with the dirs
        try {
            // get item from  queue
            DirToCheck tempDirToCheck = dirQueue.take();
            // get dir name
            currentDir = tempDirToCheck.getName();
            // get any extention that need to be checked
            extToCheck = tempDirToCheck.getExts();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        started = currentDir;

        if (manager.getDoDirs()) {
            doingDirs = true;
            String baseCase = null;
            // store for the basecase object set to null;
            BaseCase baseCaseObj = null;
            URL failurl = null;
            try {
                // get fail responce code for a dir test

                baseCaseObj = GenBaseCase.genBaseCase(manager, firstPart + currentDir, true, null);

            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }

            // baseCaseObj = new BaseCase(null, failcode, true, failurl, baseCase);
            // call function to generate the brute force
            if (failcode != 200) {
                makeList(minLen, maxLen, null, baseCaseObj);
            } else {
                makeList(minLen, maxLen, baseCase, baseCaseObj);
            }
        } // end of doing the dirs

        // brute force files names
        if (manager.getDoFiles()) {
            doingDirs = false;
            String baseCase = null;
            BaseCase baseCaseObj = null;
            URL failurl = null;
            for (int b = 0; b < extToCheck.size(); b++) {
                ExtToCheck tempExt = (ExtToCheck) extToCheck.elementAt(b);
                if (tempExt.toCheck()) {
                    fileExtention = "";
                    if (tempExt.getName().equals(ExtToCheck.BLANK_EXT)) {
                        fileExtention = "";
                    } else {
                        fileExtention = "." + tempExt.getName();
                    }

                    try {
                        // deal with the files

                        baseCaseObj = GenBaseCase.genBaseCase(manager, firstPart + currentDir, false,
                                fileExtention);

                    } catch (MalformedURLException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }

                    // call function to generate the brute force
                    if (failcode != 200) {
                        makeList(minLen, maxLen, null, baseCaseObj);
                    } else {
                        makeList(minLen, maxLen, baseCase, baseCaseObj);
                    }
                }
            }
        }

        finished = started;
    }
    manager.youAreFinished();
}

From source file:dao.TagsQuery.java

public List run(Connection conn, int numTags) throws BaseDaoException {

    ResultSet rs = null;/*from   ww w .j  ava2 s .c  om*/
    String sqlQuery = "select * from tags order by hits DESC limit " + numTags + "";
    //logger.info("sqlQuery = " + sqlQuery);

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

        Vector columnNames = null;
        Yourkeywords tag = null;
        List tagList = new ArrayList();

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

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

From source file:dao.PblogTagsUserQuery.java

public HashSet run(Connection conn, String sString) throws BaseDaoException {

    if ((RegexStrUtil.isNull(sString) || conn == null)) {
        return null;
    }//w ww .  j a  va 2  s.  c om

    ResultSet rs = null;
    StringBuffer sb = new StringBuffer("select distinct usertags from pblogtags where ");
    ArrayList columns = new ArrayList();
    columns.add("ownerid");
    sb.append(sqlSearch.getConstraint(columns, sString));
    //logger.info("PblogTagsUserQuery = " + sb.toString());

    try {
        PreparedStatement stmt = conn.prepareStatement(sb.toString());
        rs = stmt.executeQuery();
        Vector columnNames = null;
        Blog blog = null;
        HashSet pendingSet = new HashSet();

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

        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)));
            }
            pendingSet.add(blog);
        }
        return pendingSet;
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing search in PblogTagsUserQuery run query ", e);
    }
}

From source file:org.campware.cream.modules.util.XmlRpcHandler.java

/**
 * The client has indicated that it would like
 * to update customer data.//from  w ww.ja  va 2s  . c  o  m
 */
public int updateCustomer(Vector params) {

    try {
        Criteria criteria = new Criteria();
        criteria.add(CustomerPeer.LOGIN_NAME, params.elementAt(12), Criteria.EQUAL);
        criteria.add(CustomerPeer.PASSWORD_VALUE, params.elementAt(13), Criteria.EQUAL);
        Customer entry = (Customer) CustomerPeer.doSelect(criteria).get(0);

        entry.setCustomerDisplay((String) params.elementAt(0));
        entry.setCustomerName1((String) params.elementAt(0));
        entry.setCustomerName2((String) params.elementAt(1));
        entry.setAddress1((String) params.elementAt(2));
        entry.setAddress2((String) params.elementAt(3));
        entry.setCity((String) params.elementAt(4));
        entry.setZip((String) params.elementAt(5));
        entry.setState((String) params.elementAt(6));

        try {
            entry.setCountryId(((Integer) params.elementAt(7)).intValue());
        } catch (Exception e) {
            return -1;
        }
        entry.setPhone1((String) params.elementAt(8));
        entry.setPhone2((String) params.elementAt(9));
        entry.setFax((String) params.elementAt(10));
        entry.setEmail((String) params.elementAt(11));
        entry.setLoginName((String) params.elementAt(12));
        entry.setPasswordValue((String) params.elementAt(13));

        entry.setModifiedBy("web");
        entry.setModified(new Date());

        entry.setModified(true);
        entry.setNew(false);
        entry.save();

    } catch (Exception e) {
        return -1;
    }

    return 1;

}

From source file:es.prodevelop.gvsig.mini.tasks.namefinder.NameFinderFunc.java

@Override
public boolean execute() {

    NameFinder NFTask = new NameFinder();
    String query = new String(NFTask.URL + NFTask.parms).replaceAll(" ", "%20");

    try {//from  ww w .  j  av a2  s .  co  m
        log.log(Level.FINE, query);
        InputStream is = Utils.openConnection(query);
        BufferedInputStream bis = new BufferedInputStream(is);

        /* Read bytes to the Buffer until there is nothing more to read(-1). */
        ByteArrayBuffer baf = new ByteArrayBuffer(50);
        int current = 0;
        while ((current = bis.read()) != -1) {
            if (this.isCanceled()) {
                res = TaskHandler.CANCELED;
                return true;
            }
            baf.append((byte) current);

        }

        Vector result = NFTask.parse(baf.toByteArray());

        if (result != null) {
            // handler.sendEmptyMessage(map.POI_SUCCEEDED);
            Named[] searchRes = new Named[result.size()];
            desc = new String[result.size()];
            for (int i = 0; i < result.size(); i++) {
                Named n = (Named) result.elementAt(i);
                desc[i] = n.description;
                searchRes[i] = n;

                if (this.isCanceled()) {
                    res = TaskHandler.CANCELED;
                    return true;
                }
            }

            if (this.isCanceled()) {
                res = TaskHandler.CANCELED;
                return true;
            }
            nm = new NamedMultiPoint(searchRes);

            res = TaskHandler.FINISHED;
        } else {
            res = TaskHandler.CANCELED;
        }
    } catch (IOException e) {
        if (e instanceof UnknownHostException) {
            res = TaskHandler.NO_RESPONSE;
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, "Namefinder" + e.getMessage(), e);
    } finally {

    }
    return true;
}

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

/**
 * This method will return a vector which will a whole service was
 * unselected We consider the whole services was seleted: 1. both service
 * name and all document types in the service were unselected. 2. service
 * name is selected, but the all documents types are unselected
 * // w w w  .  ja v  a  2 s. c o  m
 * @return Vector
 */
public Vector getAllUnSelectedServicesList() {
    Vector list = new Vector();
    Vector selectedList = tableModel.getSelectedServicesList();
    if (selectedList != null) {
        int length = selectedList.size();
        for (int i = 0; i < length; i++) {
            SelectableEcoGridService service = (SelectableEcoGridService) selectedList.elementAt(i);
            SelectableServiceName name = service.getSelectableServiceName();
            // if (name != null && !name.getIsSelected())
            // {
            SelectableDocumentType[] types = service.getSelectableDocumentTypeList();
            if (isDocuementTypeAllUnSelected(types)) {
                list.add(service);
            } // fi
              // }//else if
        } // for
    } // if
    return list;
}

From source file:com.sittinglittleduck.DirBuster.Worker.java

private int makeRequest(HttpMethodBase httpMethod) throws HttpException, IOException, InterruptedException {
    if (Config.debug) {
        System.out.println("DEBUG Worker[" + threadId + "]: " + httpMethod.getName() + " : " + url.toString());
    }//from ww w  .  ja  v  a  2 s. co  m

    // set the custom HTTP headers
    Vector HTTPheaders = manager.getHTTPHeaders();
    for (int a = 0; a < HTTPheaders.size(); a++) {
        HTTPHeader httpHeader = (HTTPHeader) HTTPheaders.elementAt(a);
        /*
         * Host header has to be set in a different way!
         */
        if (httpHeader.getHeader().startsWith("Host")) {
            httpMethod.getParams().setVirtualHost(httpHeader.getValue());
        } else {
            httpMethod.setRequestHeader(httpHeader.getHeader(), httpHeader.getValue());
        }
    }
    httpMethod.setFollowRedirects(Config.followRedirects);

    /*
     * this code is used to limit the number of request/sec
     */
    if (manager.isLimitRequests()) {
        while (manager.getTotalDone()
                / ((System.currentTimeMillis() - manager.getTimestarted()) / 1000.0) > manager
                        .getLimitRequestsTo()) {
            Thread.sleep(100);
        }
    }
    /*
     * Send the request
     */
    int code = httpclient.executeMethod(httpMethod);

    if (Config.debug) {
        System.out.println("DEBUG Worker[" + threadId + "]: " + code + " " + url.toString());
    }
    return code;
}

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

/**
 * This method will return a vector which will a whole service was selected
 * We consider the whole services was seleted: The service name was selected
 * and all document types in the service were selected.
 * /*w  ww .  j  a  va2 s  .  c o  m*/
 * @return Vector
 */
public Vector getAllSelectedServicesList() {
    Vector list = new Vector();
    Vector selectedList = tableModel.getSelectedServicesList();
    if (selectedList != null) {
        int length = selectedList.size();
        for (int i = 0; i < length; i++) {
            SelectableEcoGridService service = (SelectableEcoGridService) selectedList.elementAt(i);
            SelectableServiceName name = service.getSelectableServiceName();
            if (name != null && !name.getIsSelected()) {
                SelectableDocumentType[] types = service.getSelectableDocumentTypeList();
                if (isDocuementTypeAllSelected(types)) {
                    list.add(service);
                } // fi
            } else if (name != null && name.getIsSelected()) {
                list.add(service);
            }
        } // for
    } // if
    return list;
}

From source file:dao.DirectoryListUsersQuery.java

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

/* Uses tables - directory, dirallow, 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, "
            + "dirallow d2, hdlogin hd where d2.loginid=hd.loginid "
            + "and d1.directoryid=d2.directoryid and d1.directoryid=" + directoryid + "";
    try {
        PreparedStatement stmt = conn.prepareStatement(sqlQuery);
        ResultSet rs = stmt.executeQuery();
        Vector columnNames = null;
        Directory directory = null;
        HashSet dirSet = 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++) {
                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 DirectoryListUsersQuery run query " + sqlQuery, e);
    }
}