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:nl.tricode.magnolia.blogs.dialog.action.SaveWordpressBlogDialogAction.java

/**
 * Builds the getUser request for the WordPress XML-RPC call.
 *
 * @param wordpressUserID the user to get
 * @return the request/*from   w w  w. j a  v  a 2  s.c om*/
 */
private Vector<Object> buildGetUserRequest(String wordpressUserID) {
    Vector<Object> request = new Vector<Object>();
    Vector<String> expectedReturnValues = new Vector<String>();
    expectedReturnValues.addElement(FIRSTNAME);
    expectedReturnValues.addElement(LASTNAME);
    expectedReturnValues.addElement(EMAIL);
    expectedReturnValues.addElement(URL);

    request.addElement(item.getItemProperty("blogID").getValue());
    request.addElement(item.getItemProperty("username").getValue());
    request.addElement(item.getItemProperty("password").getValue());
    request.addElement(wordpressUserID);
    request.addElement(expectedReturnValues);

    return request;
}

From source file:edu.monash.merc.system.remote.FTPFileGetter.java

/**
 * Get the list of sub-directories in the current directory as a Vector of Strings, exclusive files
 *
 * @return a List of sub-directories//from w  ww  . j a v a2s. c  om
 */
public Vector<String> listSubdirNames() {
    Vector<String> v = new Vector<String>();
    try {
        FTPFile[] files = listFiles();
        for (int i = 0; i < files.length; i++) {
            if (files[i].isDirectory()) {
                v.addElement(files[i].getName());
            }
        }
    } catch (Exception ex) {
        throw new DMFTPException(ex);
    }
    return v;
}

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

