/*This code was generated using the UMPLE modeling language!
 Date of generation: 2008/07/29 15:15:39*/
/*This class drives: */

package GIS.core;

import GIS.*;
import GIS.json.*;

public class Feature {
  //Class datatypes
  private String name;

  //Class association variables
  private Map map;

  private FeatureType featureType;

  //Registry of our system.
  GISRegistry registry = GISRegistry.getInstance();

  //Constructor
  public Feature(String aName, Map aMap, FeatureType aFeatureType) {
    name = aName;
    map = aMap;
    map.addFeature(this);

    featureType = aFeatureType;
    featureType.addFeature(this);

  }

  public boolean setName(String aName) {
    name = aName;
    return true;
  }

  public String getName() {
    return name;
  }

  public Map getMap() {
    return map;
  }

  public FeatureType getFeatureType() {
    return featureType;
  }

  /* This class does not drive Map and therefore sets the association unidirectionally.*/
  public void setMap(Map aMap) {
    map = aMap;
  }

  /* This class does not drive FeatureType and therefore sets the association unidirectionally.*/
  public void setFeatureType(FeatureType aFeatureType) {
    featureType = aFeatureType;
  }

  public void delete() {
    //Delete all 1 ends.
    map.deleteFeature(this);
    featureType.deleteFeature(this);
  }

  public boolean areManyEndsNull() {
    return true;
  }

  /***********************************
   * Returns the attribute list along with the  
   * class ID in JSON format.
   ***********************************/
  public JSONObject getAttributes() throws JSONException {
    JSONObject obj = new JSONObject();
    obj.put("CLASS_ID", registry.getKey(this));
    obj.put("name", getName());
    return obj;
  }

}