GeosupportVersion { String formatVersion(String version) { String v = version.trim(); while (v.endsWith("0")) { v = v.substring(0, v.length() - 1); } while (v.startsWith("0")) { v = v.substring(1); } int len = v.length(); switch (len) { case 0: return VERSION_NOT_AVAILABLE; case 3: case 4: v = v.substring(0, 2) + "." + v.substring(2); break; default: break; } return v; } GeosupportVersion(); String getVersion(); String getRelease(); List<FileInfo> getGeoFileInfo(); ThinFileInfo getThinFileInfo(); FileInfo getGrid1RFileInfo(); FileInfo getAuxsegFileInfo(); FileInfo getTpadFileInfo(); FileInfo getApequivFileInfo(); void setGeoFileInfo(List<FileInfo> geoFileInfo); void setThinFileInfo(ThinFileInfo thinFileInfo); void setGrid1RFileInfo(FileInfo grid1rFileInfo); void setAuxsegFileInfo(FileInfo auxsegFileInfo); void setTpadFileInfo(FileInfo tpadFileInfo); void setApequivFileInfo(FileInfo apequivFileInfo); List<String> getDsNames(); void setDsNames(List<String> dsNames); @Override String toString(); static final String GEO_FILE_TAG; static final String PAD_FILE_TAG; static final String RELEASE_NOT_AVAILABLE; static final String VERSION_NOT_AVAILABLE; }
@Test public void testFormatVersion() { assertEquals(GeosupportVersion.VERSION_NOT_AVAILABLE, geosupportVersion.formatVersion("")); assertEquals(GeosupportVersion.VERSION_NOT_AVAILABLE, geosupportVersion.formatVersion("0000")); assertEquals("1", geosupportVersion.formatVersion("00001")); assertEquals("32", geosupportVersion.formatVersion("0032")); assertEquals("13.2", geosupportVersion.formatVersion("0132")); assertEquals("13.24", geosupportVersion.formatVersion("1324")); }