public boolean fromJSONObject(JSONObject jobj, IAnimation anim) {
    boolean result = false;
    setAnimation(anim);//  ww  w . ja v  a 2s  .  c  om
    try {
        Vector _data = new Vector();
        JSONArray comments = jobj.getJSONArray("data");
        int numElements = comments.length();

        if (comments != null) {
            for (int n = 0; n < numElements; n++) {
                JSONObject entry = comments.getJSONObject(n);
                CommentEntry c = new CommentEntry();
                c.fromJSONObject(entry, anim);
                _data.addElement(c);
            }
        }
        data = _data;
        result = true;

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

    return result;
}

From source file:edu.monash.merc.system.remote.FTPFileGetter.java

/**
 * Get the list of files in the current directory as a Vector of Strings, exclusive sub-directories
 *
 * @return a Vecgtor of Strings which contains file names
 *//* ww w  .ja  va  2  s.c om*/
public Vector<String> listFileNames() {
    Vector<String> v = new Vector<String>();
    try {
        FTPFile[] files = listFiles();
        for (int i = 0; i < files.length; i++) {
            if (!files[i].isDirectory()) {
                v.addElement(files[i].getName());
            }
        }
    } catch (Exception ex) {
        throw new DMFTPException(ex);
    }
    return v;
}

From source file:com.nokia.example.lwuit.rlinks.network.operation.LinksLoadOperation.java

/**
 * Parse a JSON representation of Reddit links into a Vector
 * of RedditLink objects./*from w ww  .java 2 s.c  o  m*/
 *
 * @param linksJson The JSON response from the server
 */
private void parseLinks(String linksJson) {
    JSONObject jsonResponse;
    JSONArray jsonItems;
    try {
        try {
            jsonResponse = new JSONObject(linksJson);
        } catch (NumberFormatException nfe) {
            System.out.println("NFE: " + nfe.getMessage());
            return;
        }
        jsonItems = jsonResponse.getJSONObject("data").getJSONArray("children");
    } catch (JSONException e) {
        System.out.println("Could not populate from JSON data: " + e.getMessage());
        return;
    }

    Vector links = new Vector();
    int numItems = jsonItems.length();
    if (numItems > 0) {
        LinkThing item;
        JSONObject jsonObj;
        for (int i = 0; i < numItems; i++) {
            try {
                jsonObj = jsonItems.getJSONObject(i).getJSONObject("data");
                item = LinkThing.fromJson(jsonObj);
                links.addElement(item);
            } catch (JSONException e) {
                System.out.println("Could not parse JSON object: " + e.getMessage());
            }
        }
    }

    finished = true;
    linkListener.linksReceived(links);
}

From source file:com.nokia.example.rlinks.network.operation.LinksLoadOperation.java

/**
 * Parse a JSON representation of Reddit links into a Vector
 * of RedditLink objects.//from w w w  . j av  a 2s  . co m
 *
 * @param linksJson The JSON response from the server
 */
private void parseLinks(String linksJson) {
    JSONObject jsonResponse;
    JSONArray jsonItems;
    try {
        try {
            jsonResponse = new JSONObject(linksJson);
        } catch (NumberFormatException nfe) {
            System.out.println("NFE: " + nfe.getMessage());
            return;
        }
        jsonItems = jsonResponse.getJSONObject("data").getJSONArray("children");
    } catch (JSONException e) {
        System.out.println("Could not populate from JSON data: " + e.getMessage());
        return;
    }

    Vector links = new Vector();
    int numItems = jsonItems.length();

    if (numItems > 0) {
        LinkThing item;
        JSONObject jsonObj;
        for (int i = 0; i < numItems; i++) {
            try {
                jsonObj = jsonItems.getJSONObject(i).getJSONObject("data");
                item = LinkThing.fromJson(jsonObj);
                links.addElement(item);
            } catch (JSONException e) {
                System.out.println("Could not parse JSON object: " + e.getMessage());
            }
        }
    }

    finished = true;
    linkListener.linksReceived(links);
}

From source file:nl.tricode.magnolia.blogs.dialog.action.SaveWordpressBlogDialogAction.java

/**
 * Builds the getPosts request for the WordPress XML-RPC call.
 *
 * @return the request/*from   w  w w. j  a  va2  s  .  co m*/
 */
private Vector<Object> buildGetPostsRequest() {
    Integer blogID = Integer.valueOf((String) item.getItemProperty("blogID").getValue());
    String username = (String) item.getItemProperty("username").getValue();
    String password = (String) item.getItemProperty("password").getValue();

    Vector<Object> request = new Vector<Object>();
    Vector<String> expectedReturnValues = new Vector<String>();
    expectedReturnValues.addElement("post_content");
    expectedReturnValues.addElement("post_title");
    expectedReturnValues.addElement("post_author");
    expectedReturnValues.addElement("post_date");
    expectedReturnValues.addElement("post_modified");
    expectedReturnValues.addElement("post_name");
    expectedReturnValues.addElement("terms");

    Hashtable hashTable = new Hashtable();
    hashTable.put("number", 254);

    request.addElement(blogID);
    request.addElement(username);
    request.addElement(password);
    request.addElement(hashTable);
    request.addElement(expectedReturnValues);

    return request;
}

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

/**
 * Divides a String by its whitespace./*from  w  w w.  j  a v  a  2s.  c om*/
 *
 * @param line The String to divide.
 * @return An Array of Strings taken from between the whitespace characters.
 */
public static String[] splitSpaces(String line) {
    if (line == null)
        return (new String[0]);

    int start, end;

    Vector vec = new Vector();

    end = 0;
    while (true) {
        start = findNonBlank(line, end);
        if (start == -1)
            break;
        end = findBlank(line, start);
        if (end == -1) {
            vec.addElement(line.substring(start));
            break;
        } else {
            vec.addElement(line.substring(start, end));
        }
    }

    String[] result = new String[vec.size()];
    for (int j = 0; j < vec.size(); j++) {
        result[j] = (String) vec.elementAt(j);
    }

    return (result);
}

From source file:net.nosleep.superanalyzer.analysis.views.GrowthView.java

private void refreshDataset() {
    TimeSeries series1 = new TimeSeries(Misc.getString("SONGS_IN_LIBRARY"));

    Hashtable addedHash = null;/*from w w w . jav a 2s. com*/

    if (_comboBox == null) {
        addedHash = _analysis.getDatesAdded(Analysis.KIND_TRACK, null);
    } else {
        ComboItem item = (ComboItem) _comboBox.getSelectedItem();
        addedHash = _analysis.getDatesAdded(item.getKind(), item.getValue());
    }

    Vector items = new Vector();

    Enumeration e = addedHash.keys();
    while (e.hasMoreElements()) {

        Day day = (Day) e.nextElement();
        Integer count = (Integer) addedHash.get(day);

        if (count.intValue() > 0) {
            items.addElement(new GrowthItem(day, count));
        }
    }

    Collections.sort(items, new GrowthComparator());

    double value = 0.0;
    for (int i = 0; i < items.size(); i++) {
        GrowthItem item = (GrowthItem) items.elementAt(i);

        value += item.Count;

        series1.add(item.Day, value);

    }

    _dataset.removeAllSeries();
    _dataset.addSeries(series1);
}

From source file:fsart.diffTools.gui.DiffToolsMainPanel.java

private void appendExcelSheetInJList(String excelFile, JList listfic) {
    log.debug("Enter append excel sheet with " + excelFile);
    String type = Helper.getTypeOfFile(excelFile);
    Vector<String> emptyList = new Vector<String>();
    listfic.setListData(emptyList);// w w w. ja va  2 s.c o m
    log.debug("type of file : " + type);
    if (type.equals("xls")) {
        InputStream inp = null;
        try {
            inp = new FileInputStream(excelFile);
            HSSFWorkbook wb = new HSSFWorkbook(inp);
            int sheetNb = wb.getNumberOfSheets();
            if (sheetNb > 0) {
                Vector<String> sheetnames = new Vector<String>();
                for (int i = 0; i < sheetNb; i++) {
                    Sheet sheet = wb.getSheetAt(i);
                    sheetnames.addElement(sheet.getSheetName());
                    log.debug("I find : " + sheet.getSheetName());
                }
                listfic.setListData(sheetnames);
            }
        } catch (Exception e) {
        }

    }

}