📄 inform.java
字号:
/*
* Inform.java
*
*/
package org.openacs.message;
import org.openacs.Message;
import java.util.Hashtable;
import java.util.Iterator;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFactory;
/**
*
* @author Administrator
*/
public class Inform extends Message {
/** Creates a new instance of Inform */
public Inform() {
}
protected void createBody (SOAPBodyElement body, SOAPFactory spf) throws SOAPException
{
}
protected void parseBody (SOAPBodyElement body, SOAPFactory spf) throws SOAPException
{
SOAPElement deviceid = getRequestChildElement (spf, body, "DeviceId");
oui = getRequestElement (spf, deviceid, "OUI");
sn = getRequestElement (spf, deviceid, "SerialNumber");
Manufacturer = getRequestElement (spf, deviceid, "Manufacturer");
ProductClass = getRequestElement (spf, deviceid, "ProductClass");
MaxEnvelopes = Integer.parseInt(getRequestElement (spf, body, "MaxEnvelopes"));
RetryCount = Integer.parseInt(getRequestElement (spf, body, "RetryCount"));
CurrentTime = getRequestElement (spf, body, "CurrentTime");
Iterator pi = getRequestChildElement (spf, body, "ParameterList").getChildElements(spf.createName("ParameterValueStruct"));
Name nameKey = spf.createName("Name");
Name nameValue = spf.createName("Value");
params = new Hashtable <String, String> ();
while (pi.hasNext()) {
SOAPElement param = (SOAPElement)pi.next();
String key = getRequestElement (param, nameKey);
String value = getRequestElement (param, nameValue);
if (value == null) value = "";
params.put(key, value);
}
pi = getRequestChildElement (spf, body, "Event").getChildElements(spf.createName("EventStruct"));
Name eventCode = spf.createName("EventCode");
Name commandKey = spf.createName(COMMAND_KEY);
events = new Hashtable <String, Object> ();
while (pi.hasNext()) {
SOAPElement param = (SOAPElement)pi.next();
String event = getRequestElement (param, eventCode);
String cmdKey = getRequestElement (param, commandKey);
System.out.println ("EVENT: "+event + "["+cmdKey+"]");
if (cmdKey == null) cmdKey = "";
if (!event.startsWith("M ") && !event.startsWith("X ")) {
events.put(event, cmdKey);
}
}
if (params.get("InternetGatewayDevice.DeviceInfo.SoftwareVersion") != null) {
root = "InternetGatewayDevice";
} else if (params.get("Device.DeviceInfo.SoftwareVersion") != null) {
root = "Device";
} else {
throw new RuntimeException("Invalid root. Must be InternetGatewayDevice or Device");
}
}
public String getSoftwareVersion () {
String v = params.get(root +".DeviceInfo.SoftwareVersion");
v = v.replace('-', '.');
return v;
}
public String getHardwareVersion () {
return params.get(root+".DeviceInfo.HardwareVersion");
}
public String getConfigVersion () {
return params.get(root+".DeviceInfo.VendorConfigFile.1.Version");
}
public String getURL () {
return params.get(root+".ManagementServer.ConnectionRequestURL");
}
public String getProvisiongCode () {
return params.get(root+".DeviceInfo.ProvisioningCode");
}
public String getRoot () {
return root;
}
public boolean isEvent (String event) {
return events.containsKey (event);
}
public String oui;
public String sn;
public String ProductClass;
public String Manufacturer;
public int RetryCount;
public String CurrentTime;
public Hashtable <String, String> params;
public Hashtable <String, Object> events;
public int MaxEnvelopes;
private String root;
public static final String EVENT_BOOT = "1 BOOT";
public static final String EVENT_PERIODIC = "2 PERIODIC";
public static final String EVENT_SCHEDULED = "3 SCHEDULED";
public static final String EVENT_VALUE_CHANGE = "4 VALUE CHANGE";
public static final String EVENT_KICKED = "5 KICKED";
public static final String EVENT_CONNECTION_REQUEST = "6 CONNECTION REQUEST";
public static final String EVENT_TRANSFER_COMPLETE = "7 TRANSFER COMPLETE";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -