本文整理汇总了Java中org.codehaus.stax2.XMLStreamReader2.getAttributeAsLong方法的典型用法代码示例。如果您正苦于以下问题:Java XMLStreamReader2.getAttributeAsLong方法的具体用法?Java XMLStreamReader2.getAttributeAsLong怎么用?Java XMLStreamReader2.getAttributeAsLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.stax2.XMLStreamReader2
的用法示例。
在下文中一共展示了XMLStreamReader2.getAttributeAsLong方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseForwardingRule
import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseForwardingRule(NetPlan netPlan, long layerId, XMLStreamReader2 xmlStreamReader , DoubleMatrix2D f_de) throws XMLStreamException
{
long linkId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "linkId"));
long demandId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "demandId"));
double splittingRatio = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "splittingRatio"));
f_de.set (mapOldId2Demand.get(Pair.of (layerId,demandId)).index , mapOldId2Link.get(Pair.of(layerId , linkId)).index , splittingRatio);
while(xmlStreamReader.hasNext())
{
xmlStreamReader.next();
switch(xmlStreamReader.getEventType())
{
case XMLEvent.START_ELEMENT:
String startElementName = xmlStreamReader.getName().toString();
switch(startElementName)
{
case "attribute":
break;
default:
throw new RuntimeException("Bad");
}
break;
case XMLEvent.END_ELEMENT:
String endElementName = xmlStreamReader.getName().toString();
if (endElementName.equals("forwardingRule")) return;
break;
}
}
throw new RuntimeException("'Forwarding rule' element not parsed correctly (end tag not found)");
}
示例2: parseForwardingRule
import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseForwardingRule(NetPlan netPlan, long layerId, XMLStreamReader2 xmlStreamReader , DoubleMatrix2D f_de) throws XMLStreamException
{
long linkId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "linkId"));
long demandId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "demandId"));
double splittingRatio = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "splittingRatio"));
f_de.set (mapOldId2Demand.get(demandId).index , mapOldId2Link.get(linkId).index , splittingRatio);
while(xmlStreamReader.hasNext())
{
xmlStreamReader.next();
switch(xmlStreamReader.getEventType())
{
case XMLEvent.START_ELEMENT:
String startElementName = xmlStreamReader.getName().toString();
switch(startElementName)
{
case "attribute":
break;
default:
throw new RuntimeException("Bad");
}
break;
case XMLEvent.END_ELEMENT:
String endElementName = xmlStreamReader.getName().toString();
if (endElementName.equals("forwardingRule")) return;
break;
}
}
throw new RuntimeException("'Forwarding rule' element not parsed correctly (end tag not found)");
}
示例3: parseNode
import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseNode(NetPlan netPlan, XMLStreamReader2 xmlStreamReader) throws XMLStreamException
{
long nodeId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "id"));
double xCoord = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "xCoord"));
double yCoord = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "yCoord"));
String nodeName = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "name"));
Node newNode = netPlan.addNode(xCoord, yCoord, nodeName, null);
mapOldId2Node.put (nodeId , newNode);
while(xmlStreamReader.hasNext())
{
xmlStreamReader.next();
switch(xmlStreamReader.getEventType())
{
case XMLEvent.START_ELEMENT:
String startElementName = xmlStreamReader.getName().toString();
switch(startElementName)
{
case "attribute":
String key = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "key"));
String name = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "value"));
newNode.setAttribute(key, name);
break;
default:
throw new RuntimeException("Bad");
}
break;
case XMLEvent.END_ELEMENT:
String endElementName = xmlStreamReader.getName().toString();
if (endElementName.equals("node")) return;
break;
}
}
throw new RuntimeException("'Node' element not parsed correctly (end tag not found)");
}
示例4: parseDemand
import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseDemand(NetPlan netPlan, XMLStreamReader2 xmlStreamReader) throws XMLStreamException
{
long ingressNodeId = -1;
long egressNodeId = -1;
double offeredTraffic = 0;
Map<String, String> attributeMap = new LinkedHashMap<String, String>();
int numAttributes = xmlStreamReader.getAttributeCount();
for(int i = 0; i < numAttributes; i++)
{
String localName = xmlStreamReader.getAttributeLocalName(i);
switch(localName)
{
case "ingressNodeId":
ingressNodeId = xmlStreamReader.getAttributeAsLong(i);
break;
case "egressNodeId":
egressNodeId = xmlStreamReader.getAttributeAsLong(i);
break;
case "offeredTrafficInErlangs":
offeredTraffic = xmlStreamReader.getAttributeAsDouble(i);
break;
default:
attributeMap.put(localName, xmlStreamReader.getAttributeValue(i));
break;
}
}
while(xmlStreamReader.hasNext())
{
xmlStreamReader.next();
switch(xmlStreamReader.getEventType())
{
case XMLEvent.START_ELEMENT:
throw new RuntimeException("No nested elements allowed for 'Demand' element");
case XMLEvent.END_ELEMENT:
String endElementName = xmlStreamReader.getName().toString();
if (endElementName.equals("demandEntry"))
{
netPlan.addDemand(netPlan.nodes.get((int) ingressNodeId), netPlan.nodes.get((int) egressNodeId), offeredTraffic, attributeMap);
return;
}
break;
}
}
throw new RuntimeException("'Demand' element not parsed correctly (end tag not found)");
}
示例5: parseLink
import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseLink(NetPlan netPlan, XMLStreamReader2 xmlStreamReader) throws XMLStreamException
{
Map<String, String> attributeMap = new LinkedHashMap<String, String>();
double linkCapacity = 0;
double linkLengthInKm = 0;
long originNodeId = -1;
long destinationNodeId = -1;
int numAttributes = xmlStreamReader.getAttributeCount();
for(int i = 0; i < numAttributes; i++)
{
String localName = xmlStreamReader.getAttributeLocalName(i);
switch(localName)
{
case "originNodeId":
originNodeId = xmlStreamReader.getAttributeAsLong(i);
break;
case "destinationNodeId":
destinationNodeId = xmlStreamReader.getAttributeAsLong(i);
break;
case "linkCapacityInErlangs":
linkCapacity = xmlStreamReader.getAttributeAsDouble(i);
break;
case "linkLengthInKm":
linkLengthInKm = xmlStreamReader.getAttributeAsDouble(i);
break;
default:
attributeMap.put(localName, xmlStreamReader.getAttributeValue(i));
break;
}
}
while(xmlStreamReader.hasNext())
{
xmlStreamReader.next();
switch(xmlStreamReader.getEventType())
{
case XMLEvent.START_ELEMENT:
throw new RuntimeException("No nested elements allowed for 'Link' element");
case XMLEvent.END_ELEMENT:
String endElementName = xmlStreamReader.getName().toString();
if (endElementName.equals("link"))
{
netPlan.addLink(netPlan.nodes.get((int) originNodeId), netPlan.nodes.get((int) destinationNodeId), linkCapacity, linkLengthInKm, 200000 , attributeMap);
return;
}
break;
}
}
throw new RuntimeException("'Link' element not parsed correctly (end tag not found)");
}
示例6: parseRoute
import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseRoute(NetPlan netPlan, XMLStreamReader2 xmlStreamReader) throws XMLStreamException
{
long demandId = -1;
double carriedTrafficInErlangs = 0;
Map<String, String> attributeMap = new LinkedHashMap<String, String>();
int numAttributes = xmlStreamReader.getAttributeCount();
for(int i = 0; i < numAttributes; i++)
{
String localName = xmlStreamReader.getAttributeLocalName(i);
switch(localName)
{
case "carriedTrafficInErlangs":
carriedTrafficInErlangs = xmlStreamReader.getAttributeAsDouble(i);
break;
case "demandId":
demandId = xmlStreamReader.getAttributeAsLong(i);
break;
default:
attributeMap.put(localName, xmlStreamReader.getAttributeValue(i));
}
}
List<Long> seqLinks = new LinkedList<Long>();
List<Long> backupSegmentList = new LinkedList<Long>();
while(xmlStreamReader.hasNext())
{
xmlStreamReader.next();
switch(xmlStreamReader.getEventType())
{
case XMLEvent.START_ELEMENT:
String startElementName = xmlStreamReader.getName().toString();
switch(startElementName)
{
case "linkEntry":
seqLinks.add(xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "id")));
break;
case "protectionSegmentEntry":
backupSegmentList.add(xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "id")));
break;
default:
throw new RuntimeException("Bad");
}
break;
case XMLEvent.END_ELEMENT:
String endElementName = xmlStreamReader.getName().toString();
if (endElementName.equals("route"))
{
List<Link> newSeqLinks = new LinkedList<Link> (); for (long linkId : seqLinks) newSeqLinks.add (netPlan.defaultLayer.links.get((int) linkId));
Route route = netPlan.addRoute(netPlan.defaultLayer.demands.get ((int) demandId), carriedTrafficInErlangs, carriedTrafficInErlangs , newSeqLinks, attributeMap);
backupSegmentMap.put((long) route.index, backupSegmentList);
return;
}
break;
}
}
throw new RuntimeException("'Route' element not parsed correctly (end tag not found)");
}
示例7: parseNetwork
import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseNetwork(NetPlan netPlan, XMLStreamReader2 xmlStreamReader) throws XMLStreamException
{
String networkDescription_thisNetPlan = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "description"));
String networkName_thisNetPlan = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "name"));
netPlan.setNetworkDescription(networkDescription_thisNetPlan);
netPlan.setNetworkName(networkName_thisNetPlan);
while(xmlStreamReader.hasNext())
{
xmlStreamReader.next();
switch(xmlStreamReader.getEventType())
{
case XMLEvent.START_ELEMENT:
String startElementName = xmlStreamReader.getName().toString();
switch(startElementName)
{
case "attribute":
String key = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "key"));
String name = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "value"));
netPlan.setAttribute(key, name);
break;
case "layer":
parseLayer(netPlan, xmlStreamReader);
break;
case "node":
parseNode(netPlan, xmlStreamReader);
break;
case "srg":
parseSRG(netPlan, xmlStreamReader);
break;
case "layerCouplingDemand":
long upperLayerLinkId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "upperLayerLinkId"));
long lowerLayerDemandId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "lowerLayerDemandId"));
mapOldId2Demand.get(lowerLayerDemandId).coupleToUpperLayerLink(mapOldId2Link.get(upperLayerLinkId));
break;
case "layerCouplingMulticastDemand":
List<Long> upperLayerLinkIds = LongUtils.toList(xmlStreamReader.getAttributeAsLongArray(xmlStreamReader.getAttributeIndex(null, "upperLayerLinkIds")));
long lowerLayerMulticastDemandId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "lowerLayerDemandId"));
Set<Link> setLinksToCouple = new HashSet<Link> (); for (long oldLinkId : upperLayerLinkIds) setLinksToCouple.add (mapOldId2Link.get(oldLinkId));
mapOldId2MulticastDemand.get(lowerLayerMulticastDemandId).couple(setLinksToCouple);
break;
default:
throw new RuntimeException("Bad");
}
break;
case XMLEvent.END_ELEMENT:
String endElementName = xmlStreamReader.getName().toString();
if (endElementName.equals("network"))
{
// if (!netPlan.hasReadLayerZero && netPlan.layers.size() > 1) netPlan.removeNetworkLayer (netPlan.layers.get(0));
return;
}
break;
}
}
throw new RuntimeException("'Network' element not parsed correctly (end tag not found)");
}
示例8: parseProtectionSegment
import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseProtectionSegment(NetPlan netPlan, long layerId, XMLStreamReader2 xmlStreamReader) throws XMLStreamException
{
long segmentId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "id"));
double reservedCapacity = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "reservedCapacity"));
List<Long> seqLinks = LongUtils.toList(xmlStreamReader.getAttributeAsLongArray(xmlStreamReader.getAttributeIndex(null, "seqLinks")));
// netPlan.nextSegmentId.put(layerId, segmentId);
List<Link> newSeqLinks = new LinkedList<Link> (); for (long linkId : seqLinks) newSeqLinks.add (mapOldId2Link.get(linkId));
// ProtectionSegment newSegment = netPlan.addProtectionSegment(newSeqLinks, reservedCapacity, null);
// mapOldId2ProtectionSegment.put (segmentId , newSegment);
while(xmlStreamReader.hasNext())
{
xmlStreamReader.next();
switch(xmlStreamReader.getEventType())
{
case XMLEvent.START_ELEMENT:
String startElementName = xmlStreamReader.getName().toString();
switch(startElementName)
{
case "attribute":
String key = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "key"));
String name = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "value"));
// newSegment.setAttribute(key, name);
break;
default:
throw new RuntimeException("Bad");
}
break;
case XMLEvent.END_ELEMENT:
String endElementName = xmlStreamReader.getName().toString();
if (endElementName.equals("protectionSegment")) return;
break;
}
}
throw new RuntimeException("'Protection segment' element not parsed correctly (end tag not found)");
}
示例9: parseNode
import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseNode(NetPlan netPlan, XMLStreamReader2 xmlStreamReader) throws XMLStreamException
{
long nodeId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "id"));
double xCoord = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "xCoord"));
double yCoord = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "yCoord"));
String nodeName = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "name"));
boolean isUp = true; try { isUp = xmlStreamReader.getAttributeAsBoolean(xmlStreamReader.getAttributeIndex(null, "isUp")); } catch (Exception e) {}
//netPlan.nextNodeId = new MutableLong(nodeId);
Node newNode = netPlan.addNode(xCoord, yCoord, nodeName, null);
newNode.setFailureState(isUp);
mapOldId2Node.put (nodeId , newNode);
while(xmlStreamReader.hasNext())
{
xmlStreamReader.next();
switch(xmlStreamReader.getEventType())
{
case XMLEvent.START_ELEMENT:
String startElementName = xmlStreamReader.getName().toString();
switch(startElementName)
{
case "attribute":
String key = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "key"));
String name = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "value"));
newNode.setAttribute(key, name);
break;
default:
throw new RuntimeException("Bad");
}
break;
case XMLEvent.END_ELEMENT:
String endElementName = xmlStreamReader.getName().toString();
if (endElementName.equals("node")) return;
break;
}
}
throw new RuntimeException("'Node' element not parsed correctly (end tag not found)");
}
示例10: parseDemand
import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseDemand(NetPlan netPlan, long layerId, XMLStreamReader2 xmlStreamReader) throws XMLStreamException
{
long demandId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "id"));
long ingressNodeId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "ingressNodeId"));
long egressNodeId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "egressNodeId"));
double offeredTraffic = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "offeredTraffic"));
// netPlan.nextDemandId.put(layerId, demandId);
Demand newDemand = netPlan.addDemand(mapOldId2Node.get(ingressNodeId), mapOldId2Node.get(egressNodeId), offeredTraffic, null , mapOldId2Layer.get(layerId));
mapOldId2Demand.put (demandId , newDemand);
while(xmlStreamReader.hasNext())
{
xmlStreamReader.next();
switch(xmlStreamReader.getEventType())
{
case XMLEvent.START_ELEMENT:
String startElementName = xmlStreamReader.getName().toString();
switch(startElementName)
{
case "attribute":
String key = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "key"));
String name = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "value"));
if (key.equals(KEY_STRING_BIDIRECTIONALCOUPLE)) name = "" + mapOldId2Demand.get(Long.parseLong(name)).getId();
newDemand.setAttribute(key, name);
break;
default:
throw new RuntimeException("Bad");
}
break;
case XMLEvent.END_ELEMENT:
String endElementName = xmlStreamReader.getName().toString();
if (endElementName.equals("demand")) return;
break;
}
}
throw new RuntimeException("'Demand' element not parsed correctly (end tag not found)");
}
示例11: parseLink
import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseLink(NetPlan netPlan, long layerId, XMLStreamReader2 xmlStreamReader) throws XMLStreamException
{
long linkId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "id"));
long originNodeId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "originNodeId"));
long destinationNodeId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "destinationNodeId"));
double capacity = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "capacity"));
double lengthInKm = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "lengthInKm"));
double propagationSpeedInKmPerSecond = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "propagationSpeedInKmPerSecond"));
boolean isUp = true; try { isUp = xmlStreamReader.getAttributeAsBoolean(xmlStreamReader.getAttributeIndex(null, "isUp")); } catch (Exception e) {}
Link newLink = netPlan.addLink(mapOldId2Node.get(originNodeId), mapOldId2Node.get(destinationNodeId), capacity, lengthInKm, propagationSpeedInKmPerSecond, null , mapOldId2Layer.get (layerId));
mapOldId2Link.put (linkId , newLink);
newLink.setFailureState(isUp);
while(xmlStreamReader.hasNext())
{
xmlStreamReader.next();
switch(xmlStreamReader.getEventType())
{
case XMLEvent.START_ELEMENT:
String startElementName = xmlStreamReader.getName().toString();
switch(startElementName)
{
case "attribute":
String key = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "key"));
String name = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "value"));
if (key.equals(KEY_STRING_BIDIRECTIONALCOUPLE)) name = "" + mapOldId2Link.get(Long.parseLong(name)).getId();
newLink.setAttribute(key, name);
break;
default:
throw new RuntimeException("Bad");
}
break;
case XMLEvent.END_ELEMENT:
String endElementName = xmlStreamReader.getName().toString();
if (endElementName.equals("link")) return;
break;
}
}
throw new RuntimeException("'Link' element not parsed correctly (end tag not found)");
}
示例12: parseSRG
import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseSRG(NetPlan netPlan, XMLStreamReader2 xmlStreamReader) throws XMLStreamException
{
long srgId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "id"));
double meanTimeToFailInHours = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "meanTimeToFailInHours"));
double meanTimeToRepairInHours = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "meanTimeToRepairInHours"));
SharedRiskGroup newSRG = netPlan.addSRG(meanTimeToFailInHours, meanTimeToRepairInHours, null);
mapOldId2Srg.put (srgId , newSRG);
while(xmlStreamReader.hasNext())
{
xmlStreamReader.next();
switch(xmlStreamReader.getEventType())
{
case XMLEvent.START_ELEMENT:
String startElementName = xmlStreamReader.getName().toString();
switch(startElementName)
{
case "attribute":
String key = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "key"));
String name = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "value"));
newSRG.setAttribute(key, name);
break;
case "node":
long nodeId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "id"));
newSRG.addNode(mapOldId2Node.get(nodeId));
break;
case "link":
// long layerId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "layerId"));
long linkId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "linkId"));
newSRG.addLink(mapOldId2Link.get(linkId));
break;
default:
throw new RuntimeException("Bad");
}
break;
case XMLEvent.END_ELEMENT:
String endElementName = xmlStreamReader.getName().toString();
if (endElementName.equals("srg")) return;
break;
}
}
throw new RuntimeException("'SRG' element not parsed correctly (end tag not found)");
}
示例13: parseMulticastDemand
import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseMulticastDemand(NetPlan netPlan, long layerId, XMLStreamReader2 xmlStreamReader) throws XMLStreamException
{
long demandId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "id"));
long ingressNodeId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "ingressNodeId"));
Set<Long> egressNodeIds = new HashSet <Long>(LongUtils.toList(xmlStreamReader.getAttributeAsLongArray(xmlStreamReader.getAttributeIndex(null, "egressNodeIds"))));
Set<Node> newEgressNodes = new HashSet<Node> (); for (long nodeId : egressNodeIds) newEgressNodes.add (mapOldId2Node.get(nodeId));
double offeredTraffic = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "offeredTraffic"));
MulticastDemand newDemand = netPlan.addMulticastDemand(mapOldId2Node.get(ingressNodeId), newEgressNodes , offeredTraffic, null , mapOldId2Layer.get(layerId));
mapOldId2MulticastDemand.put (demandId , newDemand);
while(xmlStreamReader.hasNext())
{
xmlStreamReader.next();
switch(xmlStreamReader.getEventType())
{
case XMLEvent.START_ELEMENT:
String startElementName = xmlStreamReader.getName().toString();
switch(startElementName)
{
case "attribute":
String key = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "key"));
String name = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "value"));
newDemand.setAttribute(key, name);
break;
default:
throw new RuntimeException("Bad");
}
break;
case XMLEvent.END_ELEMENT:
String endElementName = xmlStreamReader.getName().toString();
if (endElementName.equals("multicastDemand")) return;
break;
}
}
throw new RuntimeException("'MulticastDemand' element not parsed correctly (end tag not found)");
}
示例14: parseDemand
import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseDemand(NetPlan netPlan, long layerId, XMLStreamReader2 xmlStreamReader) throws XMLStreamException
{
long demandId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "id"));
long ingressNodeId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "ingressNodeId"));
long egressNodeId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "egressNodeId"));
double offeredTraffic = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "offeredTraffic"));
// netPlan.nextDemandId.put(layerId, demandId);
Demand newDemand = netPlan.addDemand(mapOldId2Node.get(ingressNodeId), mapOldId2Node.get(egressNodeId), offeredTraffic, null , mapOldId2Layer.get(layerId));
mapOldId2Demand.put (Pair.of (layerId , demandId) , newDemand);
while(xmlStreamReader.hasNext())
{
xmlStreamReader.next();
switch(xmlStreamReader.getEventType())
{
case XMLEvent.START_ELEMENT:
String startElementName = xmlStreamReader.getName().toString();
switch(startElementName)
{
case "attribute":
String key = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "key"));
String name = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "value"));
newDemand.setAttribute(key, name);
break;
default:
throw new RuntimeException("Bad");
}
break;
case XMLEvent.END_ELEMENT:
String endElementName = xmlStreamReader.getName().toString();
if (endElementName.equals("demand")) return;
break;
}
}
throw new RuntimeException("'Demand' element not parsed correctly (end tag not found)");
}
示例15: parseLink
import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseLink(NetPlan netPlan, long layerId, XMLStreamReader2 xmlStreamReader) throws XMLStreamException
{
long linkId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "id"));
long originNodeId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "originNodeId"));
long destinationNodeId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "destinationNodeId"));
double capacity = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "capacity"));
double lengthInKm = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "lengthInKm"));
double propagationSpeedInKmPerSecond = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "propagationSpeedInKmPerSecond"));
// netPlan.nextLinkId.put(layerId, linkId);
Link newLink = netPlan.addLink(mapOldId2Node.get(originNodeId), mapOldId2Node.get(destinationNodeId), capacity, lengthInKm, propagationSpeedInKmPerSecond, null , mapOldId2Layer.get (layerId));
mapOldId2Link.put (Pair.of (layerId , linkId) , newLink);
while(xmlStreamReader.hasNext())
{
xmlStreamReader.next();
switch(xmlStreamReader.getEventType())
{
case XMLEvent.START_ELEMENT:
String startElementName = xmlStreamReader.getName().toString();
switch(startElementName)
{
case "attribute":
String key = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "key"));
String name = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "value"));
newLink.setAttribute(key, name);
break;
default:
throw new RuntimeException("Bad");
}
break;
case XMLEvent.END_ELEMENT:
String endElementName = xmlStreamReader.getName().toString();
if (endElementName.equals("link")) return;
break;
}
}
throw new RuntimeException("'Link' element not parsed correctly (end tag not found)");
}