FeatureType.java

  1. package de.turnertech.ows.gml;

  2. import java.util.ArrayList;
  3. import java.util.Collection;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.Map;

  7. import de.turnertech.ows.srs.SpatialReferenceSystem;

  8. public class FeatureType {
  9.    
  10.     /**
  11.      * The "type name". This is the parameter which will be used in requests usw.
  12.      */
  13.     private final String name;

  14.     private final String namespace;

  15.     private final Map<String, FeatureProperty> featureTypeProperties;

  16.     private SpatialReferenceSystem srs;

  17.     private String title;

  18.     private String description;

  19.     public FeatureType(String namespace, String name) {
  20.         this.namespace = namespace;
  21.         this.name = name;
  22.         this.featureTypeProperties = new HashMap<>();
  23.     }

  24.     /**
  25.      * @return the name
  26.      */
  27.     public String getName() {
  28.         return name;
  29.     }

  30.     /**
  31.      * @return the namespace
  32.      */
  33.     public String getNamespace() {
  34.         return namespace;
  35.     }

  36.     /**
  37.      * @return the title
  38.      */
  39.     public String getTitle() {
  40.         return title;
  41.     }

  42.     /**
  43.      * @param title the title to set
  44.      */
  45.     public void setTitle(String title) {
  46.         this.title = title;
  47.     }

  48.     /**
  49.      * @return the srs
  50.      */
  51.     public SpatialReferenceSystem getSrs() {
  52.         return srs;
  53.     }

  54.     /**
  55.      * @param srs the srs to set
  56.      */
  57.     public void setSrs(SpatialReferenceSystem srs) {
  58.         this.srs = srs;
  59.     }

  60.     public String getDescription() {
  61.         return description;
  62.     }

  63.     public void setDescription(String description) {
  64.         this.description = description;
  65.     }

  66.     public Feature createInstance() {
  67.         return new Feature(this);
  68.     }

  69.     public FeatureProperty getIdProperty() {
  70.         for(FeatureProperty property : featureTypeProperties.values()) {
  71.             if(property.getPropertyType() == FeaturePropertyType.ID) return property;
  72.         }
  73.         return null;
  74.     }

  75.     public List<FeatureProperty> getBoundingBoxProperties() {
  76.         List<FeatureProperty> returnList = new ArrayList<>(1);
  77.         for(FeatureProperty property : featureTypeProperties.values()) {
  78.             if(property.getPropertyType().isBoundingBoxProvider()) {
  79.                 returnList.add(property);
  80.             }
  81.         }
  82.         return returnList;
  83.     }

  84.     public FeatureProperty getProperty(String propertyName) {
  85.         return featureTypeProperties.get(propertyName);
  86.     }

  87.     public Collection<FeatureProperty> getProperties() {
  88.         return featureTypeProperties.values();
  89.     }

  90.     public boolean hasProperty(String propertyName) {
  91.         return featureTypeProperties.containsKey(propertyName);
  92.     }

  93.     public FeatureProperty putProperty(FeatureProperty value) {
  94.         return featureTypeProperties.put(value.getName(), value);
  95.     }

  96. }