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.comcast.cmb.test.tools.CNSTestingUtils.java

public static Vector<String> getQueueUrlfromList(String response) {
    Vector<String> res = new Vector<String>();
    int beginLoc = response.indexOf("<QueueUrl>");
    int endLoc = response.indexOf("</QueueUrl>");
    while (beginLoc != -1) {
        res.add(response.substring(beginLoc + 10, endLoc));
        beginLoc = response.indexOf("<QueueUrl>", endLoc);
        if (beginLoc == -1)
            break;
        endLoc = response.indexOf("</QueueUrl>", beginLoc);
    }/*from w w w.j av  a 2  s .  c  om*/
    return res;
}

From source file:de.betterform.connector.xmlrpc.XMLRPCSubmissionHandler.java

/**
 * Parses the URI into three elements.//from  w  w  w  .  j  a  va  2s  .c om
 * The xmlrpc URL, the function and the params
 *
 * @return a Vector
 */
private Vector parseURI(URI uri) {
    String host = uri.getHost();
    int port = uri.getPort();
    String path = uri.getPath();
    String query = uri.getQuery();

    /* Split the path up into basePath and function */
    int finalSlash = path.lastIndexOf('/');
    String basePath = "";
    if (finalSlash > 0) {
        basePath = path.substring(1, finalSlash);
    }
    String function = path.substring(finalSlash + 1, path.length());

    String rpcURL = "http://" + host + ":" + port + "/" + basePath;

    log.debug("New URL  = " + rpcURL);
    log.debug("Function = " + function);

    Hashtable paramHash = new Hashtable();

    if (query != null) {
        String[] params = query.split("&");

        for (int i = 0; i < params.length; i++) {
            log.debug("params[" + i + "] = " + params[i]);

            String[] keyval = params[i].split("=");

            log.debug("\t" + keyval[0] + " -> " + keyval[1]);

            paramHash.put(keyval[0], keyval[1]);
        }
    }

    Vector ret = new Vector();
    ret.add(rpcURL);
    ret.add(function);
    ret.add(paramHash);
    return ret;
}

From source file:edu.stanford.cfuller.imageanalysistools.clustering.ObjectClustering.java

/**
 * Sets up a set of ClusterObjects and a set of Clusters from an Image mask with each object labeled with a unique greylevel.
 *
 * @param im                The Image mask with each cluster object labeled with a unique greylevel.  These must start at 1 and be consecutive.
 * @param clusterObjects    A Vector of ClusterObjects that will contain the initialized ClusterObjects on return; this may be empty, and any contents will be erased.
 * @param clusters          A Vector of Clusters that will contain the initialized Clusters on return; this may be empty, and any contents will be erased.
 * @param k                 The number of Clusters to generate.
 * @return                  The number of ClusterObjects in the Image.
 *//*from   www .  j  a  va 2s  .co m*/
