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

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*  ww w  .  j  av  a  2s.  co m*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    HttpSession session = request.getSession();
    response.setContentType("application/json;charset=UTF-8");
    String id = "";
    String nama = "";
    String email = "";
    String link = "";
    String admin = "";
    String icw = "";
    try {
        JSONObject userAccount = (JSONObject) session.getAttribute("userAccount");
        id = userAccount.get("id").toString();
        nama = userAccount.get("name").toString();
        email = userAccount.get("email").toString();
        link = userAccount.get("link").toString();
        admin = userAccount.get("admin").toString();
        icw = userAccount.get("icw").toString();
    } catch (Exception ex1) {
    }
    if (admin.equalsIgnoreCase("Y")) {
        try (PrintWriter out = response.getWriter()) {
            Vector dataPosisi = new Vector();
            dataPosisi.addElement("Menteri");
            dataPosisi.addElement("Pejabat Setingkat Menteri");
            dataPosisi.addElement("Duta Besar");
            JSONArray obj1 = new JSONArray();
            for (int i = 0; i < dataPosisi.size(); i++) {
                String FilterKey = "", FilterValue = "";
                String key = "posisi",
                        keyValue = dataPosisi.get(i).toString().toLowerCase().replaceAll(" ", "");
                String table = "posisi";
                DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
                //Filter linkFilter = new FilterPredicate(FilterKey, FilterOperator.EQUAL, FilterValue);
                Key AlasanStarCalonKey = KeyFactory.createKey(key, keyValue);
                Query query = new Query(table, AlasanStarCalonKey);
                PreparedQuery pq = datastore.prepare(query);
                JSONArray obj11 = new JSONArray();
                getData(obj11, table, key, keyValue, dataPosisi.get(i).toString(),
                        Query.SortDirection.ASCENDING);
                LinkedHashMap record = new LinkedHashMap();
                record.put("posisi", keyValue);
                record.put("nama", dataPosisi.get(i).toString());
                record.put("child", obj11);
                obj1.add(record);
            }
            out.print(JSONValue.toJSONString(obj1));
            out.flush();
        }
    }
}

From source file:com.yahoo.messenger.data.json.IgnoredUserList.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);
        IgnoredUser c = new IgnoredUser();
        c.unserializeJSON(o.getJSONObject("ignoredUser"));
        v.addElement(c);
    }//from   ww w.  j  a va  2  s .  c o  m

    ignoredUsers = new IgnoredUser[v.size()];
    v.copyInto(ignoredUsers);

}

From source file:com.duroty.controller.actions.GoogieSpellAction.java

protected Vector getMatches(String text) {
    Pattern pattern = Pattern.compile(
            "<c o=\\\"([^\\\"]*)\\\" l=\\\"([^\\\"]*)\\\" s=\\\"([^\\\"]*)\\\">([^<]*)<\\/c>",
            Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(text);

    Vector vector = new Vector();

    while (matcher.find()) {
        int groupCount = matcher.groupCount();
        vector.addElement(matcher.group(0));
        for (int i = 0; i < groupCount; i++) {
            DLog.log(DLog.WARN, this.getClass(), "GROUP: " + i + " >> " + matcher.group(i));
        }/*  w w w  . j  ava  2  s .co m*/
    }

    return vector;
}

From source file:com.cloudbase.datacommands.CBSearchCondition.java

/**
 * Creates a new search condition for geographical searches. This looks for documents whose location data
 * places them near the given location.//from  ww  w .  java 2  s.  c o m
 * @param nearLoc The location we are looking for
 * @param maxDistance The maximum distance in meters from the given location
 */
public CBSearchCondition(BlackBerryLocation nearLoc, int maxDistance) {
    Vector points = new Vector();

    points.addElement(Double.toString(nearLoc.getQualifiedCoordinates().getLatitude()));
    points.addElement(Double.toString(nearLoc.getQualifiedCoordinates().getLongitude()));

    Hashtable searchQuery = new Hashtable();
    this.setField("cb_location");
    this.setOperator(CBSearchConditionOperator.CBOperatorEqual);

    searchQuery.put("$near", points);
    if (maxDistance > 0)
        searchQuery.put("$maxDistance", Integer.toString(maxDistance));

    this.setValue(searchQuery);
    this.limit = -1;

    this.setCommandType(CBDataAggregationCommandType.CBDataAggregationMatch);
}

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

private void refreshDataset() {

    Stat itemStats = null;/*  w ww  . j  a va 2 s .c o m*/

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

    Vector counts = new Vector(5);
    int[] rates = itemStats.getBitRates();
    for (int i = 0; i < rates.length; i++)
        counts.addElement(new Double(rates[i]));

    Vector labels = new Vector(5);
    labels.add(new String(Misc.getString("POOR") + "\n(0-63 kbps)\n"));
    labels.add(new String(Misc.getString("LOW") + "\n(64-127 kbps)\n"));
    labels.add(new String(Misc.getString("GOOD") + "\n(128-191 kbps)\n"));
    labels.add(new String(Misc.getString("HIGH") + "\n(192-255 kbps)\n"));
    labels.add(new String(Misc.getString("EXCELLENT") + "\n(256-320 kbps)\n"));

    _dataset.clear();

    PiePlot3D plot = (PiePlot3D) _chart.getPlot();
    Color[] colors = Theme.getColorSet();
    plot.setIgnoreZeroValues(true);

    for (int i = 0; i < counts.size(); i++) {
        // if((Double)counts.elementAt(i) > 0)
        {
            _dataset.setValue((String) labels.elementAt(i), (Double) counts.elementAt(i));
            plot.setSectionPaint((String) labels.elementAt(i), colors[5 - i]);
        }

    }

}

From source file:com.yahoo.messenger.data.json.ClientCapabilityList.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);
        ClientCapability c = new ClientCapability();
        c.unserializeJSON(o.getJSONObject("clientCapability"));
        v.addElement(c);
    }/*  w  ww  .ja  va 2s. c o  m*/

    clientCapabilities = new ClientCapability[v.size()];
    v.copyInto(clientCapabilities);

}

From source file:com.cloudbase.datacommands.CBSearchCondition.java

/**
 * Creates a new search condition for geographical searches. This looks for documents within a given boundary box
 * defined by the coordinates of its North-Eastern and South-Western corners.
 * @param NECorner The coordinates for the north eastern corner
 * @param SWCorner The coordinates for the south western corner
 *//*  w ww . j av a 2s. co m*/
public CBSearchCondition(BlackBerryLocation NECorner, BlackBerryLocation SWCorner) {
    Vector box = new Vector();
    Vector NECornerList = new Vector();
    NECornerList.addElement(Double.toString((NECorner.getQualifiedCoordinates().getLatitude())));
    NECornerList.addElement(Double.toString((NECorner.getQualifiedCoordinates().getLongitude())));
    Vector SWCornerList = new Vector();
    SWCornerList.addElement(Double.toString((SWCorner.getQualifiedCoordinates().getLatitude())));
    SWCornerList.addElement(Double.toString((SWCorner.getQualifiedCoordinates().getLongitude())));
    box.addElement(SWCornerList);
    box.addElement(NECornerList);

    Hashtable boxCondition = new Hashtable();
    boxCondition.put("$box", box);

    Hashtable searchQuery = new Hashtable();
    searchQuery.put("$within", boxCondition);

    this.setField("cb_location");
    this.setOperator(CBSearchConditionOperator.CBOperatorEqual);
    this.setValue(searchQuery);
    this.limit = -1;

    this.setCommandType(CBDataAggregationCommandType.CBDataAggregationMatch);
}

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

public org.osid.repository.RecordStructureIterator getRecordStructures()
        throws org.osid.repository.RepositoryException {
    java.util.Vector results = new java.util.Vector();
    results.addElement(new RecordStructure());
    return new RecordStructureIterator(results);
}

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

private void refreshDataset() {
    _dataset.clear();/*from w w w  . ja v a2s  .  c o m*/

    Stat itemStats = null;

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

    Vector<Double> counts = new Vector<Double>(6);
    double[] ratings = itemStats.getRatings();
    for (int i = 0; i < ratings.length; i++)
        counts.addElement(new Double(ratings[i]));

    Vector<String> labels = new Vector<String>(6);
    labels.add(new String(Misc.getString("NOT_RATED")));
    labels.add(new String("1 " + Misc.getString("STAR")));
    labels.add(new String("2 " + Misc.getString("STARS")));
    labels.add(new String("3 " + Misc.getString("STARS")));
    labels.add(new String("4 " + Misc.getString("STARS")));
    labels.add(new String("5 " + Misc.getString("STARS")));

    PiePlot3D plot = (PiePlot3D) _chart.getPlot();
    Color[] colors = Theme.getColorSet();
    plot.setIgnoreZeroValues(true);

    for (int i = 0; i < counts.size(); i++) {
        // if((Double)counts.elementAt(i) > 0)
        {
            _dataset.setValue((String) labels.elementAt(i), (Double) counts.elementAt(i));
            plot.setSectionPaint((String) labels.elementAt(i), colors[5 - i]);
        }
    }

}

From source file:at.tuwien.ifs.somtoolbox.apps.helper.DataSetGenerator.java

private Vector<DataPoint> generatePoints(String name, int num, double x, double y, double sigmaX,
        double sigmaY) {
    Vector<DataPoint> res = new Vector<DataPoint>(num);
    for (int i = 0; i < num; i++) {
        res.addElement(new DataPoint(name + "-" + (i + 1), rand.nextGaussian(x, sigmaX),
                rand.nextGaussian(y, sigmaY)));
    }/*from  w w  w  .  j a va2  s  .co  m*/
    return res;
}