- Timestamp:
- 09/29/11 17:16:42 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ClientUserManagement/HeuristicLab.GeoIP/1.12/DatabaseInfo.cs
r6826 r6852 21 21 22 22 using System; 23 using System.IO;24 23 25 24 public class DatabaseInfo { 26 25 27 28 29 30 31 32 33 34 35 36 26 public static int COUNTRY_EDITION = 1; 27 public static int REGION_EDITION_REV0 = 7; 28 public static int REGION_EDITION_REV1 = 3; 29 public static int CITY_EDITION_REV0 = 6; 30 public static int CITY_EDITION_REV1 = 2; 31 public static int ORG_EDITION = 5; 32 public static int ISP_EDITION = 4; 33 public static int PROXY_EDITION = 8; 34 public static int ASNUM_EDITION = 9; 35 public static int NETSPEED_EDITION = 10; 37 36 38 37 //private static SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd"); 39 38 40 41 42 43 44 39 private String info; 40 /** 41 * Creates a new DatabaseInfo object given the database info String. 42 * @param info 43 */ 45 44 46 public DatabaseInfo(String info) { 47 this.info = info; 45 public DatabaseInfo(String info) { 46 this.info = info; 47 } 48 49 public int getType() { 50 if ((info == null) | (info == "")) { 51 return COUNTRY_EDITION; 52 } else { 53 // Get the type code from the database info string and then 54 // subtract 105 from the value to preserve compatability with 55 // databases from April 2003 and earlier. 56 return Convert.ToInt32(info.Substring(4, 7)) - 105; 48 57 } 58 } 49 59 50 public int getType() { 51 if ((info == null) | (info == "")) { 52 return COUNTRY_EDITION; 60 /** 61 * Returns true if the database is the premium version. 62 * 63 * @return true if the premium version of the database. 64 */ 65 public bool isPremium() { 66 return info.IndexOf("FREE") < 0; 67 } 68 69 /** 70 * Returns the date of the database. 71 * 72 * @return the date of the database. 73 */ 74 public DateTime getDate() { 75 for (int i = 0; i < info.Length - 9; i++) { 76 if (Char.IsWhiteSpace(info[i]) == true) { 77 String dateString = info.Substring(i + 1, i + 9); 78 try { 79 //synchronized (formatter) { 80 return DateTime.ParseExact(dateString, "yyyyMMdd", null); 81 //} 53 82 } 54 else { 55 // Get the type code from the database info string and then 56 // subtract 105 from the value to preserve compatability with 57 // databases from April 2003 and earlier. 58 return Convert.ToInt32(info.Substring(4, 7)) - 105; 83 catch (Exception e) { 84 Console.Write(e.Message); 59 85 } 86 break; 87 } 60 88 } 89 return DateTime.Now; 90 } 61 91 62 /** 63 * Returns true if the database is the premium version. 64 * 65 * @return true if the premium version of the database. 66 */ 67 public bool isPremium() { 68 return info.IndexOf("FREE") < 0; 69 } 70 71 /** 72 * Returns the date of the database. 73 * 74 * @return the date of the database. 75 */ 76 public DateTime getDate() { 77 for (int i=0; i<info.Length-9; i++) { 78 if (Char.IsWhiteSpace(info[i]) == true) { 79 String dateString = info.Substring(i+1, i+9); 80 try { 81 //synchronized (formatter) { 82 return DateTime.ParseExact(dateString,"yyyyMMdd",null); 83 //} 84 } 85 catch (Exception e) { 86 Console.Write(e.Message); 87 } 88 break; 89 } 90 } 91 return DateTime.Now; 92 } 93 94 public String toString() { 95 return info; 96 } 92 public String toString() { 93 return info; 94 } 97 95 } 98 96
Note: See TracChangeset
for help on using the changeset viewer.