Search in sources :

Example 1 with DataSourceField

use of com.sldeditor.common.datasource.DataSourceField in project sldeditor by robward-scisys.

the class MXDParser method processFields.

/**
 * Process fields.
 *
 * @param layerName the layer name
 * @param fieldArrayElement the field array element
 * @return the list
 */
private List<DataSourceFieldInterface> processFields(String layerName, JsonElement fieldArrayElement) {
    List<DataSourceFieldInterface> fieldList = new ArrayList<DataSourceFieldInterface>();
    if (fieldArrayElement != null) {
        JsonArray fieldArray = fieldArrayElement.getAsJsonArray();
        for (int index = 0; index < fieldArray.size(); index++) {
            JsonObject fieldObject = null;
            try {
                fieldObject = fieldArray.get(index).getAsJsonObject();
            } catch (IllegalStateException e) {
                ConsoleManager.getInstance().error(this, "Layer : " + layerName);
                ConsoleManager.getInstance().exception(this, e);
            }
            if (fieldObject != null) {
                Class<?> fieldType = convertFieldType(fieldObject.get("type").getAsString());
                DataSourceField esriField = new DataSourceField(fieldObject.get("field").getAsString(), fieldType);
                fieldList.add(esriField);
            }
        }
    }
    return fieldList;
}
Also used : JsonArray(com.google.gson.JsonArray) DataSourceFieldInterface(com.sldeditor.common.datasource.DataSourceFieldInterface) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) DataSourceField(com.sldeditor.common.datasource.DataSourceField)

Aggregations

JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 DataSourceField (com.sldeditor.common.datasource.DataSourceField)1 DataSourceFieldInterface (com.sldeditor.common.datasource.DataSourceFieldInterface)1 ArrayList (java.util.ArrayList)1