Package org.hornetq.utils.json

Examples of org.hornetq.utils.json.JSONArray


      return FilterConstants.HORNETQ_USERID + " = '" + jmsMessageID + "'";
   }

   static String toJSON(final Map<String, Object>[] messages)
   {
      JSONArray array = new JSONArray();
      for (Map<String, Object> message : messages)
      {
         array.put(new JSONObject(message));
      }
      return array.toString();
   }
View Full Code Here


            // sort by creation time, oldest first
            return (int)(entry1.getValue() - entry2.getValue());
         }
      });

      JSONArray txDetailListJson = new JSONArray();
      for (Map.Entry<Xid, Long> entry : xidsSortedByCreationTime)
      {
         Xid xid = entry.getKey();
         Transaction tx = resourceManager.getTransaction(xid);
         if (tx == null)
         {
            continue;
         }
         TransactionDetail detail = new JMSTransactionDetail(xid, tx, entry.getValue());
         txDetailListJson.put(detail.toJSON());
      }
      return txDetailListJson.toString();
   }
View Full Code Here

         html.append("<tr><th colspan=\"6\">Message List</th></tr>");
         html.append("<tr><td colspan=\"6\">");
         html.append("<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">");

         JSONArray msgs = txJson.getJSONArray(TransactionDetail.KEY_TX_RELATED_MESSAGES);
         for (int i = 0; i < msgs.length(); i++)
         {
            JSONObject msgJson = msgs.getJSONObject(i);
            JSONObject props = msgJson.getJSONObject(TransactionDetail.KEY_MSG_PROPERTIES);
            StringBuilder propstr = new StringBuilder();
            @SuppressWarnings("unchecked")
            Iterator<String> propkeys = props.keys();
            while (propkeys.hasNext())
View Full Code Here

   // Static --------------------------------------------------------

   public static String toJSON(final DayCounterInfo[] infos) throws JSONException
   {
      JSONObject json = new JSONObject();
      JSONArray counters = new JSONArray();
      for (DayCounterInfo info : infos)
      {
         JSONObject counter = new JSONObject();
         counter.put("date", info.getDate());
         counter.put("counters", Arrays.asList(info.getCounters()));
         counters.put(counter);
      }
      json.put("dayCounters", counters);
      return json.toString();
   }
View Full Code Here

    * by {@link QueueControl#listMessageCounterHistory()}.
    */
   public static DayCounterInfo[] fromJSON(final String jsonString) throws JSONException
   {
      JSONObject json = new JSONObject(jsonString);
      JSONArray dayCounters = json.getJSONArray("dayCounters");
      DayCounterInfo[] infos = new DayCounterInfo[dayCounters.length()];
      for (int i = 0; i < dayCounters.length(); i++)
      {

         JSONObject counter = (JSONObject)dayCounters.get(i);
         JSONArray hour = (JSONArray)counter.getJSONArray("counters").get(0);
         int[] hourCounters = new int[24];
         for (int j = 0; j < 24; j++)
         {
            hourCounters[j] = hour.getInt(j);
         }
         DayCounterInfo info = new DayCounterInfo(counter.getString("date"), hourCounters);
         infos[i] = info;
      }
      return infos;
View Full Code Here

    * Returns an array of RoleInfo corresponding to the JSON serialization returned
    * by {@link AddressControl#getRolesAsJSON()}.
    */
   public static final RoleInfo[] from(final String jsonString) throws Exception
   {
      JSONArray array = new JSONArray(jsonString);
      RoleInfo[] roles = new RoleInfo[array.length()];
      for (int i = 0; i < array.length(); i++)
      {
         JSONObject r = array.getJSONObject(i);
         RoleInfo role = new RoleInfo(r.getString("name"),
                                      r.getBoolean("send"),
                                      r.getBoolean("consume"),
                                      r.getBoolean("createDurableQueue"),
                                      r.getBoolean("deleteDurableQueue"),
View Full Code Here

      String paramString;

      if (parameters != null)
      {
         JSONArray jsonArray = ManagementHelper.toJSONArray(parameters);

         paramString = jsonArray.toString();
      }
      else
      {
         paramString = null;
      }
View Full Code Here

      message.getBodyBuffer().writeNullableSimpleString(SimpleString.toSimpleString(paramString));
   }

   private static JSONArray toJSONArray(final Object[] array) throws Exception
   {
      JSONArray jsonArray = new JSONArray();

      for (Object parameter : array)
      {
         if (parameter instanceof Map)
         {
            Map<String, Object> map = (Map<String, Object>)parameter;

            JSONObject jsonObject = new JSONObject();

            for (Map.Entry<String, Object> entry : map.entrySet())
            {
               String key = entry.getKey();

               Object val = entry.getValue();

               if (val != null)
               {
                  if (val.getClass().isArray())
                  {
                     val = ManagementHelper.toJSONArray((Object[])val);
                  }
                  else
                  {
                     ManagementHelper.checkType(val);
                  }
               }

               jsonObject.put(key, val);
            }

            jsonArray.put(jsonObject);
         }
         else
         {
            if (parameter != null)
            {
               Class clz = parameter.getClass();

               if (clz.isArray())
               {
                  Object[] innerArray = (Object[])parameter;

                  jsonArray.put(ManagementHelper.toJSONArray(innerArray));
               }
               else
               {
                  ManagementHelper.checkType(parameter);

                  jsonArray.put(parameter);
               }
            }
            else
            {
               jsonArray.put((Object)null);
            }
         }
      }

      return jsonArray;
View Full Code Here

      SimpleString sstring = message.getBodyBuffer().readNullableSimpleString();
      String jsonString = (sstring == null) ? null : sstring.toString();

      if (jsonString != null)
      {
         JSONArray jsonArray = new JSONArray(jsonString);

         return ManagementHelper.fromJSONArray(jsonArray);
      }
      else
      {
View Full Code Here

      if (result != null)
      {
         // Result is stored in body, also encoded as JSON array of length 1

         JSONArray jsonArray = ManagementHelper.toJSONArray(new Object[] { result });

         resultString = jsonArray.toString();
      }
      else
      {
         resultString = null;
      }
View Full Code Here

TOP

Related Classes of org.hornetq.utils.json.JSONArray

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.