Changeset 2370 in josm for trunk/src/org/openstreetmap/josm/data/Version.java
- Timestamp:
- 2009-11-01T10:20:23+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Version.java
r2369 r2370 14 14 15 15 import org.openstreetmap.josm.Main; 16 import org.openstreetmap.josm.tools.LanguageInfo; 16 17 17 18 /** 18 19 * Provides basic information about the currently used JOSM build. 19 * 20 * 20 21 */ 21 22 public class Version { … … 23 24 static public final int JOSM_UNKNOWN_VERSION = 0; 24 25 25 /** the unique instance */ 26 /** the unique instance */ 26 27 private static Version instance; 27 28 28 29 /** 29 30 * Load the specified resource as string. 30 * 31 * 31 32 * @param resource the resource url to load 32 * @return the content of the resource file; null, if an error occurred 33 * @return the content of the resource file; null, if an error occurred 33 34 */ 34 35 static public String loadResourceFile(URL resource) { … … 48 49 return s; 49 50 } 50 51 /** 52 * Replies the unique instance of the version information 53 * 51 52 /** 53 * Replies the unique instance of the version information 54 * 54 55 * @return the unique instance of the version information 55 56 */ 56 57 57 58 static public Version getInstance() { 58 59 if (instance == null) { … … 60 61 instance.init(); 61 62 } 62 return instance; 63 } 64 63 return instance; 64 } 65 65 66 private int version; 66 67 private String revision; 67 68 private String time; 68 69 private boolean isLocalBuild; 69 70 70 71 protected HashMap<String, String> parseManifestStyleFormattedString(String content) { 71 72 HashMap<String, String> properties = new HashMap<String, String>(); … … 82 83 return properties; 83 84 } 84 85 /** 86 * Initializes the version infos from the revision resource file 87 * 88 * @param revisionInfo the revision info loaded from a revision resource file 85 86 /** 87 * Initializes the version infos from the revision resource file 88 * 89 * @param revisionInfo the revision info loaded from a revision resource file 89 90 */ 90 91 protected void initFromRevisionInfo(String revisionInfo) { … … 93 94 this.version = JOSM_UNKNOWN_VERSION; 94 95 this.time = null; 95 return; 96 } 97 96 return; 97 } 98 98 99 HashMap<String, String> properties = parseManifestStyleFormattedString(revisionInfo); 99 100 String value = properties.get("Revision"); … … 109 110 version = JOSM_UNKNOWN_VERSION; 110 111 } 111 112 // the last changed data 112 113 // the last changed data 113 114 // 114 115 time = properties.get("Last Changed Date"); … … 116 117 time = properties.get("Build-Date"); 117 118 } 118 119 119 120 // is this a local build ? 120 121 // 121 isLocalBuild = false; 122 isLocalBuild = false; 122 123 value = properties.get("Is-Local-Build"); 123 124 if (value != null && value.trim().toLowerCase().equals("true")) { 124 125 isLocalBuild = true; 125 126 } 126 127 127 128 // the revision info 128 129 // … … 132 133 } 133 134 revision = sb.toString(); 134 } 135 136 public void init() { 135 } 136 137 public void init() { 137 138 URL u = Main.class.getResource("/REVISION"); 138 139 if (u == null) { … … 145 146 System.out.println(revision); 146 147 } 147 148 /** 149 * Replies the version string. Either the SVN revision "1234" (as string) or the 148 149 /** 150 * Replies the version string. Either the SVN revision "1234" (as string) or the 150 151 * the I18n equivalent of "UNKNOWN". 151 * 152 * @return the JOSM version 152 * 153 * @return the JOSM version 153 154 */ 154 155 public String getVersionString() { 155 156 return version == 0 ? tr("UNKNOWN") : Integer.toString(version); 156 157 } 157 158 158 159 /** 159 160 * Replies a text with the release attributes 160 * 161 * 161 162 * @return a text with the release attributes 162 163 */ … … 166 167 167 168 /** 168 * Replies the build date as string 169 * 170 * @return the build date as string 169 * Replies the build date as string 170 * 171 * @return the build date as string 171 172 */ 172 173 public String getTime() { 173 174 return time; 174 175 } 175 176 /** 177 * Replies the JOSM version. Replies {@see #JOSM_UNKNOWN_VERSION} if the version isn't known. 176 177 /** 178 * Replies the JOSM version. Replies {@see #JOSM_UNKNOWN_VERSION} if the version isn't known. 178 179 * @return the JOSM version 179 180 */ … … 184 185 /** 185 186 * Replies true if this is a local build, i.e. an inofficial development build. 186 * 187 * 187 188 * @return true if this is a local build, i.e. an inofficial development build. 188 189 */ … … 190 191 return isLocalBuild; 191 192 } 193 194 public String getAgentString() { 195 int v = getVersion(); 196 String s = (v == JOSM_UNKNOWN_VERSION) ? "UNKNOWN" : Integer.toString(v); 197 if (isLocalBuild() && v != JOSM_UNKNOWN_VERSION) { 198 s += " SVN"; 199 } 200 return "JOSM/1.5 ("+ s+" "+LanguageInfo.getJOSMLocaleCode()+")"; 201 } 192 202 }
Note:
See TracChangeset
for help on using the changeset viewer.