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 childs and Must have parent if the Level is > 1 (an Adm with level 1 is to be a 'ROOT')

Author:
David Masclet

Field Summary
 
Fields inherited from class com.gisgraphy.domain.geoloc.entity.GisFeature
countryDao, LOCATION_COLUMN_NAME, logger
 
Constructor Summary
protected Adm()
          Default constructor (Needed by CGLib)
  Adm(GisFeature gisFeature, java.lang.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 featureCode will be set according to the Level (ex : ADM + level)
  Adm(java.lang.Integer level)
          Constructor that create an Adm for the specified level
note the featureClass will be set to 'A' and The featureCode will be set according to the Level (ex : ADM + level)
 
Method Summary
 void addChild(Adm child)
          Do a double set : Add (not replace !
 void addChildren(java.util.List<Adm> children)
          Do a double set : Add (not replace !)
 boolean equals(java.lang.Object obj)
           
 java.util.List<Adm> getChildren()
          Return the Adms of the higher Level
 java.lang.Integer getLevel()
           
 Adm getParent()
          Returns The parent Adm in the Adm tree structure
static int getProcessedLevelFromCodes(java.lang.String adm1Code, java.lang.String adm2Code, java.lang.String adm3Code, java.lang.String adm4Code)
          Determine the Level from the given codes
static int getProcessedLevelFromFeatureClassCode(java.lang.String featureClass, java.lang.String featureCode)
          Determine the level from a featureClass and a featureCode.
 int hashCode()
           
 boolean isConsistentForLevel()
          Check that the countryCode and the admXcode are correctly set according to the level of the Adm
 void setChildren(java.util.List<Adm> children)
          Set the Adms of a higher level
 void setLevel(java.lang.Integer level)
          Set the level and Check that 1<=level<=4.
 void setParent(Adm parent)
          Set the parent Adm in the tree structure
 java.lang.String toString()
           
 
Methods inherited from class com.gisgraphy.domain.geoloc.entity.GisFeature
addAlternateName, addAlternateNames, distance, getAdm, getAdm1Code, getAdm1Name, getAdm2Code, getAdm2Name, getAdm3Code, getAdm3Name, getAdm4Code, getAdm4Name, getAlternateNames, getAsciiName, getCountry, getCountryCode, getElevation, getFeatureClass, getFeatureCode, getFeatureId, getFullyQualifiedName, getGtopo30, getId, getLatitude, getLocation, getLongitude, getModificationDate, getName, getPopulation, getSource, getTimezone, 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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Adm

public Adm(GisFeature gisFeature,
           java.lang.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 featureCode will be set according to the Level (ex : ADM + level)

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

Adm

public Adm(java.lang.Integer level)
Constructor that create an Adm for the specified level
note the featureClass will be set to 'A' and The featureCode will be set according to the Level (ex : 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 countryCode and the admXcode are correctly set according to the level of the Adm


getLevel

public java.lang.Integer getLevel()
Returns:
The Level Of The Adm

setLevel

public void setLevel(java.lang.Integer level)
Set the level and Check that 1<=level<=4. If Not throw an IllegalArgumentException

Parameters:
level - The Level to Set
Throws:
java.lang.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 is not equals to the level of this Adm+1

addChildren

public void addChildren(java.util.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 java.util.List<Adm> getChildren()
Return the Adms of the higher Level

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

setChildren

public void setChildren(java.util.List<Adm> children)
Set the Adms of a 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(java.lang.String adm1Code,
                                             java.lang.String adm2Code,
                                             java.lang.String adm3Code,
                                             java.lang.String adm4Code)
Determine the Level from the given 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(java.lang.String featureClass,
                                                        java.lang.String featureCode)
Determine the level from a 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(java.lang.Object obj)
Overrides:
equals in class GisFeature
See Also:
GisFeature.equals(java.lang.Object)

toString

public java.lang.String toString()
Overrides:
toString in class GisFeature


Copyright © 2009. All Rights Reserved.