ParamFormatLine.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.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 ParamFormatLine {
private String symbol;
private ArrayList<String> parameterNames;
public ParamFormatLine(String symbol) {
parameterNames = new ArrayList<>();
this.symbol = symbol;
}
public String getSymbol() {
return symbol;
}
public ArrayList<String> getParameterNames() {
return parameterNames;
}
public String parse(XMLEventReader reader) throws XMLStreamException {
XMLEvent event;
boolean done = false;
StartElement startElement;
EndElement endElement;
String variable = "";
while (reader.hasNext() && !done) {
event = reader.nextEvent();
switch (event.getEventType()) {
case XMLStreamConstants.START_ELEMENT:
startElement = event.asStartElement();
if (startElement.getName().getLocalPart().equals(PARAMNAME)) {
variable = reader.getElementText();
parameterNames.add(variable);
}
break;
case XMLStreamConstants.END_ELEMENT:
endElement = event.asEndElement();
if (endElement.getName().getLocalPart().equals(PARAMFORMATLINE))
done = true;
}
}
return variable;
}
}