com.gisgraphy.domain.geoloc.entity
Class Adm

java.lang.Object
  extended by com.gisgraphy.domain.geoloc.entity.GisFeature
      extended by com.gisgraphy.domain.geoloc.entity.Adm

public class Adm
extends GisFeature

Represents a (sub) division of a Country (Region, Province, state, Department, and so on)
Adm are in tree structure. An Adm can have some children and MUST have a parent if the Level is > 1 (an Adm with level 1 is to be a 'ROOT' Adm)

Author:
David Masclet

Field Summary
 
Fields inherited from class com.gisgraphy.domain.geoloc.entity.GisFeature
LOCATION_COLUMN_NAME, logger
 
Constructor Summary
protected Adm()
          Default constructor (Needed by CGLib)
  Adm(GisFeature gisFeature, Integer level)
          Constructor that populate the Adm with the gisFeature fields and set the level
note The feature class will be set to 'A' and The feature code will be set according to the Level (ADM + level)
  Adm(Integer level)
          Constructor that create an Adm for the specified level
note the feature class will be set to 'A' and The feature code will be set according to the Level (ADM + level)
 
Method Summary
 void addChild(Adm child)
          Do a double set : Add (not replace !
 void addChildren(List<Adm> children)
          Do a double set : Add (not replace !)
 boolean equals(Object obj)
           
 List<Adm> getChildren()
          Return the Adms of a directly higher Level in the adm the tree structure
 Integer getLevel()
           
 Adm getParent()
          Returns The parent Adm in the Adm tree structure
static int getProcessedLevelFromCodes(String adm1Code, String adm2Code, String adm3Code, String adm4Code)
          Determine what should be the level of an Adm which have the provided codes
static int getProcessedLevelFromFeatureClassCode(String featureClass, String featureCode)
          Determine what should be the level of an adm which have a the specified featureClass and a featureCode.
 int hashCode()
           
 boolean isConsistentForLevel()
          Check that the country code is filled and the admXcode are correctly filled according to the level
 void setChildren(List<Adm> children)
          Set the Adms of a directly higher level
 void setLevel(Integer level)
          Set the level and Check that 1<= level<= 4.
 void setParent(Adm parent)
          Set the parent Adm in the tree structure
 String toString()
           
 
Methods inherited from class com.gisgraphy.domain.geoloc.entity.GisFeature
addAlternateName, addAlternateNames, addZipCode, addZipCodes, distanceTo, getAdm, getAdm1Code, getAdm1Name, getAdm2Code, getAdm2Name, getAdm3Code, getAdm3Name, getAdm4Code, getAdm4Name, getAlternateNames, getAsciiName, getCountry, getCountryCode, getElevation, getFeatureClass, getFeatureCode, getFeatureId, getFullyQualifiedName, getFullyQualifiedName, getGtopo30, getId, getLatitude, getLocation, getLongitude, getModificationDate, getName, getPopulation, getSource, getTimezone, getZipCodes, isAdm, isCity, isCountry, isFullTextSearchable, populate, setAdm, setAdm1Code, setAdm1Name, setAdm2Code, setAdm2Name, setAdm3Code, setAdm3Name, setAdm4Code, setAdm4Name, setAlternateNames, setAsciiName, setCountryCode, setElevation, setFeatureClass, setFeatureCode, setFeatureId, setGtopo30, setId, setLocation, setModificationDate, setName, setPopulation, setSource, setTimezone, setZipCodes
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Adm

public Adm(GisFeature gisFeature,
           Integer level)
Constructor that populate the Adm with the gisFeature fields and set the level
note The feature class will be set to 'A' and The feature code will be set according to the Level (ADM + level)

Parameters:
gisFeature - The gisFeature we want to populate the Adm
level - The level of the Adm

Adm

public Adm(Integer level)
Constructor that create an Adm for the specified level
note the feature class will be set to 'A' and The feature code will be set according to the Level (ADM + level)

Parameters:
level - The level of the Adm

Adm

protected Adm()
Default constructor (Needed by CGLib)

Method Detail

isConsistentForLevel

public boolean isConsistentForLevel()
Check that the country code is filled and the admXcode are correctly filled according to the level


getLevel

public Integer getLevel()
Returns:
The Level Of The Adm

setLevel

public void setLevel(Integer level)
Set the level and Check that 1<= level<= 4. If it is not the case, throw an IllegalArgumentException

Parameters:
level - The Level to set
Throws:
IllegalArgumentException - If level is not correct

addChild

public void addChild(Adm child)
Do a double set : Add (not replace ! ) The child to the current Adm and set the current Adm as the Parent of the specified Child.

Parameters:
child - The child to add
Throws:
IllegalArgumentException - if the level of the child is not equals to the level of this Adm +1

addChildren

public void addChildren(List<Adm> children)
Do a double set : Add (not replace !) the children to the current Adm and set the current Adm as the parent of the specified Children

Parameters:
children - The children to add
See Also:
addChild(Adm)

getChildren

public List<Adm> getChildren()
Return the Adms of a directly higher Level in the adm the tree structure

Returns:
The Adms of a directly higher Level
Example Returns the Adm(s) with level 2 if the current Adm has a level equals to 1

setChildren

public void setChildren(List<Adm> children)
Set the Adms of a directly higher level

Parameters:
children - the children for the current Adm

getParent

public Adm getParent()
Returns The parent Adm in the Adm tree structure

Returns:
The parent Adm (with lower Level)

setParent

public void setParent(Adm parent)
Set the parent Adm in the tree structure

Parameters:
parent - the Parent Adm to set

getProcessedLevelFromCodes

public static int getProcessedLevelFromCodes(String adm1Code,
                                             String adm2Code,
                                             String adm3Code,
                                             String adm4Code)
Determine what should be the level of an Adm which have the provided codes

Parameters:
adm1Code - The Adm1Code of the Adm to test
adm2Code - The Adm2Code of the Adm to test
adm3Code - The Adm3Code of the Adm to test
adm4Code - The Adm4Code of the Adm to test
Returns:
the processed Level or 0 if the level can not be determine or all the code are null

getProcessedLevelFromFeatureClassCode

public static int getProcessedLevelFromFeatureClassCode(String featureClass,
                                                        String featureCode)
Determine what should be the level of an adm which have a the specified featureClass and a featureCode.
e.g : featureClass=A and featureCode=ADM3 will return 3 .
featureClass=P and featureCode=ADM4 will return 0 because P_ADM4 is not of ADM type. This method is case sensitive.

Parameters:
featureClass - The featureClass of the Adm to test
featureCode - The featureCode of the Adm to Test
Returns:
the Level of the Adm or 0 if the level can not be determine

hashCode

public int hashCode()
Overrides:
hashCode in class GisFeature

equals

public boolean equals(Object obj)
Overrides:
equals in class GisFeature
See Also:
GisFeature.equals(java.lang.Object)

toString

public String toString()
Overrides:
toString in class GisFeature


Copyright © 2012. All Rights Reserved.