Class Utilities
- java.lang.Object
-
- org.hortonmachine.gears.io.geopaparazzi.forms.Utilities
-
public class Utilities extends Object
Form utilities- Author:
- Andrea Antonello (www.hydrologis.com)
-
-
Field Summary
Fields Modifier and Type Field Description static StringATTR_FORMNAMEstatic StringATTR_FORMSstatic StringATTR_SECTIONNAMEstatic StringATTR_SECTIONOBJECTSTRstatic StringIMAGES_SEPARATORstatic String[]ITEM_NAMESstatic StringTAG_FORMITEMSstatic StringTAG_FORMSstatic StringTAG_ISLABELstatic StringTAG_ISMANDATORYstatic StringTAG_ITEMstatic StringTAG_ITEMSstatic StringTAG_KEYstatic StringTAG_LABELstatic StringTAG_LONGNAMEstatic StringTAG_RANGEstatic StringTAG_READONLYstatic StringTAG_SHORTNAMEstatic StringTAG_SIZEstatic StringTAG_TYPEstatic StringTAG_URLstatic StringTAG_VALUEstatic StringTAG_VALUESstatic StringTYPE_IMAGELIBType for image from library element.static StringTYPE_MAPType for map element.static StringTYPE_PICTURESType for pictures element.static StringTYPE_SKETCHType for pictures element.
-
Constructor Summary
Constructors Constructor Description Utilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.json.JSONArrayformsRootFromSectionsMap(HashMap<String,org.json.JSONObject> sectionsMap)Create the forms root json object from the map of sections json objects.static org.json.JSONObjectgetForm4Name(String formName, org.json.JSONObject section)static org.json.JSONArraygetFormItems(org.json.JSONObject formObj)Utility method to get the formitems of a form object.static List<String>getFormNames4Section(org.json.JSONObject section)static List<String>getImageIds(String formString)Get the images paths out of a form string.static LinkedHashMap<String,org.json.JSONObject>getSectionFromFile(String formPath)static LinkedHashMap<String,org.json.JSONObject>getSectionsFromJsonString(String formJsonString)static booleanisDoubleType(String type)static booleanisIntegerType(String type)static booleanisMediaType(String type)static booleanisStringType(String type)static voidproperties2Mainframe(MainFrame mainFrame, File templateFile)static voidremoveFormFromSection(String formName, org.json.JSONObject section)
-
-
-
Field Detail
-
ATTR_SECTIONNAME
public static final String ATTR_SECTIONNAME
- See Also:
- Constant Field Values
-
ATTR_SECTIONOBJECTSTR
public static final String ATTR_SECTIONOBJECTSTR
- See Also:
- Constant Field Values
-
ATTR_FORMS
public static final String ATTR_FORMS
- See Also:
- Constant Field Values
-
ATTR_FORMNAME
public static final String ATTR_FORMNAME
- See Also:
- Constant Field Values
-
TAG_LONGNAME
public static final String TAG_LONGNAME
- See Also:
- Constant Field Values
-
TAG_SHORTNAME
public static final String TAG_SHORTNAME
- See Also:
- Constant Field Values
-
TAG_FORMS
public static final String TAG_FORMS
- See Also:
- Constant Field Values
-
TAG_FORMITEMS
public static final String TAG_FORMITEMS
- See Also:
- Constant Field Values
-
TAG_KEY
public static final String TAG_KEY
- See Also:
- Constant Field Values
-
TAG_VALUE
public static final String TAG_VALUE
- See Also:
- Constant Field Values
-
TAG_VALUES
public static final String TAG_VALUES
- See Also:
- Constant Field Values
-
TAG_ITEMS
public static final String TAG_ITEMS
- See Also:
- Constant Field Values
-
TAG_ITEM
public static final String TAG_ITEM
- See Also:
- Constant Field Values
-
TAG_TYPE
public static final String TAG_TYPE
- See Also:
- Constant Field Values
-
TAG_READONLY
public static final String TAG_READONLY
- See Also:
- Constant Field Values
-
TAG_SIZE
public static final String TAG_SIZE
- See Also:
- Constant Field Values
-
TAG_URL
public static final String TAG_URL
- See Also:
- Constant Field Values
-
TAG_LABEL
public static final String TAG_LABEL
- See Also:
- Constant Field Values
-
TAG_ISLABEL
public static final String TAG_ISLABEL
- See Also:
- Constant Field Values
-
TAG_ISMANDATORY
public static final String TAG_ISMANDATORY
- See Also:
- Constant Field Values
-
TAG_RANGE
public static final String TAG_RANGE
- See Also:
- Constant Field Values
-
IMAGES_SEPARATOR
public static final String IMAGES_SEPARATOR
- See Also:
- Constant Field Values
-
TYPE_PICTURES
public static final String TYPE_PICTURES
Type for pictures element.- See Also:
- Constant Field Values
-
TYPE_SKETCH
public static final String TYPE_SKETCH
Type for pictures element.- See Also:
- Constant Field Values
-
TYPE_IMAGELIB
public static final String TYPE_IMAGELIB
Type for image from library element.- See Also:
- Constant Field Values
-
TYPE_MAP
public static final String TYPE_MAP
Type for map element.- See Also:
- Constant Field Values
-
ITEM_NAMES
public static final String[] ITEM_NAMES
-
-
Method Detail
-
isStringType
public static boolean isStringType(String type)
-
isIntegerType
public static boolean isIntegerType(String type)
-
isDoubleType
public static boolean isDoubleType(String type)
-
isMediaType
public static boolean isMediaType(String type)
-
getSectionFromFile
public static LinkedHashMap<String,org.json.JSONObject> getSectionFromFile(String formPath) throws IOException
- Throws:
IOException
-
getSectionsFromJsonString
public static LinkedHashMap<String,org.json.JSONObject> getSectionsFromJsonString(String formJsonString)
-
properties2Mainframe
public static void properties2Mainframe(MainFrame mainFrame, File templateFile) throws Exception
- Throws:
Exception
-
getFormNames4Section
public static List<String> getFormNames4Section(org.json.JSONObject section) throws org.json.JSONException
- Throws:
org.json.JSONException
-
getForm4Name
public static org.json.JSONObject getForm4Name(String formName, org.json.JSONObject section) throws org.json.JSONException
- Throws:
org.json.JSONException
-
removeFormFromSection
public static void removeFormFromSection(String formName, org.json.JSONObject section) throws org.json.JSONException
- Throws:
org.json.JSONException
-
getFormItems
public static org.json.JSONArray getFormItems(org.json.JSONObject formObj) throws org.json.JSONExceptionUtility method to get the formitems of a form object.Note that the entering json object has to be one object of the main array, not THE main array itself, i.e. a choice was already done.
- Parameters:
jsonObj- the single object.- Returns:
- the array of items of the contained form or
nullif no form is contained. - Throws:
org.json.JSONException
-
getImageIds
public static List<String> getImageIds(String formString) throws Exception
Get the images paths out of a form string.- Parameters:
formString- the form.- Returns:
- the list of images paths.
- Throws:
Exception- if something goes wrong.
-
formsRootFromSectionsMap
public static org.json.JSONArray formsRootFromSectionsMap(HashMap<String,org.json.JSONObject> sectionsMap)
Create the forms root json object from the map of sections json objects.- Parameters:
sectionsMap- the json sections map.- Returns:
- the root object that can be dumped to file through the toString method.
-
-