net.anotheria.asg.generator.parser.XMLFormParser Maven / Gradle / Ivy
package net.anotheria.asg.generator.parser;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import net.anotheria.asg.generator.forms.meta.MetaForm;
import net.anotheria.asg.generator.forms.meta.MetaFormField;
import net.anotheria.asg.generator.forms.meta.MetaFormSingleField;
import net.anotheria.asg.generator.forms.meta.MetaFormTableColumn;
import net.anotheria.asg.generator.forms.meta.MetaFormTableField;
import net.anotheria.asg.generator.forms.meta.MetaFormTableHeader;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
/**
* Parser for the forms.
* @author another
*/
public final class XMLFormParser {
public static final List parseForms(String content){
SAXBuilder reader = new SAXBuilder();
reader.setValidation(false);
List ret = new ArrayList();
try{
Document doc = reader.build(new StringReader(content));
Element root = doc.getRootElement();
@SuppressWarnings("unchecked")List forms = root.getChildren("form");
for (int i=0; i formFields = parseFields(fields);
form.setElements(formFields);
form.setTargets(parseTargets(formElement));
form.setAction(formElement.getAttributeValue("action"));
return form;
}
private static List parseTargets(Element formElement){
@SuppressWarnings("unchecked")List targets = formElement.getChildren("target");
List ret = new ArrayList(targets.size());
for (int i=0; i parseFields(Element fields){
@SuppressWarnings("unchecked")List fieldElements = fields.getChildren("field");
List ret = new ArrayList(fieldElements.size());
for (int i=0; i columns = table.getChildren("column");
for (int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy