Example usage for java.util Vector add

List of usage examples for java.util Vector add

Introduction

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

Prototype

public synchronized boolean add(E e) 

Source Link

Document

Appends the specified element to the end of this Vector.

Usage

From source file:com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.java

/**
 * Transforms the Collection of SystemUnderTests into a Vector of SystemUnderTests parameters.
 * </p>//  w ww  . j  a v  a 2 s .  c  o m
 *
 * @param suts a {@link java.util.Collection} object.
 * @return the Collection of SystemUnderTests into a Vector of SystemUnderTests parameters
 */
public static Vector<Object> toXmlRpcSystemUnderTestsParameters(Collection<SystemUnderTest> suts) {
    Vector<Object> sutsParams = new Vector<Object>();
    for (SystemUnderTest sut : suts) {
        sutsParams.add(sut.marshallize());
    }

    return sutsParams;
}

From source file:com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.java

/**
 * Transforms the Collection of projects into a Vector of project parameters.
 * </p>//from   w  w w.j a va  2 s.com
 *
 * @param projects a {@link java.util.Collection} object.
 * @return the Collection of projects into a Vector of projects parameters
 */
public static Vector<Object> toXmlRpcProjectsParameters(Collection<Project> projects) {
    Vector<Object> projectsParams = new Vector<Object>();
    for (Project project : projects) {
        projectsParams.add(project.marshallize());
    }

    return projectsParams;
}

From source file:com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.java

/**
 * Transforms the Collection of EnvironmentTypes into a Vector of EnvironmentTypes parameters.
 * </p>//  w ww  .j a  v  a2 s . c o m
 *
 * @param envTypes a {@link java.util.Collection} object.
 * @return the Collection of EnvironmentTypes into a Vector of EnvironmentTypes parameters
 */
public static Vector<Object> toXmlRpcEnvironmentTypesParameters(Collection<EnvironmentType> envTypes) {
    Vector<Object> envTypesParams = new Vector<Object>();
    for (EnvironmentType envType : envTypes) {
        envTypesParams.add(envType.marshallize());
    }

    return envTypesParams;
}

From source file:com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.java

/**
 * Transforms the Collection of Repositories into a Vector of Repositories parameters
 * by repositoriy types.//from ww w .ja  va2s  .c om
 * </p>
 *
 * @param repositories a {@link java.util.Collection} object.
 * @return the Collection of Repositories into a Vecotr of Repositories parameters by type.
 */
public static Vector<Object> toXmlRpcRepositoriesParameters(Collection<Repository> repositories) {
    Vector<Object> repositoriesParams = new Vector<Object>();
    for (Repository repo : repositories) {
        repositoriesParams.add(repo.marshallize());
    }

    return repositoriesParams;
}

From source file:com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.java

/**
 * Transforms the Collection of References into a Vector of Reference parameters.
 * </p>/*w  w w .  j  ava2s . c  o  m*/
 *
 * @param references a {@link java.util.Collection} object.
 * @return the Collection of References into a Vector of Reference parameters
 */
public static Vector<Object> toXmlRpcReferencesParameters(Collection<Reference> references) {
    Vector<Object> referencesParams = new Vector<Object>();
    for (Reference reference : references) {
        referencesParams.add(reference.marshallize());
    }

    return referencesParams;
}

From source file:gda.configuration.properties.LocalProperties.java

/**
 * @param s//  www.  j a  v  a  2s .com
 * @return list of integers from a csv string e.g. 1,2 yields [1,2] returns null if property
 */
public static List<Integer> stringToIntList(String s) {
    if (s == null)
        return null;
    Vector<Integer> ints = new Vector<Integer>();
    String[] parts = s.split("[:, \t\r\n]");
    for (String part : parts) {
        if (!part.isEmpty())
            ints.add(Integer.valueOf(part));
    }
    return ints;
}

From source file:GeometryUtilities.java

public static Vector<Point2D> getCrossings(Line2D line0, Line2D line1) {
    Vector<Point2D> ret = new Vector<Point2D>();

    if (line0.intersectsLine(line1)) {
        Point2D.Double intersection = new Point2D.Double(0.0, 0.0);

        double xDiff0 = line0.getX2() - line0.getX1();
        double xDiff1 = line1.getX2() - line1.getX1();
        double yDiff0 = line0.getY2() - line0.getY1();
        double yDiff1 = line1.getY2() - line1.getY1();
        double xDiff2 = line0.getX1() - line1.getX1();
        double yDiff2 = line0.getY1() - line1.getY1();

        double div = yDiff1 * xDiff0 - xDiff1 * yDiff0;
        double u = (xDiff1 * yDiff2 - yDiff1 * xDiff2) / div;
        intersection.x = line0.getX1() + u * xDiff0;
        intersection.y = line0.getY1() + u * yDiff0;

        ret.add(intersection);
    }//ww w. j  a v a  2s  . co m

    return ret;
}

From source file:com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.java

/**
 * Transforms the Collection of Specifications into a Vector of Specification parameters.
 * </p>//from w  ww. ja v  a  2s . c  om
 *
 * @param specifications a {@link java.util.Collection} object.
 * @return the Collection of Specifications into a Vector of Specification parameters
 */
public static Vector<Object> toXmlRpcSpecificationsParameters(Collection<Specification> specifications) {
    Vector<Object> specificationsParams = new Vector<Object>();
    for (Specification specification : specifications) {
        specificationsParams.add(specification.marshallize());
    }

    return specificationsParams;
}

From source file:edu.umn.cs.spatialHadoop.operations.Indexer.java

/***
 * Create a partitioner for a particular job
 * @param in/*from   w  ww. ja v  a 2s .c  om*/
 * @param out
 * @param job
 * @param partitionerName
 * @return
 * @throws IOException
 */
public static Partitioner createPartitioner(Path[] ins, Path out, Configuration job, String partitionerName)
        throws IOException {
    try {
        Partitioner partitioner = null;
        Class<? extends Partitioner> partitionerClass = PartitionerClasses.get(partitionerName.toLowerCase());
        if (partitionerClass == null) {
            throw new RuntimeException("Unknown index type '" + partitionerName + "'");
        }
        boolean replicate = PartitionerReplicate.get(partitionerName.toLowerCase());
        job.setBoolean("replicate", replicate);
        partitioner = partitionerClass.newInstance();

        long t1 = System.currentTimeMillis();
        final Rectangle inMBR = (Rectangle) OperationsParams.getShape(job, "mbr");
        // Determine number of partitions
        long inSize = 0;
        for (Path in : ins) {
            inSize += FileUtil.getPathSize(in.getFileSystem(job), in);
        }
        long estimatedOutSize = (long) (inSize * (1.0 + job.getFloat(SpatialSite.INDEXING_OVERHEAD, 0.1f)));
        FileSystem outFS = out.getFileSystem(job);
        long outBlockSize = outFS.getDefaultBlockSize(out);
        int numPartitions = Math.max(1, (int) Math.ceil((float) estimatedOutSize / outBlockSize));
        LOG.info("Partitioning the space into " + numPartitions + " partitions");

        final Vector<Point> sample = new Vector<Point>();
        float sample_ratio = job.getFloat(SpatialSite.SAMPLE_RATIO, 0.01f);
        long sample_size = job.getLong(SpatialSite.SAMPLE_SIZE, 100 * 1024 * 1024);

        LOG.info("Reading a sample of " + (int) Math.round(sample_ratio * 100) + "%");
        ResultCollector<Point> resultCollector = new ResultCollector<Point>() {
            @Override
            public void collect(Point p) {
                sample.add(p.clone());
            }
        };
        OperationsParams params2 = new OperationsParams(job);
        params2.setFloat("ratio", sample_ratio);
        params2.setLong("size", sample_size);
        params2.setClass("outshape", Point.class, Shape.class);
        Sampler.sample(ins, resultCollector, params2);
        long t2 = System.currentTimeMillis();
        System.out.println("Total time for sampling in millis: " + (t2 - t1));
        LOG.info("Finished reading a sample of " + sample.size() + " records");

        partitioner.createFromPoints(inMBR, sample.toArray(new Point[sample.size()]), numPartitions);

        return partitioner;
    } catch (InstantiationException e) {
        e.printStackTrace();
        return null;
    } catch (IllegalAccessException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:kenh.expl.impl.ExpLParser.java

/**
 * Get the parameters for function, use ',' to split each parameter.
 * @param parameter/*w ww  . j a va  2  s  . c o  m*/
 * @return
 */
private static String[] splitParameter(String parameter) throws UnsupportedExpressionException {
    Vector<String> params = new Vector();

    StringBuffer param = new StringBuffer();
    int count = 0;
    for (int scan = 0; scan < parameter.length(); scan++) {
        char c = parameter.charAt(scan);

        if (c == ',') {
            if (count > 0) {
                param.append(c);
            } else {
                params.add(param.toString());
                param = new StringBuffer();
            }
        } else if (c == '{') {
            count++;
            param.append(c);
        } else if (c == '}') {
            count--;
            param.append(c);
            if (count < 0) {
                UnsupportedExpressionException e = new UnsupportedExpressionException("Missing '{'.");
                e.push(parameter);
                throw e;
            }
        } else {
            param.append(c);
        }
    }

    if (count > 0) {
        UnsupportedExpressionException e = new UnsupportedExpressionException("Missing '}'.");
        e.push(parameter);
        throw e;
    }

    String lastParam = param.toString();

    if (params.size() == 0 && lastParam.equals("")) {
        // '()' only, mean no parameter
    } else {
        params.add(lastParam);
    }

    return params.toArray(new String[] {});
}