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:RSAccounts.java

private void loadAccounts() {
    Vector v = new Vector();
    try {//from ww  w .java  2 s.co  m
        rs = statement.executeQuery("SELECT * FROM acc_acc");

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

From source file:net.anidb.udp.UdpGroupStatusFactory.java

/**
 * Returns the list of the group status from the response.
 * @param animeId The anime Id./*from w  ww . ja  va  2s .c  om*/
 * @param response The response.
 * @return The list of the group status.
 * @throws UdpConnectionException If a connection problem occured.
 */
private List<GroupStatus> getGroupStatus(final Long animeId, final UdpResponse response)
        throws UdpConnectionException {

    Vector<GroupStatus> list;
    UdpResponseEntry entry;

    list = new Vector<GroupStatus>();
    for (int index = 0; index < response.getEntryCount(); index++) {
        entry = response.getEntryAt(index);
        list.addElement(this.getGroupStatus(animeId, entry));
    }
    return list;
}

From source file:org.anonymous.dobroreaderme.networking.dobrochan.DobrochanApi.java

protected BoardThread parseThread(JSONObject thread_json) throws JSONException {
    JSONArray posts = thread_json.getJSONArray("posts");

    Vector postsVector = new Vector(4);
    for (int i = 0; i < posts.length(); i++) {
        JSONObject post = posts.getJSONObject(i);
        postsVector.addElement(parsePost(post));
    }/*from   ww w.j  av  a  2s.c o m*/

    BoardThread thread = parseThreadHeader(thread_json);
    thread.setPosts(postsVector);
    return thread;
}

From source file:net.wastl.webmail.xml.XMLGenericModel.java

/**
 * We need to synchronize that because it can cause problems with multiple threads
 *//*w w w. ja  va2s .  c o  m*/
public synchronized void removeAllStateVars(String name) {
    NodeList nl = getNodeListXPath("//STATEDATA/VAR");

    if (nl != null) {
        /* This suxx: NodeList Object is changed when removing children !!!
           I will store all nodes that should be deleted in a Vector and delete them afterwards */
        int length = nl.getLength();
        Vector<Element> v = new Vector<Element>(nl.getLength());
        for (int i = 0; i < length; i++) {
            if (((Element) nl.item(i)).getAttribute("name").equals(name)) {
                v.addElement((Element) nl.item(i));
            }
        }
        Enumeration enumVar = v.elements();
        while (enumVar.hasMoreElements()) {
            Node n = (Node) enumVar.nextElement();
            statedata.removeChild(n);
        }
    }
    invalidateCache();
}

From source file:nl.nn.adapterframework.util.StringTagger.java

/**
 *  Manually sets a single value./*from   w ww.  j  ava 2  s  . c  o  m*/
 */
public void setValue(String token, String val) {
    Vector newval = new Vector();
    newval.addElement(val);
    tokens.put(token, newval);
    multitokens.put(token, newval);
}

From source file:com.instantme.model.UserEntryModel.java

public boolean fromJSONObject(JSONObject jobj, IAnimation anim) {
    boolean result = false;

    try {// w  w  w. j  a  v  a  2  s. c om
        Vector _data = new Vector();
        JSONArray feeds = jobj.getJSONArray("data");

        if (feeds != null) {
            for (int n = 0; n < feeds.length(); n++) {
                //System.out.println("User " + n);
                JSONObject entry = feeds.getJSONObject(n);
                UserEntry ue = new UserEntry();
                ue.fromJSONObject(entry, anim);
                _data.addElement(ue);
            }
        }
        data = _data;
        result = true;

    } catch (JSONException ex) {
        ex.printStackTrace();
    }

    return result;
}

From source file:Sampler.java

private void createUI() {
    setFont(new Font("Serif", Font.PLAIN, 12));
    setLayout(new BorderLayout());
    // Set our location to the left of the image frame.
    setSize(200, 350);//from  ww  w  .java 2s  .c o m
    Point pt = mImageFrame.getLocation();
    setLocation(pt.x - getSize().width, pt.y);

    final Checkbox accumulateCheckbox = new Checkbox("Accumulate", false);
    final Label statusLabel = new Label("");

    // Make a sorted list of the operators.
    Enumeration e = mOps.keys();
    Vector names = new Vector();
    while (e.hasMoreElements())
        names.addElement(e.nextElement());
    Collections.sort(names);
    final java.awt.List list = new java.awt.List();
    for (int i = 0; i < names.size(); i++)
        list.add((String) names.elementAt(i));
    add(list, BorderLayout.CENTER);

    // When an item is selected, do the corresponding transformation.
    list.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ie) {
            if (ie.getStateChange() != ItemEvent.SELECTED)
                return;
            String key = list.getSelectedItem();
            BufferedImageOp op = (BufferedImageOp) mOps.get(key);
            BufferedImage source = mSplitImageComponent.getSecondImage();
            boolean accumulate = accumulateCheckbox.getState();
            if (source == null || accumulate == false)
                source = mSplitImageComponent.getImage();
            String previous = mImageFrame.getTitle() + " + ";
            if (accumulate == false)
                previous = "";
            mImageFrame.setTitle(previous + key);
            statusLabel.setText("Performing " + key + "...");
            list.setEnabled(false);
            accumulateCheckbox.setEnabled(false);
            BufferedImage destination = op.filter(source, null);
            mSplitImageComponent.setSecondImage(destination);
            mSplitImageComponent.setSize(mSplitImageComponent.getPreferredSize());
            mImageFrame.setSize(mImageFrame.getPreferredSize());
            list.setEnabled(true);
            accumulateCheckbox.setEnabled(true);
            statusLabel.setText("Performing " + key + "...done.");
        }
    });

    Button loadButton = new Button("Load...");
    loadButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            FileDialog fd = new FileDialog(Sampler.this);
            fd.show();
            if (fd.getFile() == null)
                return;
            String path = fd.getDirectory() + fd.getFile();
            mSplitImageComponent.setImage(path);
            mSplitImageComponent.setSecondImage(null);
            //            Utilities.sizeContainerToComponent(mImageFrame,
            //               mSplitImageComponent);
            mImageFrame.validate();
            mImageFrame.repaint();
        }
    });

    Panel bottom = new Panel(new GridLayout(2, 1));
    Panel topBottom = new Panel();
    topBottom.add(accumulateCheckbox);
    topBottom.add(loadButton);
    bottom.add(topBottom);
    bottom.add(statusLabel);
    add(bottom, BorderLayout.SOUTH);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            mImageFrame.dispose();
            dispose();
            System.exit(0);
        }
    });
}

