Example usage for java.util Vector size

List of usage examples for java.util Vector size

Introduction

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

Prototype

public synchronized int size() 

Source Link

Document

Returns the number of components in this vector.

Usage

From source file:com.iver.cit.gvsig.fmap.drivers.wms.FMapWMSDriver.java

private GetMapRequest createMapRequest(WMSStatus status) {
    GetMapRequest mapRequest = wms.createGetMapRequest();

    mapRequest.setSRS(status.getSrs());/* w w w .  j  a va 2s  .  c om*/

    String bbox = status.getExtent().getMinX() + "," + status.getExtent().getMinY() + ","
            + status.getExtent().getMaxX() + "," + status.getExtent().getMaxY();
    mapRequest.setBBox(bbox);
    mapRequest.setDimensions(status.getWidth(), status.getHeight());
    mapRequest.setFormat(status.getFormat());
    mapRequest.setTransparent(status.getTransparency());

    Vector<String> stylesVector = status.getStyles();
    if (stylesVector != null && stylesVector.size() > 0) {
        Vector<String> layerNamesVector = status.getLayerNames();
        for (int i = 0; i < stylesVector.size(); i++) {
            mapRequest.addLayer(layerNamesVector.get(i), stylesVector.get(i));
        }
    } else {
        for (Layer layer : WMSUtils.getNamedLayers(wms.getCapabilities())) {
            mapRequest.addLayer(layer);
        }
    }
    return mapRequest;
}

From source file:com.ricemap.spateDB.operations.Repartition.java

public static <S extends Shape> CellInfo[] packInPrisms(FileSystem fs, Path[] files, FileSystem outFileSystem,
        Path outFile, long blocksize, S stockShape) throws IOException {
    final Vector<Point3d> sample = new Vector<Point3d>();

    double sample_ratio = outFileSystem.getConf().getFloat(SpatialSite.SAMPLE_RATIO, 0.01f);
    long sample_size = outFileSystem.getConf().getLong(SpatialSite.SAMPLE_SIZE, 100 * 1024 * 1024);

    // 24 is the estimated size in bytes needed to store each sample point 
    long sample_count = sample_size / 24;

    LOG.info("Reading a sample of " + (int) Math.round(sample_ratio * 100) + "%");
    ResultCollector<Point3d> resultCollector = new ResultCollector<Point3d>() {
        @Override//from   www.  j  av  a2 s  .c  o  m
        public void collect(Point3d value) {
            sample.add(value.clone());
        }
    };
    Sampler.sampleWithRatio(fs, files, sample_ratio, sample_count, System.currentTimeMillis(), resultCollector,
            stockShape, new Point3d());
    LOG.info("Finished reading a sample of size: " + sample.size() + " records");

    long inFileSize = Sampler.sizeOfLastProcessedFile;

    // Compute an approximate MBR to determine the desired number of rows
    // and columns
    Prism approxMBR = new Prism(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE, -Double.MAX_VALUE,
            -Double.MAX_VALUE, -Double.MAX_VALUE);
    for (Point3d pt : sample) {
        approxMBR.expand(pt);
    }
    GridInfo gridInfo = new GridInfo(approxMBR.t1, approxMBR.x1, approxMBR.y1, approxMBR.t2, approxMBR.x2,
            approxMBR.y2);
    gridInfo.calculateCellDimensions(Math.max(1, (int) ((inFileSize + blocksize / 2) / blocksize)));
    gridInfo.set(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE,
            Double.MAX_VALUE);

    Prism[] Prisms = RTree.packInPrisms(gridInfo, sample.toArray(new Point3d[sample.size()]));
    CellInfo[] cellsInfo = new CellInfo[Prisms.length];
    for (int i = 0; i < Prisms.length; i++)
        cellsInfo[i] = new CellInfo(i + 1, Prisms[i]);

    return cellsInfo;
}

From source file:DatabaseBrowser.java

protected void populateSchemaBox() {
    try {//from   www  .j ava 2  s.  c o m
        DatabaseMetaData dmd = connection.getMetaData();
        ResultSet rset = dmd.getSchemas();
        Vector values = new Vector();
        while (rset.next()) {
            values.addElement(rset.getString(1));
        }
        rset.close();
        schemaBox.setModel(new DefaultComboBoxModel(values));
        schemaBox.setEnabled(values.size() > 0);
    } catch (Exception e) {
        schemaBox.setEnabled(false);
    }
}

From source file:dao.TagsQuery.java

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

    ResultSet rs = null;//from  ww  w. j a  v a 2  s  .  c  o  m
    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:DatabaseBrowser.java

protected void populateTableBox() {
    try {//  w w w. j a va 2s  .  c  o  m
        String[] types = { "TABLE" };
        String catalog = connection.getCatalog();
        String schema = (String) (schemaBox.getSelectedItem());
        DatabaseMetaData dmd = connection.getMetaData();
        ResultSet rset = dmd.getTables(catalog, schema, null, types);
        Vector values = new Vector();
        while (rset.next()) {
            values.addElement(rset.getString(3));
        }
        rset.close();
        tableBox.setModel(new DefaultComboBoxModel(values));
        tableBox.setEnabled(values.size() > 0);
    } catch (Exception e) {
        tableBox.setEnabled(false);
    }
}

From source file:com.openmeap.json.JSONObjectBuilder.java

private Object[] toTypedArray(Vector list) {
    if (list.isEmpty()) {
        return null;
    }/* w w w  . j a  v  a  2 s . c  o  m*/
    Object first = list.elementAt(0);
    Object[] ret = null;
    if (first instanceof String) {
        ret = new String[list.size()];
    } else if (first instanceof Double) {
        ret = new Double[list.size()];
    } else if (first instanceof Integer) {
        ret = new Integer[list.size()];
    } else if (first instanceof Long) {
        ret = new Long[list.size()];
    } else if (first instanceof Boolean) {
        ret = new Boolean[list.size()];
    }
    list.copyInto(ret);
    return (Object[]) ret;
}

From source file:dao.PblogTagsUserQuery.java

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

    if ((RegexStrUtil.isNull(sString) || conn == null)) {
        return null;
    }/*from ww w  .jav a  2s  .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:ArrayDictionary.java

/**
 * Create an ArrayDictionary, contructing the arrays of keys and
 * values from the two given vectors./*  w w w  .jav a2  s . c om*/
 * The two vectors should have the same size.
 * @param keys the vector of keys
 * @param values the vector of values
 * @param incr the increment for growing the arrays
 */
public ArrayDictionary(Vector keys, Vector values, int incr) {
    this.incr = incr;
    nelems = keys.size();
    this.keys = new Object[nelems];
    this.values = new Object[nelems];
    keys.copyInto(this.keys);
    values.copyInto(this.values);
}

From source file:edu.caltechUcla.sselCassel.projects.jMarkets.server.control.UpdateServ.java

/** Called by implementation of this class to directly add an update to the queue of the
 *  given client. Returns -1 if the operation failed. Ohterwise returns the new size of
 *  the queue *///from w w  w.  j av  a2  s. co m
protected int enqueueUpdate(int dbId, Response update) {
    Integer clientInt = new Integer(dbId);

    if (!updateQueues.containsKey(clientInt)) {
        log.warn("Cannot enqueue update for client " + dbId + " -- this client is not in any session!");
        return -1;
    }

    Vector queue = (Vector) updateQueues.get(clientInt);
    queue.add(update);

    return queue.size();
}

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  w w w . java 2s  .  c  o 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;
}