diff --git a/src/main/java/it/geosolutions/geoserver/rest/decoder/RESTFeatureType.java b/src/main/java/it/geosolutions/geoserver/rest/decoder/RESTFeatureType.java index b5c34f5..5e8f0b2 100644 --- a/src/main/java/it/geosolutions/geoserver/rest/decoder/RESTFeatureType.java +++ b/src/main/java/it/geosolutions/geoserver/rest/decoder/RESTFeatureType.java @@ -27,8 +27,14 @@ package it.geosolutions.geoserver.rest.decoder; import it.geosolutions.geoserver.rest.decoder.utils.JDOMBuilder; import it.geosolutions.geoserver.rest.decoder.utils.JDOMListIterator; +import it.geosolutions.geoserver.rest.encoder.feature.FeatureTypeAttribute; +import it.geosolutions.geoserver.rest.encoder.feature.GSAttributeEncoder; +import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; +import java.util.List; +import java.util.Map; import org.jdom.Element; /** @@ -244,4 +250,50 @@ public class RESTFeatureType extends RESTResource { } }; } + + /** + * @return + */ + public List> getAttributeList() { + List> attrsList = null; + + final Element attrsRoot = rootElem.getChild("attributes"); + if(attrsRoot!=null){ + final List attrs = attrsRoot.getChildren(); + if (attrs != null) { + attrsList = new ArrayList>(attrs.size()); + for (Element attr : attrs) { + Map attrsMap = new HashMap(); + attrsList.add(attrsMap); + for (FeatureTypeAttribute at : FeatureTypeAttribute.values()) { + String key = at.toString(); + attrsMap.put(at, attr.getChildText(key)); + } + } + } + } + return attrsList; + } + + public List getEncodedAttributeList() { + List attrsList = null; + + final Element attrsRoot = rootElem.getChild("attributes"); + if(attrsRoot!=null){ + final List attrs = attrsRoot.getChildren(); + if (attrs != null) { + attrsList = new ArrayList(attrs.size()); + for (Element attr : attrs) { + final GSAttributeEncoder attrEnc = new GSAttributeEncoder(); + for (FeatureTypeAttribute at : FeatureTypeAttribute.values()) { + String key = at.toString(); + attrEnc.setAttribute(at, attr.getChildText(key)); + } + attrsList.add(attrEnc); + } + + } + } + return attrsList; + } } diff --git a/src/main/java/it/geosolutions/geoserver/rest/decoder/RESTResource.java b/src/main/java/it/geosolutions/geoserver/rest/decoder/RESTResource.java index 9de1981..a6f3411 100644 --- a/src/main/java/it/geosolutions/geoserver/rest/decoder/RESTResource.java +++ b/src/main/java/it/geosolutions/geoserver/rest/decoder/RESTResource.java @@ -133,43 +133,22 @@ public class RESTResource { return getLatLonEdge("maxy"); } + /** + * @deprecated use {@link RESTFeatureType#getAttributeList()} + * @return + * @throws UnsupportedOperationException + */ public List> getAttributeList() { - List> attrsList = null; - - final Element attrsRoot = rootElem.getChild("attributes"); - final List attrs = attrsRoot.getChildren(); - if (attrs != null) { - attrsList = new ArrayList>(attrs.size()); - for (Element attr : attrs) { - Map attrsMap = new HashMap(); - attrsList.add(attrsMap); - for (FeatureTypeAttribute at : FeatureTypeAttribute.values()) { - String key = at.toString(); - attrsMap.put(at, attr.getChildText(key)); - } - } - } - return attrsList; + throw new UnsupportedOperationException("This method is specific for RESTFeatureType"); } + /** + * @deprecated use {@link RESTFeatureType#getEncodedAttributeList()} + * @return + * @throws UnsupportedOperationException + */ public List getEncodedAttributeList() { - List attrsList = null; - - final Element attrsRoot = rootElem.getChild("attributes"); - final List attrs = attrsRoot.getChildren(); - if (attrs != null) { - attrsList = new ArrayList(attrs.size()); - for (Element attr : attrs) { - final GSAttributeEncoder attrEnc = new GSAttributeEncoder(); - for (FeatureTypeAttribute at : FeatureTypeAttribute.values()) { - String key = at.toString(); - attrEnc.setAttribute(at, attr.getChildText(key)); - } - attrsList.add(attrEnc); - } - - } - return attrsList; + throw new UnsupportedOperationException("This method is specific for RESTFeatureType"); } @@ -198,43 +177,4 @@ public class RESTResource { return metaLinksList; } - // /** - // * @return the list of available attribute names - // */ - // public List getAttributeNames() { - // return getAttributes("name"); - // } - // - // /** - // * @return a list of object which are String representation of Classes - // */ - // public List getAttributeBinding() { - // return getAttributes("binding"); - // } - - // /** - // *
- // * NATION
- // * 0
- // * 1
- // * true
- // * java.lang.Integer
- // * 3
- // *

- // * - // * @param name - // * @return - // */ - // private List getAttributes(String name) { - // final Element attrsRoot = rootElem.getChild("attributes"); - // final List attrs = attrsRoot.getChildren(); - // List attrNames = null; - // if (attrs != null) { - // attrNames = new ArrayList(attrs.size()); - // for (Element attr : attrs) { - // attrNames.add(attr.getChildText(name)); - // } - // } - // return attrNames; - // } }