2017-01-30 57 views
0

我正在發送一些事件來更新偵聽器方法,並且我正在接收對象,但update()方法將其包裝到某個Hashmap中。我無法從那裏檢索對象。在更新偵聽器方法中無法訪問Esper中的事件對象屬性

public static class CEPListener implements UpdateListener { 
    public void update(EventBean[] newData, EventBean[] oldData) { 
      // put some condition here before sending to crowd....... 
      System.out.println("Event received: " 
           + newData[0].getUnderlying()); 
      System.out.println("Sending event to crowd.........");  
     } 
    } 

在上面的功能,我可以得到我想要的對象內newData,但它被包裹在一些地圖,我無法找到從中檢索我的對象的方法。在下面的屏幕newData [0] .getUnderlying()具有各種屬性,我需要紅色矩形下的值對象,根據object methods我無法訪問。將感謝幫助。 Attributes of newData[0].getUnderlying()

回答

0

好的。我已經得到了答案。

   for (EventBean eb : newData) { 
       if (eb instanceof MapEventBean) { 
        //MapEvent event = null; 
        if (eb.getUnderlying() instanceof Map<?, ?>) { 
         Map<?, ?> alert = (Map<?, ?>) eb.getUnderlying(); 
         for (Entry<?, ?> entry : alert.entrySet()) 
         { 
          System.out.println(entry.getValue()); 
         } 


        }