@Test public void testEvent2JSONObject() { logger.info("Event2JSONObject"); HashMap<String, Object> m = new HashMap(); m.put("one", "1"); m.put("two", 2); EventBean event = new EventBeanMock(m); JSONObject result = Utils.Event2JSONObject(event); assertEquals(result.get("one"), "1"); assertEquals(result.get("two"), 2); }
public static JSONObject Event2JSONObject(EventBean event) { JSONObject jo = new JSONObject(); Map<String, Object> errors = new HashMap<String, Object>(); String[] propertyNames = event.getEventType().getPropertyNames(); for (String propertyName : propertyNames) { try { jo.put(propertyName, event.get(propertyName)); } catch (JSONException je) { errors.put(propertyName, je.getMessage()); logger.error(je.getMessage()); } } if (!errors.isEmpty()) { jo.put("errors", errors); } return jo; }
Utils { public static JSONObject Event2JSONObject(EventBean event) { JSONObject jo = new JSONObject(); Map<String, Object> errors = new HashMap<String, Object>(); String[] propertyNames = event.getEventType().getPropertyNames(); for (String propertyName : propertyNames) { try { jo.put(propertyName, event.get(propertyName)); } catch (JSONException je) { errors.put(propertyName, je.getMessage()); logger.error(je.getMessage()); } } if (!errors.isEmpty()) { jo.put("errors", errors); } return jo; } }
Utils { public static JSONObject Event2JSONObject(EventBean event) { JSONObject jo = new JSONObject(); Map<String, Object> errors = new HashMap<String, Object>(); String[] propertyNames = event.getEventType().getPropertyNames(); for (String propertyName : propertyNames) { try { jo.put(propertyName, event.get(propertyName)); } catch (JSONException je) { errors.put(propertyName, je.getMessage()); logger.error(je.getMessage()); } } if (!errors.isEmpty()) { jo.put("errors", errors); } return jo; }  }
Utils { public static JSONObject Event2JSONObject(EventBean event) { JSONObject jo = new JSONObject(); Map<String, Object> errors = new HashMap<String, Object>(); String[] propertyNames = event.getEventType().getPropertyNames(); for (String propertyName : propertyNames) { try { jo.put(propertyName, event.get(propertyName)); } catch (JSONException je) { errors.put(propertyName, je.getMessage()); logger.error(je.getMessage()); } } if (!errors.isEmpty()) { jo.put("errors", errors); } return jo; }  static synchronized EPServiceProvider initEPService(ServletContext sc); static synchronized void destroyEPService(ServletContext sc); static Map<String, Object> JSONObject2Map(JSONObject jo); static JSONObject Event2JSONObject(EventBean event); static JSONObject Statement2JSONObject(EPStatement st); static boolean DoHTTPPost(String urlStr, String content); static void putCorrelatorAndTrans(HttpServletRequest req); static String getBodyAsString(HttpServletRequest request); static void setTimerRuleHeaders(JSONObject rule); static Boolean isValidURL(String url); }
Utils { public static JSONObject Event2JSONObject(EventBean event) { JSONObject jo = new JSONObject(); Map<String, Object> errors = new HashMap<String, Object>(); String[] propertyNames = event.getEventType().getPropertyNames(); for (String propertyName : propertyNames) { try { jo.put(propertyName, event.get(propertyName)); } catch (JSONException je) { errors.put(propertyName, je.getMessage()); logger.error(je.getMessage()); } } if (!errors.isEmpty()) { jo.put("errors", errors); } return jo; }  static synchronized EPServiceProvider initEPService(ServletContext sc); static synchronized void destroyEPService(ServletContext sc); static Map<String, Object> JSONObject2Map(JSONObject jo); static JSONObject Event2JSONObject(EventBean event); static JSONObject Statement2JSONObject(EPStatement st); static boolean DoHTTPPost(String urlStr, String content); static void putCorrelatorAndTrans(HttpServletRequest req); static String getBodyAsString(HttpServletRequest request); static void setTimerRuleHeaders(JSONObject rule); static Boolean isValidURL(String url);  }