Example usage for java.util Vector addElement

List of usage examples for java.util Vector addElement

Introduction

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

Prototype

public synchronized void addElement(E obj) 

Source Link

Document

Adds the specified component to the end of this vector, increasing its size by one.

Usage

From source file:edu.indiana.lib.osid.base.repository.http.RepositoryManager.java

private java.util.Vector asVector(Object value) {
    java.util.Vector vector = new java.util.Vector(1);

    vector.addElement(value);
    return vector;
}

From source file:com.globalsight.everest.webapp.applet.admin.customer.FileSystemApplet.java

/**
 * Prepare the info for the upload process and zip all the files.
 *///from  w w w.j  a  v a 2s  .c  o m
private void performUploadProcess(String servletLocation, String targetLocation, String randID,
        Vector p_outgoingData) {
    try {
        m_progressBar.setValue(10);
        getParentFrame().setCursor(Cursor.WAIT_CURSOR);
        String lineRead = null;
        String result = null;

        Vector outgoingData = new Vector();
        outgoingData.addElement(p_outgoingData);
        outgoingData.addElement(randID);

        Object[] objs = (Object[]) p_outgoingData.get(0);
        int size = objs == null ? 0 : objs.length;
        File[] files = new File[size];
        System.arraycopy(objs, 0, files, 0, size);
        m_progressBar.setValue(20);
        sendZipFile(files, servletLocation, targetLocation);
    } catch (Exception ioe) //IOException, ClassNotFoundException
    {
        System.err.println(ioe);
        AppletHelper.getErrorDlg(ioe.getMessage(), null);
    } finally {
        getParentFrame().setCursor(Cursor.DEFAULT_CURSOR);
    }
}

From source file:com.yahoo.messenger.data.notification.json.ResponseList.java

public void unserializeJSON(JSONArray a) throws JSONException {

    Vector v = new Vector();

    //  Mandatory fields

    for (int i = 0; i < a.length(); i++) {

        JSONObject o = a.getJSONObject(i);

        if (o.has("message")) {
            Message c = new Message();
            c.unserializeJSON(o.getJSONObject("message"));
            v.addElement(c);
        }/*from   w ww  . j  a v a  2s  . co m*/
        if (o.has("buddyInfo")) {
            BuddyInfo c = new BuddyInfo();
            c.unserializeJSON(o.getJSONObject("buddyInfo"));
            v.addElement(c);
        }
    }

    responses = new Response[v.size()];
    v.copyInto(responses);

}

From source file:IDlook.java

private void loadAccounts() {
    Vector v = new Vector();
    try {//  w ww .java 2  s  . c  om
        rs = statement.executeQuery("SELECT * FROM thumbnail");

        while (rs.next()) {
            v.addElement(rs.getString("acc_id"));
        }
    } catch (SQLException e) {
        displaySQLErrors(e);
    }
    accountNumberList.setListData(v);
}

From source file:org.apache.jasper.compiler.JspUtil.java

/**
 * Checks if all mandatory attributes are present and if all attributes
 * present have valid names.  Checks attributes specified as XML-style
 * attributes as well as attributes specified using the jsp:attribute
 * standard action. /*from  www.j  av a2 s .c  o m*/
 */
