CropDefn.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.StartElement;
import javax.xml.stream.events.XMLEvent;
import static utils.Constants.*;
/**
*
* @author Brad
*/
public class CropDefn {
private final ArrayList<ParamDefn> paramDefns;
public CropDefn() {
paramDefns = new ArrayList<>();
}
public void parse(XMLEventReader reader) throws XMLStreamException {
XMLEvent event;
ParamDefn paramDefn;
StartElement startElement;
while (reader.hasNext()) {
event = reader.nextEvent();
switch (event.getEventType()) {
case XMLStreamConstants.START_ELEMENT:
startElement = event.asStartElement();
if (startElement.getName().getLocalPart().equals(PARAMDEFN)) {
paramDefn = new ParamDefn();
paramDefn.parse(reader);
paramDefns.add(paramDefn);
}
break;
}
}
}
}