public static int initializeObjectsAndClustersFromImage(Image im, Vector<ClusterObject> clusterObjects,
        Vector<Cluster> clusters, int k) {

    int n = 0;

    clusters.clear();

    for (int j = 0; j < k; j++) {

        clusters.add(new Cluster());
        clusters.get(j).setID(j + 1);

    }

    Histogram h = new Histogram(im);

    n = h.getMaxValue();

    clusterObjects.clear();

    for (int j = 0; j < n; j++) {

        clusterObjects.add(new ClusterObject());

        clusterObjects.get(j).setCentroidComponents(0, 0, 0);

        clusterObjects.get(j).setnPixels(0);

    }

    for (ImageCoordinate i : im) {

        if (im.getValue(i) > 0) {

            ClusterObject current = clusterObjects.get((int) im.getValue(i) - 1);

            current.incrementnPixels();

            current.setCentroid(current.getCentroid().add(new Vector3D(i.get(ImageCoordinate.X),
                    i.get(ImageCoordinate.Y), i.get(ImageCoordinate.Z))));

        }

    }

    for (int j = 0; j < n; j++) {
        ClusterObject current = clusterObjects.get(j);
        current.setCentroid(current.getCentroid().scalarMultiply(1.0 / current.getnPixels()));
    }

    //initialize clusters using kmeans++ strategy

    double[] probs = new double[n];
    double[] cumulativeProbs = new double[n];

    java.util.Arrays.fill(probs, 0);
    java.util.Arrays.fill(cumulativeProbs, 0);

    //choose the initial cluster

    int initialClusterObject = (int) Math.floor(n * RandomGenerator.rand());

    clusters.get(0).setCentroid(clusterObjects.get(initialClusterObject).getCentroid());

    clusters.get(0).getObjectSet().add(clusterObjects.get(initialClusterObject));

    for (int j = 0; j < n; j++) {

        clusterObjects.get(j).setCurrentCluster(clusters.get(0));
    }

    //assign the remainder of the clusters

    for (int j = 1; j < k; j++) {

        double probSum = 0;

        for (int m = 0; m < n; m++) {
            double minDist = Double.MAX_VALUE;

            Cluster bestCluster = null;

            for (int p = 0; p < j; p++) {

                double tempDist = clusterObjects.get(m).distanceTo(clusters.get(p));

                if (tempDist < minDist) {
                    minDist = tempDist;

                    bestCluster = clusters.get(p);
                }

            }

            probs[m] = minDist;
            probSum += minDist;

            clusterObjects.get(m).setCurrentCluster(bestCluster);
        }

        for (int m = 0; m < n; m++) {
            probs[m] = probs[m] / probSum;
            if (m == 0) {
                cumulativeProbs[m] = probs[m];
            } else {
                cumulativeProbs[m] = cumulativeProbs[m - 1] + probs[m];
            }
        }
        double randNum = RandomGenerator.rand();
        int nextCenter = 0;

        for (int m = 0; m < n; m++) {
            if (randNum < cumulativeProbs[m]) {
                nextCenter = m;
                break;
            }
        }

        clusters.get(j).setCentroid(clusterObjects.get(nextCenter).getCentroid());

    }

    for (int m = 0; m < n; m++) {

        double minDist = Double.MAX_VALUE;

        Cluster bestCluster = null;

        for (int p = 0; p < k; p++) {

            double tempDist = clusterObjects.get(m).distanceTo(clusters.get(p));

            if (tempDist < minDist) {

                minDist = tempDist;
                bestCluster = clusters.get(p);
            }
        }

        clusterObjects.get(m).setCurrentCluster(bestCluster);
        bestCluster.getObjectSet().add(clusterObjects.get(m));

    }

    return n;
}

From source file:Mopex.java

/**
 * Returns a Method array of the methods to which instances of the specified
 * respond except for those methods defined in the class specifed by limit
 * or any of its superclasses. Note that limit is usually used to eliminate
 * them methods defined by java.lang.Object.
 * /*from  ww w  . j a v a2s . c  om*/
 * @return Method[]
 * @param cls
 *            java.lang.Class
 * @param limit
 *            java.lang.Class
 */
//start extract getSupportedMethods
public static Method[] getSupportedMethods(Class cls, Class limit) {
    Vector supportedMethods = new Vector();
    for (Class c = cls; c != limit; c = c.getSuperclass()) {
        Method[] methods = c.getDeclaredMethods();
        for (int i = 0; i < methods.length; i++) {
            boolean found = false;
            for (int j = 0; j < supportedMethods.size(); j++)
                if (equalSignatures(methods[i], (Method) supportedMethods.elementAt(j))) {
                    found = true;
                    break;
                }
            if (!found)
                supportedMethods.add(methods[i]);
        }
    }
    Method[] mArray = new Method[supportedMethods.size()];
    for (int k = 0; k < mArray.length; k++)
        mArray[k] = (Method) supportedMethods.elementAt(k);
    return mArray;
}

From source file:controller.FeedbackControllerManager.java

@RequestMapping(method = RequestMethod.GET)
public String feedbackManager(ModelMap mm) {
    Vector data = new Vector();
    Vector column = new Vector();
    List<Feedback> list = feedModel.getAll();
    column.add("Feedback ID");
    column.add("Customer");
    column.add("Title");
    column.add("Content");
    column.add("Feedback Date");
    column.add("Reply");
    column.add("Status");
    for (Feedback feed : list) {
        Vector tmp = new Vector();
        tmp.add(feed.getFeedId());//from   www. j  a  v a  2 s . co  m
        tmp.add(feed.getCustomer().getCusName());
        tmp.add("id://" + feed.getFeedId());
        tmp.add(feed.getFeedTitle());
        tmp.add(feed.getFeedContent());
        tmp.add(feed.getFeedDate());
        tmp.add(feed.getFeedReply());

        tmp.add(feed.getStatus() == 1 ? "Replied" : "Non-reply");
        data.add(tmp);
    }
    mm.put("column", column);
    mm.put("data", data);
    mm.put("title", "Feedback Manager");
    return "feedbackManager";
}

From source file:BeanPropertyTableModel.java

