OperationDefn.java [src/config/nodes] Revision: default Date:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package config.nodes;
import java.util.HashMap;
import java.util.Map;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import static utils.Constants.*;
/**
*
* @author Brad
*/
public class OperationDefn {
Map<Identity, OpActionFormat> actionFormats;
public OperationDefn() {
actionFormats = new HashMap<>();
}
public OpActionFormat getActionFormat(Identity identity) {
return actionFormats.get(identity);
}
public void parse(XMLEventReader reader) throws XMLStreamException {
XMLEvent event;
OpActionFormat actionformat = null;
StartElement startElement;
while (reader.hasNext()) {
event = reader.nextEvent();
switch (event.getEventType()) {
case XMLStreamConstants.START_ELEMENT:
startElement = event.asStartElement();
if (startElement.getName().getLocalPart().equals(ACTION)) {
actionformat = new OpActionFormat();
actionformat.parse(reader);
actionFormats.put(actionformat.getIdentityFormat(), actionformat);
}
break;
}
}
}
}