public static void checkAttributes(String typeOfTag, Node n, ValidAttribute[] validAttributes,
        ErrorDispatcher err) throws JasperException {
    Attributes attrs = n.getAttributes();
    Mark start = n.getStart();
    boolean valid = true;

    // AttributesImpl.removeAttribute is broken, so we do this...
    int tempLength = (attrs == null) ? 0 : attrs.getLength();
    Vector temp = new Vector(tempLength, 1);
    for (int i = 0; i < tempLength; i++) {
        String qName = attrs.getQName(i);
        if ((!qName.equals("xmlns")) && (!qName.startsWith("xmlns:")))
            temp.addElement(qName);
    }

    // Add names of attributes specified using jsp:attribute
    Node.Nodes tagBody = n.getBody();
    if (tagBody != null) {
        int numSubElements = tagBody.size();
        for (int i = 0; i < numSubElements; i++) {
            Node node = tagBody.getNode(i);
            if (node instanceof Node.NamedAttribute) {
                String attrName = node.getAttributeValue("name");
                temp.addElement(attrName);
                // Check if this value appear in the attribute of the node
                if (n.getAttributeValue(attrName) != null) {
                    err.jspError(n, "jsp.error.duplicate.name.jspattribute", attrName);
                }
            } else {
                // Nothing can come before jsp:attribute, and only
                // jsp:body can come after it.
                break;
            }
        }
    }

    /*
     * First check to see if all the mandatory attributes are present.
     * If so only then proceed to see if the other attributes are valid
     * for the particular tag.
     */
    String missingAttribute = null;

    for (int i = 0; i < validAttributes.length; i++) {
        int attrPos;
        if (validAttributes[i].mandatory) {
            attrPos = temp.indexOf(validAttributes[i].name);
            if (attrPos != -1) {
                temp.remove(attrPos);
                valid = true;
            } else {
                valid = false;
                missingAttribute = validAttributes[i].name;
                break;
            }
        }
    }

    // If mandatory attribute is missing then the exception is thrown
    if (!valid)
        err.jspError(start, "jsp.error.mandatory.attribute", typeOfTag, missingAttribute);

    // Check to see if there are any more attributes for the specified tag.
    int attrLeftLength = temp.size();
    if (attrLeftLength == 0)
        return;

    // Now check to see if the rest of the attributes are valid too.
    String attribute = null;

    for (int j = 0; j < attrLeftLength; j++) {
        valid = false;
        attribute = (String) temp.elementAt(j);
        for (int i = 0; i < validAttributes.length; i++) {
            if (attribute.equals(validAttributes[i].name)) {
                valid = true;
                break;
            }
        }
        if (!valid)
            err.jspError(start, "jsp.error.invalid.attribute", typeOfTag, attribute);
    }
    // XXX *could* move EL-syntax validation here... (sb)
}

From source file:edu.indiana.lib.osid.base.repository.http.RepositoryManager.java

public org.osid.shared.TypeIterator getRepositoryTypes() throws org.osid.repository.RepositoryException {
    java.util.Vector results = new java.util.Vector();
    try {/*from w ww . j  a  v a  2  s .  com*/
        results.addElement(new Type("sakaibrary", "repository", "metasearch"));
        return new TypeIterator(results);
    } catch (Throwable t) {
        _log.error(t.getMessage());
        throw new org.osid.repository.RepositoryException(org.osid.OsidException.OPERATION_FAILED);
    }
}

From source file:org.apache.catalina.cluster.tcp.ReplicationTransmitter.java

public IDataSender[] getSenders() {
    java.util.Iterator i = map.entrySet().iterator();
    java.util.Vector v = new java.util.Vector();
    while (i.hasNext()) {
        IDataSender sender = (IDataSender) ((java.util.Map.Entry) i.next()).getValue();
        if (sender != null)
            v.addElement(sender);
    }/*from  w w  w  . j  a v  a2s  .c o m*/
    IDataSender[] result = new IDataSender[v.size()];
    v.copyInto(result);
    return result;
}

From source file:com.legstar.cob2xsd.Cob2XsdTaskTest.java

/**
 * Execute an ant script./*from w  w w .  ja v a2  s  .co m*/
 * 
 * @param buildFile the ant script
 * @throws Exception if ant script execution fails
 */
protected void runAnt(final File buildFile) throws Exception {
    final Project project = new Project();
    project.addBuildListener(new TestLogger());
    project.setCoreLoader(this.getClass().getClassLoader());
    project.init();
    ProjectHelper helper = ProjectHelper.getProjectHelper();
    project.addReference("ant.projectHelper", helper);
    helper.parse(project, buildFile);
    Vector<String> targets = new Vector<String>();
    targets.addElement(project.getDefaultTarget());
    project.executeTargets(targets);
}

From source file:Accounts.java

private void loadAccounts() {
    Vector v = new Vector();
    try {//from   w w  w.  j a  v a2 s .c o m
        Statement statement = connection.createStatement();
        ResultSet rs = statement.executeQuery("SELECT acc_id FROM acc_acc");

        while (rs.next()) {
            v.addElement(rs.getString("acc_id"));
        }
        rs.close();
    } catch (SQLException e) {
        displaySQLErrors(e);
    }
    accountNumberList.setListData(v);
}

From source file:com.legstar.coxb.gen.CoxbGenModelTest.java

/**
 * Execute an ant script./* www  . java  2 s.c  o m*/
 * 
 * @param buildFile the ant script
 * @throws Exception if ant script execution fails
 */
protected void runAnt(final File buildFile) throws Exception {
    final Project project = new Project();
    project.setCoreLoader(this.getClass().getClassLoader());
    project.init();
    ProjectHelper helper = ProjectHelper.getProjectHelper();
    project.addReference("ant.projectHelper", helper);
    helper.parse(project, buildFile);
    Vector<String> targets = new Vector<String>();
    targets.addElement(project.getDefaultTarget());
    project.setBaseDir(new File("."));
    project.executeTargets(targets);
}