@@ -0,0 +1,1584 @@
+package org.azavea.otm;%0A%0Aimport java.io.InputStream;%0Aimport java.util.ArrayList;%0A%0Aimport javax.xml.parsers.DocumentBuilder;%0Aimport javax.xml.parsers.DocumentBuilderFactory;%0A%0Aimport org.w3c.dom.Document;%0Aimport org.w3c.dom.Node;%0Aimport org.w3c.dom.NodeList;%0A%0Aimport android.content.Context;%0A%0A%0Apublic class FieldManager %7B%0A%09private Context context;%0A%09%0A%09// All fields loaded from configuration file%0A%09private  ArrayList%3CFieldGroup%3E allFields = new ArrayList%3CFieldGroup%3E();%0A%09%0A%09%0A%09public FieldManager(Context context) throws Exception %7B%0A%09%09this.context = context;%0A%09%09loadFilterDefinitions();%0A%09%7D%0A%09%0A%09private void loadFilterDefinitions() throws Exception %7B%0A%09%09// Load the field definitions from the included XML resource, and parse them %0A%09%09// into field objects%0A%09%09InputStream filterFile = context.getResources().openRawResource(R.raw.configuration);%0A%09%09try %7B%0A%09%09%09DocumentBuilder xml = DocumentBuilderFactory.newInstance().newDocumentBuilder();%0A%09%09%09Document doc = xml.parse(filterFile);%0A%09%09%09NodeList fields = doc.getElementsByTagName(%22fieldGroup%22);%0A%09%09%09for (int i=0; i %3C fields.getLength(); i++) %7B%0A%09%09%09%09Node fieldGroup = fields.item(i);%0A%09%09%09%09%0A%09%09%09%09Node name = fieldGroup.getAttributes().getNamedItem(%22name%22);%0A%09%09%09%09String groupName = name == null ? null : name.getNodeValue();%0A%09%09%09%09%0A%09%09%09%09FieldGroup group = new FieldGroup(groupName);%0A%09%09%09%09group.addFields(fieldGroup.getChildNodes());%0A%09%09%09%09allFields.add(group);%0A%09%09%09%7D%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09throw new Exception(%22Invalid field xml file%22, e);%0A%09%09%7D%0A%09%7D%0A%09%0A%09public FieldGroup%5B%5D getFieldGroups() %7B%0A%09%09return allFields.toArray(new FieldGroup%5BallFields.size()%5D);%0A%09%7D%0A%09%0A%7D%0A%09

Add Manager for Fields