com.ksyun.api.sdk.kec.transform.InstanceNetworkStaxUnmarshaller Maven / Gradle / Ivy
package com.ksyun.api.sdk.kec.transform;
import javax.xml.stream.events.XMLEvent;
import com.ksc.transform.SimpleTypeStaxUnmarshallers.StringStaxUnmarshaller;
import com.ksyun.api.sdk.kec.model.InstanceNetwork;
import com.ksc.transform.StaxUnmarshallerContext;
import com.ksc.transform.Unmarshaller;
/**
* Reservation StAX Unmarshaller
*/
public class InstanceNetworkStaxUnmarshaller implements
Unmarshaller {
public InstanceNetwork unmarshall(StaxUnmarshallerContext context)
throws Exception {
InstanceNetwork n = new InstanceNetwork();
int originalDepth = context.getCurrentDepth();
int targetDepth = originalDepth + 1;
if (context.isStartOfDocument())
targetDepth += 1;
while (true) {
XMLEvent xmlEvent = context.nextEvent();
if (xmlEvent.isEndDocument())
return n;
if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) {
if (context.testExpression("NetworkInterfaceId", targetDepth)) {
n.setNetworkInterfaceId(StringStaxUnmarshaller
.getInstance().unmarshall(context));
continue;
}
if (context.testExpression("VpcId", targetDepth)) {
n.setVpcId(StringStaxUnmarshaller.getInstance().unmarshall(
context));
continue;
}
if (context.testExpression("SubnetId", targetDepth)) {
n.setSubnetId(StringStaxUnmarshaller.getInstance()
.unmarshall(context));
continue;
}
if (context.testExpression("MacAddress", targetDepth)) {
n.setMacAddress(StringStaxUnmarshaller.getInstance()
.unmarshall(context));
continue;
}
if (context.testExpression("PrivateIpAddress", targetDepth)) {
n.setPrivateIpAddress(StringStaxUnmarshaller.getInstance()
.unmarshall(context));
continue;
}
if (context.testExpression("GroupSet/Item", targetDepth)) {
n.withNetworkSecurityGroup(InstanceSecurityGroupStaxUnmarshaller
.getInstance().unmarshall(context));
continue;
}
} else if (xmlEvent.isEndElement()) {
if (context.getCurrentDepth() < originalDepth) {
return n;
}
}
}
}
private static InstanceNetworkStaxUnmarshaller instance;
public static InstanceNetworkStaxUnmarshaller getInstance() {
if (instance == null)
instance = new InstanceNetworkStaxUnmarshaller();
return instance;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy