ManActionFormat.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.ArrayList;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.EndElement;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import static utils.Constants.*;
/**
*
* @author Brad
*/
public class ManActionFormat {
private Identity identity;
private final ArrayList<ParamFormatLine> formatLines;
public ManActionFormat() {
formatLines = new ArrayList<>();
}
public ArrayList<ParamFormatLine> getFormatLines() {
return formatLines;
}
public Identity getIdentity() {
return identity;
}
public String parse(XMLEventReader reader) throws XMLStreamException {
XMLEvent event;
boolean done = false;
ParamFormatLine paramFormatLine;
StartElement startElement;
EndElement endElement;
String symbol;
String variable = "";
while (reader.hasNext() && !done) {
event = reader.nextEvent();
switch (event.getEventType()) {
case XMLStreamConstants.START_ELEMENT:
startElement = event.asStartElement();
if (startElement.getName().getLocalPart().equals(IDENTITY)) {
identity = new Identity();
identity.parse(reader);
}
if (startElement.getName().getLocalPart().equals(PARAMFORMATLINE)) {
symbol = startElement.getAttributeByName(new QName(SYMBOL)).getValue();
paramFormatLine = new ParamFormatLine(symbol);
variable = paramFormatLine.parse(reader);
formatLines.add(paramFormatLine);
}
break;
case XMLStreamConstants.END_ELEMENT:
endElement = event.asEndElement();
if (endElement.getName().getLocalPart().equals(ACTIONFORMAT))
done = true;
break;
}
}
return variable;
}
}