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.bluexml.xforms.demo.Util.java

public static Set<Vector<String>> getToDoTasks(String alfrescohost, String user) {
    Set<Vector<String>> result = new HashSet<Vector<String>>();
    try {/* w ww. ja  v  a2  s . com*/
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        // the mapping.xml file is private to the controller. Better use the API.
        // Document mappingDocument = builder.parse(mapping);

        PostMethod post = new PostMethod(alfrescohost + "service/xforms/workflow");
        post.setParameter("username", user);
        post.setParameter("method", "getAssignedTasks");
        post.setParameter("arg0", user);
        post.setParameter("arg1", "IN_PROGRESS");
        HttpClient client = new HttpClient();
        client.executeMethod(post);

        Document document = builder.parse(new ByteArrayInputStream(
                ("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + post.getResponseBodyAsString()).getBytes()));

        Node root = document.getDocumentElement();
        root = findNode(root.getChildNodes(), "list");

        for (int i = 0; i < root.getChildNodes().getLength(); i++) {
            Node n = root.getChildNodes().item(i);
            if (n.getNodeType() == Element.ELEMENT_NODE) {
                Vector<String> v = new Vector<String>();
                String instanceId = findNode(
                        findNode(findNode(n.getChildNodes(), "path").getChildNodes(), "instance")
                                .getChildNodes(),
                        "id").getTextContent();
                String taskId = findNode(n.getChildNodes(), "id").getTextContent();
                v.add(taskId);
                v.add(findNode(n.getChildNodes(), "title").getTextContent());
                v.add(findNode(n.getChildNodes(), "description").getTextContent());
                String name = findNode(n.getChildNodes(), "name").getTextContent();
                v.add(getFormName(name));
                v.add(getContentId(alfrescohost, user, taskId));
                v.add(instanceId);

                result.add(v);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}

From source file:Main.java

public Enumeration keys() {
    Enumeration keysEnum = super.keys();
    Vector<String> keyList = new Vector<String>();
    while (keysEnum.hasMoreElements()) {
        keyList.add((String) keysEnum.nextElement());
    }/*  w  ww.  j a  v a2 s .  c o  m*/
    Collections.sort(keyList);
    return keyList.elements();
}

From source file:com.bluexml.xforms.demo.Util.java

public static Collection<? extends Vector<String>> showAvailableContent(String alfrescohost, String user,
        String password, String taskId) throws Exception {
    Set<Vector<String>> result = new HashSet<Vector<String>>();

    PostMethod post = new PostMethod(alfrescohost + "service/xforms/workflow");
    post.setParameter("username", user);
    post.setParameter("method", "getPackageContents");
    post.setParameter("arg0", taskId);
    HttpClient client = new HttpClient();
    client.executeMethod(post);//from  w  ww  . j ava 2 s  . co  m

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(post.getResponseBodyAsStream());
    Node root = document.getDocumentElement();

    for (int i = 0; i < root.getChildNodes().getLength(); i++) {
        Node n = root.getChildNodes().item(i);
        if (n.getNodeType() == Element.ELEMENT_NODE) {
            String protocol = findNode(findNode(n.getChildNodes(), "storeRef").getChildNodes(), "protocol")
                    .getTextContent();
            String workspace = findNode(findNode(n.getChildNodes(), "storeRef").getChildNodes(), "identifier")
                    .getTextContent();
            String id = findNode(n.getChildNodes(), "id").getTextContent();

            String url = alfrescohost + "service/api/node/" + protocol + "/" + workspace + "/" + id;
            GetMethod get = new GetMethod(url);
            client = new HttpClient();
            UsernamePasswordCredentials upc = new UsernamePasswordCredentials(user, password);
            client.getState().setCredentials(AuthScope.ANY, upc);
            get.setDoAuthentication(true);
            client.executeMethod(get);
            document = builder.parse(get.getResponseBodyAsStream());
            Node rootContent = document.getDocumentElement();

            Vector<String> v = new Vector<String>();
            String downloadUrl = findNode(rootContent.getChildNodes(), "content").getAttributes()
                    .getNamedItem("src").getNodeValue();
            String title = findNode(rootContent.getChildNodes(), "title").getTextContent();
            String icon = findNode(rootContent.getChildNodes(), "alf:icon").getTextContent();
            v.add(title);
            v.add(downloadUrl);
            v.add(icon);
            result.add(v);
        }
    }

    return result;
}

From source file:Main.java

public ListRenderingFrame() {
    setTitle("ListRendering");
    setSize(400, 300);// w ww .j ava2s  . c o  m
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });

    Vector fonts = new Vector();
    fonts.add(new Font("Serif", Font.PLAIN, 8));
    fonts.add(new Font("SansSerif", Font.BOLD, 12));
    fonts.add(new Font("Monospaced", Font.PLAIN, 16));
    fonts.add(new Font("Dialog", Font.ITALIC, 12));
    fonts.add(new Font("DialogInput", Font.PLAIN, 12));
    JList fontList = new JList(fonts);
    fontList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    fontList.setCellRenderer(new FontCellRenderer());
    JScrollPane scrollPane = new JScrollPane(fontList);

    JPanel p = new JPanel();
    p.add(scrollPane);
    fontList.addListSelectionListener(this);

    getContentPane().add(p, "Center");

    getContentPane().add(label, "South");
}

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

/**
 * Sets up a set of ClusterObjects and a set of Clusters from two Image masks, one labeled with individual objects, and one labeled with all objects in a single cluster grouped with a single label.
 *
 * @param labeledByObject       An Image mask with all objects in the Image labeled with an unique greylevel value.  These labels must start with 1 and be consecutive.
 * @param labeledByCluster      An Image mask with all the objects in each cluster labeled with the same unique greylevel value.  These labels must start with 1 and be consecutive.
 * @param clusterObjects        A Vector of ClusterObjects that will contain the initialized ClusterObjects on return; this can be empty, and any contents will be erased.
 * @param clusters              A Vector of Clusters that will contain the initialized Clusters on return; this can be empty, and any contents will be erased.
 * @param k                     The number of clusters in the Image.  This must be the same as the number of unique nonzero greylevels in the labeledByCluster Image.
 * @return                      The number of ClusterObjects in the Image.
 *///w w w . j a v  a 2 s . com
public static int initializeObjectsAndClustersFromClusterImage(Image labeledByObject, Image labeledByCluster,
        Vector<ClusterObject> clusterObjects, Vector<Cluster> clusters, int k) {

    clusters.clear();

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

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

    }

    Histogram h = new Histogram(labeledByObject);

    int 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 : labeledByObject) {

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

            int value = (int) (labeledByObject.getValue(i));

            clusterObjects.get(value - 1).incrementnPixels();
            clusterObjects.get(value - 1).setCentroid(
                    clusterObjects.get(value - 1).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()));
    }

    for (ImageCoordinate i : labeledByObject) {

        int clusterValue = (int) labeledByCluster.getValue(i);
        int objectValue = (int) labeledByObject.getValue(i);
        if (clusterValue == 0 || objectValue == 0) {
            continue;
        }

        clusters.get(clusterValue - 1).getObjectSet().add(clusterObjects.get(objectValue - 1));

    }

    for (Cluster c : clusters) {

        int objectCounter = 0;

        c.setCentroidComponents(0, 0, 0);

        for (ClusterObject co : c.getObjectSet()) {

            objectCounter++;
            co.setCurrentCluster(c);

            c.setCentroid(c.getCentroid().add(co.getCentroid()));

        }

        c.setCentroid(c.getCentroid().scalarMultiply(1.0 / objectCounter));

    }

    return n;

}

From source file:DomUtils.java

/**
 * Copy the nodes of a NodeList into the supplied list.
 * <p/>//w  ww.  j  a  va  2s.c o  m
 * This is not a clone.  It's just a copy of the node references.
 * <p/>
 * Allows iteration over the Nodelist using the copy in the knowledge that
 * the list will remain the same length.  Using the NodeList can result in problems
 * because elements can get removed from the list while we're iterating over it.
 * @param nodeList Nodelist to copy.
 * @return List copy.
 */
public static List copyNodeList(NodeList nodeList) {
    Vector copy = new Vector();

    if (nodeList != null) {
        int nodeCount = nodeList.getLength();

        for (int i = 0; i < nodeCount; i++) {
            copy.add(nodeList.item(i));
        }
    }

    return copy;
}

From source file:de.mpg.escidoc.services.common.util.Util.java

/**
 * Merges a Vector of Format[] into Format[].
 * @param allFormatsV as Format[] Vector
 * @return Format[]/*from  w w  w. j  av  a2s.co m*/
 */
public static Format[] mergeFormats(Vector<Format[]> allFormatsV) {
    Vector<Format> tmpV = new Vector<Format>();
    Format[] tmpA;

    for (int i = 0; i < allFormatsV.size(); i++) {
        tmpA = allFormatsV.get(i);
        if (tmpA != null) {
            for (int x = 0; x < tmpA.length; x++) {
                tmpV.add(tmpA[x]);
                //System.out.println(tmpA[x].getName());
            }
        }
    }
    tmpV = getRidOfDuplicatesInVector(tmpV);
    return formatVectorToFormatArray(tmpV);
}

From source file:io.jjcastillo.bconferencia.model.Auditorio.java

public Vector getConferenciasVector() {
    Vector v = new Vector();
    for (Conferencia c : conferencias) {
        Vector v1 = new Vector();
        v1.add(c.getNombre());
        v1.add(HelperUtil.formatDate(c.getFechaInicio()));
        v1.add(HelperUtil.formatDate(c.getFechaFin()));
        v1.add(HelperUtil.PrettifyDateDiff(c.getFechaFin().getTime() - c.getFechaInicio().getTime()));
        v.add(v1);//from  www .ja v  a  2s. co  m
    }
    return v;
}

From source file:gda.device.scannable.ScannableUtils.java

/**
 * @param scannables/*from w  w  w  .  j  a v a2  s  .c o m*/
 * @return list of Names from the provided list of scannables/detectors
 */
public static List<String> getScannableNames(List<? extends Scannable> scannables) {
    Vector<String> names = new Vector<String>();
    if (scannables != null) {
        for (Scannable s : scannables) {
            names.add(s.getName());
        }
    }
    return names;

}

From source file:it.eng.spagobi.analiticalmodel.document.service.DetailBIObjectModule.java

/**
 * Controls if there are some BIObjectParameter objects that depend by the BIObjectParameter object
 * at input, given its id./*from w w w .  jav  a2 s . co  m*/
 * 
 * @param objParFatherId The id of the BIObjectParameter object to check
 * @throws EMFUserError
 */
public static EMFValidationError checkForDependancies(Integer objParFatherId) throws EMFUserError {
    EMFValidationError error = null;
    IObjParuseDAO objParuseDAO = DAOFactory.getObjParuseDAO();
    List objParametersCorrelated = objParuseDAO.getDependencies(objParFatherId);
    if (objParametersCorrelated != null && objParametersCorrelated.size() > 0) {
        HashMap params = new HashMap();
        params.put(AdmintoolsConstants.PAGE, DetailBIObjectModule.MODULE_PAGE);
        Vector v = new Vector();
        v.add(objParametersCorrelated.toString());
        error = new EMFValidationError(EMFErrorSeverity.ERROR, 1049, v, params);
    }
    return error;
}