try {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
XmlPullParser pp = factory.newPullParser();
pp.setInput(new StringReader(sInfo));
pp.next();
XmlPullNode stateTree = factory.newPullNode(pp);
while(true) {
// get the next child and check if we are done
XmlPullNode nextChild = (XmlPullNode) stateTree.readNextChild();
if (nextChild == null)
break;
// check the type of the child node, and act appropriately
if (nextChild.getLocalName().equals("componentIDInfo")) {
// ignore, because this information has already been set
} else if (nextChild.getLocalName().equals("properties")) {
// set the compProperties TypeMap from XML
setPropertiesFromXML(nextChild, compProperties);
} else if (nextChild.getLocalName().equals("usesPortMap")) {
// add an entry for every uses port
while (true) {
// get the next entry
XmlPullNode entryNode = (XmlPullNode) nextChild.readNextChild();
if (entryNode == null)
break;
// parse every <usesPortEntry/>
while (true) {
// get the next child for the usesPortEntry
XmlPullNode entryChild = (XmlPullNode) entryNode.readNextChild();
if (entryChild == null)
break;
// initialize values
String portName = null;
String portType = null;
TypeMap tMap = createTypeMap();
boolean inUse = false;
XCATConnectionID connID = null;
boolean unregistered = false;
int migrationStatus = 0;
if (entryChild.getLocalName().equals("portName")) {
// get the portName
portName = (String) entryChild.readNextChild();
} else { // is a <usesPortRecord/>
// read all the values for the UsesPortInfo object
while (true) {
XmlPullNode nextItem = (XmlPullNode) entryChild.readNextChild();
if (nextItem == null)
break;
if (nextItem.getLocalName().equals("portName")) {
portName = (String) nextItem.readNextChild();
} else if (nextItem.getLocalName().equals("portType")) {
portType = (String) nextItem.readNextChild();
} else if (nextItem.getLocalName().equals("properties")) {
setPropertiesFromXML(nextItem, tMap);
} else if (nextItem.getLocalName().equals("inUse")) {
inUse = Boolean.valueOf((String) nextItem.readNextChild()).booleanValue();
} else if (nextItem.getLocalName().equals("connectionID")) {
connID = xmlToConnectionID(nextItem);
} else if (nextItem.getLocalName().equals("unregistered")) {
unregistered =
Boolean.valueOf((String) nextItem.readNextChild()).booleanValue();
} else { // (nextItem.getLocalName().equals("migrationStatus"))
migrationStatus = Integer.parseInt((String) nextItem.readNextChild());
}
}
// create a UsesPortInfo entry
UsesPortInfo uInfo = new UsesPortInfo(portName,
portType,
tMap);
uInfo.setInUse(inUse);
if (unregistered)
uInfo.unregisterPort();
uInfo.setMigrationStatus(migrationStatus);
if (connID != null)
uInfo.setConnectionID(connID);
// add this uses port to the HashMap
usesPortMap.put(portName, uInfo);
}
}
}
} else if (nextChild.getLocalName().equals("wsPortMap")) {
// add an entry for every WS port
while (true) {
// get the next entry
XmlPullNode entryNode = (XmlPullNode) nextChild.readNextChild();
if (entryNode == null)
break;
// parse every <wsPortEntry/>
while (true) {
// get the next child for the wsPortEntry
XmlPullNode entryChild = (XmlPullNode) entryNode.readNextChild();
if (entryChild == null)
break;
// initialize values
String portName = null;
String portType = null;
TypeMap tMap = createTypeMap();
boolean inUse = false;
boolean unregistered = false;
String endPointLocation = null;
if (entryChild.getLocalName().equals("portName")) {
// get the portName
portName = (String) entryChild.readNextChild();
} else { // is a <wsPortRecord/>
// read all the values for the WSPortInfo object
while (true) {
XmlPullNode nextItem = (XmlPullNode) entryChild.readNextChild();
if (nextItem == null)
break;
if (nextItem.getLocalName().equals("portName")) {
portName = (String) nextItem.readNextChild();
} else if (nextItem.getLocalName().equals("portType")) {
portType = (String) nextItem.readNextChild();
} else if (nextItem.getLocalName().equals("properties")) {
setPropertiesFromXML(nextItem, tMap);
} else if (nextItem.getLocalName().equals("inUse")) {
inUse = Boolean.valueOf((String) nextItem.readNextChild()).booleanValue();
} else if (nextItem.getLocalName().equals("endPointLocation")) {
endPointLocation = (String) nextItem.readNextChild();
} else { // if (nextItem.getLocalName().equals("unregistered")) {
unregistered =
Boolean.valueOf((String) nextItem.readNextChild()).booleanValue();
}
}
// create a WSPortInfo entry
WSPortInfo wInfo = new WSPortInfo(portName,
portType,
tMap);
wInfo.setInUse(inUse);
if (unregistered)
wInfo.unregisterPort();
if (endPointLocation != null)
wInfo.setEndPointLocation(endPointLocation);
// add this WS port to the HashMap
wsPortMap.put(portName, wInfo);
}
}
}
} else { // (nextChild.getLocalName().equals("providesPortMap"))
// add an entry for every provides port
while (true) {
// get the next entry
XmlPullNode entryNode = (XmlPullNode) nextChild.readNextChild();
if (entryNode == null)
break;
// parse every <providesPortEntry/>
while (true) {
// get the next child for the providesPortEntry
XmlPullNode entryChild = (XmlPullNode) entryNode.readNextChild();
if (entryChild == null)
break;
// initialize values
String portName = null;
String portType = null;
TypeMap tMap = createTypeMap();
boolean inUse = false;
int numConnections = 0;
String providesPortHandle = null;
boolean removed = false;
if (entryChild.getLocalName().equals("portName")) {
// get the portName
portName = (String) entryChild.readNextChild();
} else { // is a <providesPortRecord/>
// read all the values for the ProvidesPortInfo object
while (true) {
XmlPullNode nextItem = (XmlPullNode) entryChild.readNextChild();
if (nextItem == null)
break;
if (nextItem.getLocalName().equals("portName")) {
portName = (String) nextItem.readNextChild();
} else if (nextItem.getLocalName().equals("portType")) {
portType = (String) nextItem.readNextChild();
} else if (nextItem.getLocalName().equals("properties")) {
setPropertiesFromXML(nextItem, tMap);
} else if (nextItem.getLocalName().equals("inUse")) {
inUse = Boolean.valueOf((String) nextItem.readNextChild()).booleanValue();
} else if (nextItem.getLocalName().equals("numConnections")) {
numConnections = Integer.parseInt((String) nextItem.readNextChild());
} else if (nextItem.getLocalName().equals("providesPortHandle")) {
providesPortHandle = (String) nextItem.readNextChild();
} else { // (nextItem.getLocalName().equals("removed"))
removed = Boolean.valueOf((String) nextItem.readNextChild()).booleanValue();
}
}
// create a ProvidesPortInfo entry
ProvidesPortInfo pInfo = new ProvidesPortInfo(portName,