Package org.apache.wink.json4j

Examples of org.apache.wink.json4j.JSONObject


   *
   * @param mIs
   */
  public void load(InputStream mIs) {
    try {
      m = new JSONObject(mIs);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here


  /**
   * get message of the day
   */
  public JSONObject getRandomMessageOfTheDay() {
    JSONObject res = null;
    try {
      JSONArray msgs = (JSONArray) m.get("motd");
     
      long numMessages = (long) m.getInt("length");
     
View Full Code Here

   *
   * @param is
   */
  public void load(InputStream is) {
    try {
      myFlights = new JSONObject(is);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

   */
  public void addMyFlight(String flightId, String userId, String approverId,
      String reason) {
    try {
      JSONArray flts = (JSONArray) myFlights.get("myflights");
      JSONObject o = new JSONObject();
      o.put("FlightId", flightId);
      o.put("UserId", userId);
      o.put("ApproverId", approverId);
      o.put("Reason", reason);
      o.put("state", "started");
      flts.put(o);
     
      myFlights.remove("myflights");
      myFlights.put("myflights", flts);

View Full Code Here

   *
   * @param userId
   *            should be from the request.getUserPrincipal
   */
  public JSONObject getMyFlights(String userId) {
    JSONObject res = new JSONObject();
    JSONArray arr = new JSONArray();
    try {
      JSONArray flts = (JSONArray) myFlights.get("myflights");

      @SuppressWarnings("rawtypes")
      Iterator iter = flts.iterator();
      while (iter.hasNext()) {
        JSONObject o = (JSONObject) iter.next();
        String uId = o.getString("UserId");

        // Checks to see if the uid exists
        if (uId.equalsIgnoreCase(userId)) {
          arr.put(o);
        }
View Full Code Here

            JSONArray flts = (JSONArray) myFlights.get("myflights");

            @SuppressWarnings("rawtypes")
            Iterator iter = flts.iterator();
            while (iter.hasNext()) {
                JSONObject o = (JSONObject) iter.next();
                String fId = o.getString("FlightId");

                // Checks to see if the fid exists
                if (fId.equalsIgnoreCase(flightId)) {
                    String uId = o.getString("UserId");
                    arr.put(uId);
                }

            }
        } catch (Exception e) {
View Full Code Here

      JSONArray flts = (JSONArray) myFlights.get("myflights");

      @SuppressWarnings("rawtypes")
      Iterator iter = flts.iterator();
      while (iter.hasNext()) {
        JSONObject o = (JSONObject) iter.next();
        String fId = o.getString("UserId");
        String uId = o.getString("FlightId");

        // Checks to see if the flight id and uid exist
        if (fId.compareTo(flightId) == 0 && uId.compareTo(userId) == 0) {
          flts.remove(o);
        }
View Full Code Here

      JSONArray flts = (JSONArray) myFlights.get("myflights");

      @SuppressWarnings("rawtypes")
      Iterator iter = flts.iterator();
      while (iter.hasNext()) {
        JSONObject o = (JSONObject) iter.next();
        String fId = o.getString("UserId");
        String uId = o.getString("FlightId");
        String aId = o.getString("ApproverId");

        // Checks to see if the flight id and uid and aId exist
        if (fId.compareTo(flightId) == 0 && uId.compareTo(userId) == 0
            && aId.compareTo(approverId) == 0) {
          flts.remove(o);
          o.put("state", "approved");
          flts.put(o);
        }

      }
View Full Code Here

      String approverId, String reason,String state) throws JSONException {
      this.removeMyFlights(userId, flightId);
      JSONArray flts = (JSONArray) myFlights.get("myflights");
      Iterator<JSONObject> iter = flts.iterator();
      while(iter.hasNext()) {
          JSONObject flight = iter.next();
          String oldFlightId = flight.getString("FlightId");
          String oldUserId = flight.getString("UserId");
          if(oldFlightId.equalsIgnoreCase(flightId) && oldUserId.equalsIgnoreCase(userId)) {
              flts.remove(flight);
              break;
          }
      }
      JSONObject o = new JSONObject();
      o.put("FlightId", flightId);
      o.put("UserId", userId);
      o.put("ApproverId", approverId);
      o.put("Reason", reason);
      o.put("state", state);
      flts.put(o);

      myFlights.remove("myflights");
      myFlights.put("myflights", flts);
      return o;
View Full Code Here

   *
   * @param flightId
   * @return
   */
  public JSONObject getCustomersByFlight(String flightId) {
    JSONObject res = new JSONObject();
    JSONArray array = new JSONArray();
    try {
      JSONArray flts = (JSONArray) myFlights.get("myflights");

      @SuppressWarnings("rawtypes")
      Iterator iter = flts.iterator();
      while (iter.hasNext()) {
        JSONObject i = (JSONObject) iter.next();

        String flight = i.getString("FlightId");
        if (flightId.compareTo(flight) == 0) {
          array.put(i);
        }
      }

View Full Code Here

TOP

Related Classes of org.apache.wink.json4j.JSONObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.