From source file:edu.umd.cfar.lamp.viper.util.StringHelp.java

/**
 * Split using a seperator.//from  w w w. j a v a 2 s.  c o  m
 *
 * @param line The String to be seperated.
 * @param sep The seperator character, eg a comma
 * @return An array of Strings containing the seperated data.
 * @see #splitBySeparatorAndParen(String line, char sep)
 */
public static String[] splitBySeparator(String line, char sep) {
    String newLine = line;
    Vector temp = new Vector();
    while (true) {
        int separatorIndex = newLine.indexOf(sep);
        if (separatorIndex == -1) {
            String lastNum = newLine.substring(separatorIndex + 1);
            temp.addElement(lastNum.trim());
            break;
        } else {
            String newNum = newLine.substring(0, separatorIndex);
            temp.addElement(newNum.trim());
        }
        newLine = newLine.substring(separatorIndex + 1);
    }
    String[] result = new String[temp.size()];
    for (int i = 0; i < result.length; i++) {
        result[i] = (String) temp.elementAt(i);
    }
    return (result);
}

From source file:org.apache.jetspeed.services.resources.VariableResourcesService.java

/**
 * The purpose of this method is to get the configuration resource
 * with the given name as a vector./*from   w  w w  . j  av a  2s  .  c om*/
 *
 * @param name The resource name.
 * @return The value of the resource as a vector.
 */
public Vector getVector(String name) {
    Vector std = (Vector) vectors.get(name);

    if (std == null) {
        std = super.getVector(name);
        if (std != null) {
            Vector newstd = new Vector();
            Enumeration en = std.elements();
            while (en.hasMoreElements()) {
                newstd.addElement(substituteString((String) en.nextElement()));
            }
            std = newstd;
            vectors.put(name, std);
        }
    }

    return std;
}

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

public org.osid.shared.ObjectIterator getPartValueByPart(org.osid.shared.Id partStructureId)
        throws org.osid.repository.RepositoryException {
    java.util.Vector results = new java.util.Vector();
    org.osid.repository.PartIterator partIterator = getPartByPart(partStructureId);
    while (partIterator.hasNextPart()) {
        results.addElement(partIterator.nextPart().getValue());
    }/*from  ww w.j  a v  a 2 s .c om*/
    try {
        return new ObjectIterator(results);
    } catch (Throwable t) {
        _log.error(t.getMessage());
        throw new org.osid.repository.RepositoryException(org.osid.OsidException.OPERATION_FAILED);
    }
}