public static ItemKind fromValue(String v) { for (ItemKind c : ItemKind.values()) { if (c.value.equalsIgnoreCase(v)) { return c; } } throw new IllegalArgumentException(v); }
/** * @param shape * @return */ protected List<Property> createPropertiesList(GenericShape shape) { ArrayList<Property> propertiesList = new ArrayList<Property>(); String propertiesString = shape.getProperty("properties"); if (propertiesString != null && !(propertiesString.length() == 0)) { try { JSONObject propertyObject = new JSONObject(propertiesString); JSONArray propertyItems = propertyObject.getJSONArray("items"); /* * Retrieve property definitions and process * them. */ for (int i = 0; i < propertyItems.length(); i++) { JSONObject propertyItem = propertyItems.getJSONObject(i); Property property = new Property(); /* Name */ String name = propertyItem.getString("name"); if (name != null && !(name.length() == 0)) property.setName(name); /* Data State */ String dataState = propertyItem.getString("datastate"); if (dataState != null && !(dataState.length() == 0)) property.setDataState(new DataState(dataState)); /* ItemKind */ String itemKind = propertyItem.getString("itemkind"); if (itemKind != null && !(itemKind.length() == 0)) property.setItemKind(ItemKind.fromValue(itemKind)); /* Structure */ String structureString = propertyItem.getString("structure"); if (structureString != null && !(structureString.length() == 0)) property.setStructure(structureString); /* isCollection */ String isCollection = propertyItem.getString("iscollection"); if (isCollection != null && isCollection.equalsIgnoreCase("false")) property.setCollection(false); else property.setCollection(true); propertiesList.add(property); } } catch (Exception e) { e.printStackTrace(); } } return propertiesList; }