/**
 * Generate a line for the passed property.
 *
 * @param propName  Name of the property.
 * @param bean    Bean containg the property.
 * @param getter    The "getter" function to retrieve the
 *            properties value./*from  w w w  .ja va2 s.  com*/
 *
 * @return  A <CODE>Vector</CODE> containing the cells for the line in
 *      the table. Element zero the first cell etc. Return
 *      <CODE>null</CODE> if this property is <B>not</B> to be added
 *      to the table.
 */
protected Vector<Object> generateLine(String propName, Object bean, Method getter)
        throws InvocationTargetException, IllegalAccessException {
    final Vector<Object> line = new Vector<Object>();
    line.add(propName);
    line.add(executeGetter(bean, getter));
    return line;
}

From source file:controller.OrderManagerController.java

private void initData(ModelMap mm) {
    Vector data = new Vector();
    Vector column = new Vector();
    List<Order> list = orderModel.getAll();
    column.add("Order ID");
    column.add("Payment Date");
    column.add("Expired Date");
    column.add("Status");

    for (Order od : list) {
        Vector tmp = new Vector();
        tmp.add(od.getOderId());/*from   w w  w.  j  a  v a2s . c om*/
        tmp.add(od.getOrderPaymentDate());
        tmp.add(od.getOrderExpiredDate());
        tmp.add(od.getStatus() == 1 ? "Processed" : "Pending");
        tmp.add("id://" + od.getOderId());
        data.add(tmp);
    }
    mm.put("column", column);
    mm.put("data", data);
}

From source file:edu.ku.brc.specify.tasks.services.PickListUtils.java

public static List<PickList> getPickLists(final LocalizableIOIFace localizableIO, final boolean doAll,
        final boolean isSystemPL) {
    List<PickList> items = null;

    if (localizableIO != null) {
        items = localizableIO.getPickLists(null);

    } else {/*from w ww .  j  a va 2  s.co  m*/
        DataProviderSessionIFace session = null;
        try {
            session = DataProviderFactory.getInstance().createSession();

            Vector<PickList> plItems = new Vector<PickList>();

            String sysPLSQL = "";
            if (!doAll) {
                sysPLSQL = " AND isSystem = " + (isSystemPL ? 1 : 0);
            }

            String sqlStr = "FROM PickList WHERE collectionId = COLLID" + sysPLSQL;
            String sql = QueryAdjusterForDomain.getInstance().adjustSQL(sqlStr);
            List<?> pickLists = session.getDataList(sql);

            for (Object obj : pickLists) {
                PickList pl = (PickList) obj;
                pl.getPickListItems().size();
                // System.out.println(pl.getName()+" - "+pl.getPickListItems().size());
                plItems.add(pl);
            }
            items = plItems;
        } catch (Exception ex) {
            ex.printStackTrace();
            edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(PickListEditorDlg.class, ex);

        } finally {
            if (session != null) {
                session.close();
            }
        }
    }

    java.util.Collections.sort(items);

    return items;
}

From source file:controller.ChanelManagerController.java

private void initData(ModelMap mm) {
    Vector data = new Vector();
    Vector column = new Vector();
    List<Chanel> list = chanelModel.getAll();
    column.add("ID");
    column.add("Chanel Name");
    column.add("Chanel Price");
    column.add("Content");

    for (Chanel cl : list) {
        Vector tmp = new Vector();
        tmp.add(cl.getChanelId());//from  w  w w.j a  va2s  .  c o  m
        tmp.add(cl.getChanelName());
        tmp.add(MyUtils.getCurrencyFormat().format(cl.getChanelPrice()));
        tmp.add(cl.getChanelContent());
        tmp.add("id://" + cl.getChanelId());
        data.add(tmp);
    }
    mm.put("column", column);
    mm.put("data", data);
}

From source file:hermes.browser.model.BeanTableModel.java

public BeanTableModel(Object bean, Map filter)
        throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    Map properties = PropertyUtils.describe(bean);
    Set iterSet = null;//from  w w  w  .  j av  a2s .co  m

    this.bean = bean;

    if (filter == null) {
        iterSet = properties.keySet();
    } else {
        iterSet = filter.keySet();
    }

    for (Iterator iter = iterSet.iterator(); iter.hasNext();) {
        String propertyName = (String) iter.next();

        if (properties.containsKey(propertyName) && !ignore.contains(propertyName)) {
            Object propertyValue = properties.get(propertyName);

            if (propertyValue == null) {
                propertyValue = "null";
            }

            Vector row = new Vector();

            row.add(propertyName);
            row.add(propertyValue);

            rows.add(row);
        }
    }

}