我必須在ESPER中定義下面的類,以便能夠引用子類型和內部數組。我必須務實地做到這一點。我並不怎麼在意:Esper:在語法上定義一個子類型的類型?
UPDATE:完整的類:
public class IoTEntityEvent implements java.io.Serializable {
private IoTProperty[] Properties;
private String About;
IoTEntityEvent(){
this.About = null;
this.Properties = null;
}
public String getAbout() {
return About;
}
public void setAbout(String value){
this.About = value;
}
public void setProperties(int index, IoTProperty value) {
Properties[index] = value;
}
public IoTProperty getProperties(int index) {
return Properties[index];
}
public void setProperties(IoTProperty[] value) {
Properties = value;
}
public IoTProperty[] getProperties() {
return Properties;
}
}
這是子類:
public class IoTProperty implements java.io.Serializable {
private Map<String,String>[] IoTStateObservation =null;
private String About = null;
IoTProperty(){
this.About = null;
this.IoTStateObservation = null;
}
public String getAbout() {
return About;
}
public void setAbout(String value) {
About = value;
}
public Map<String,String>[] getIoTStateObservation() {
return IoTStateObservation;
}
public void setIoTStateObservation(Map<String,String>[] value) {
IoTStateObservation = value;
}
public Map<String,String> getIoTStateObservation(int index) {
return IoTStateObservation[index];
}
public void setIoTStateObservation(int index, Map<String,String> value) {
IoTStateObservation[0] = value;
}
}
我想是這樣的:
eventNames[0] = "About";
eventType[0] = String.class;
eventNames[1] = "Properties";
eventType[1] = IoTProperty[].class;
epService.getEPAdministrator().getConfiguration().addEventType("type", eventNames, eventType);
This works but I ca不能訪問子類型。我也嘗試以類似的方式定義子類型。有人可以解釋我想怎麼做嗎?
這應該是一個評論 – Marco13 2014-10-02 18:53:18
通過它的工作原理就意味着我能夠來查詢它,甚至做屬性[0]。但是當我嘗試做屬性[0]。關於不行。另外,它的工作原理我的意思是在底層對象的返回值包含Properties [0] .About的值,我只是無法在esper中查詢它。 – 2014-10-03 10:55:56
確保您具有小寫屬性。根據JavaBean「getAbout()」是「關於」而不是「關於」。你也可以做一個「admin.getConfiguration()。getEventType(」type「),它返回一個EventType對象,告訴你存在哪些屬性,例如getPropertyNames() – user650839 2014-10-03 14:33:36