1 package geo.google.datamodel; 2 /*** 3 * GGeoStatusCode Enum class 4 * http://www.google.com/apis/maps/documentation/reference.html#GGeoStatusCode 5 * @author jliang 6 * 7 */ 8 public enum GeoStatusCode{ 9 G_GEO_SUCCESS(200, "No errors occurred; the address was successfully parsed and its geocode has been returned. (Since 2.55)"), 10 G_GEO_BAD_REQUEST (400, "A directions request could not be successfully parsed. (Since 2.81)"), 11 G_GEO_SERVER_ERROR (500, "A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known. (Since 2.55)"), 12 G_GEO_MISSING_QUERY (601, "The HTTP q parameter was either missing or had no value. For geocoding requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input. (Since 2.81)"), 13 G_GEO_UNKNOWN_ADDRESS (602, "No corresponding geographic location could be found for the specified address. This may be due to the fact that the address is relatively new, or it may be incorrect. (Since 2.55)"), 14 G_GEO_UNAVAILABLE_ADDRESS (603, "The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons. (Since 2.55)"), 15 G_GEO_UNKNOWN_DIRECTIONS (604, "The GDirections object could not compute directions between the points mentioned in the query. This is usually because there is no route available between the two points, or because we do not have data for routing in that region. (Since 2.81)"), 16 G_GEO_BAD_KEY (610, "The given key is either invalid or does not match the domain for which it was given. (Since 2.55)"), 17 G_GEO_TOO_MANY_QUERIES(620, "The given key has gone over the requests limit in the 24 hour period. "), 18 G_GEO_UNKOWN_STATUS (-1, "Uknown Status"); 19 20 private String _description; 21 private int _code; 22 private GeoStatusCode(int code, String description){ 23 _code = code; 24 _description = description; 25 } 26 public int getCode() { 27 return _code; 28 } 29 public String getCodeName() { 30 return this.name(); 31 } 32 public String getDescription() { 33 return _description; 34 } 35 /*** 36 * Retrun the corresponding GGeoStatusCode based from the input code. 37 */ 38 public static GeoStatusCode getStatusCode(int code){ 39 switch (code) { 40 case 200: 41 return G_GEO_SUCCESS; 42 case 400: 43 return G_GEO_BAD_REQUEST; 44 case 500: 45 return G_GEO_SERVER_ERROR; 46 case 601: 47 return G_GEO_MISSING_QUERY; 48 case 602: 49 return G_GEO_UNKNOWN_ADDRESS; 50 case 603: 51 return G_GEO_UNAVAILABLE_ADDRESS; 52 case 604: 53 return G_GEO_UNKNOWN_DIRECTIONS; 54 case 610: 55 return G_GEO_BAD_KEY; 56 case 620: 57 return G_GEO_TOO_MANY_QUERIES; 58 default: 59 return G_GEO_UNKOWN_STATUS; 60 } 61 } 62 }