mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-13 08:53:20 +00:00
ICU-5616 updated icutzu, added logger for icutzu
X-SVN-Rev: 21099
This commit is contained in:
parent
afc87d7398
commit
0645826dce
12 changed files with 203 additions and 103 deletions
1
.gitattributes
vendored
1
.gitattributes
vendored
|
@ -143,6 +143,7 @@ icu4j/src/com/ibm/icu/dev/tool/tzu/ICUFile.java -text
|
|||
icu4j/src/com/ibm/icu/dev/tool/tzu/ICUJarFinder.java -text
|
||||
icu4j/src/com/ibm/icu/dev/tool/tzu/ICUTZUMain.java -text
|
||||
icu4j/src/com/ibm/icu/dev/tool/tzu/IncludePath.java -text
|
||||
icu4j/src/com/ibm/icu/dev/tool/tzu/Logger.java -text
|
||||
icu4j/src/com/ibm/icu/dev/tool/tzu/PathComponent.java -text
|
||||
icu4j/src/com/ibm/icu/dev/tool/tzu/PathModel.java -text
|
||||
icu4j/src/com/ibm/icu/dev/tool/tzu/ResultComponent.java -text
|
||||
|
|
|
@ -2491,6 +2491,7 @@
|
|||
<fileset dir="${build.dir}" includes="com/ibm/icu/dev/tool/tzu/**/*.class"/>
|
||||
<fileset dir="${build.dir}" includes="com/ibm/icu/dev/tool/UOption*.*"/>
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="com.ibm.icu.dev.tool.tzu.ICUTZUMain"/>
|
||||
<attribute name="Built-By" value="${corp}"/>
|
||||
<section name="common">
|
||||
<attribute name="Specification-Title" value="ICU4J TimeZone Update Utility"/>
|
||||
|
|
|
@ -30,6 +30,14 @@ public class CLILoader {
|
|||
// parse the arguments using UOption.parseArgs
|
||||
int argsleft = UOption.parseArgs(args, options);
|
||||
|
||||
// set the logging options
|
||||
if (options[QUIET].doesOccur)
|
||||
Logger.setVerbosity(Logger.QUIET);
|
||||
else if (options[VERBOSE].doesOccur)
|
||||
Logger.setVerbosity(Logger.VERBOSE);
|
||||
else
|
||||
Logger.setVerbosity(Logger.NORMAL);
|
||||
|
||||
// if help is specified, show the help specs and do nothing else
|
||||
if (options[HELP].doesOccur) {
|
||||
showHelp();
|
||||
|
@ -60,6 +68,10 @@ public class CLILoader {
|
|||
if (options[QUIET].doesOccur)
|
||||
options[AUTO].doesOccur = true;
|
||||
|
||||
// discoveronly implies auto
|
||||
if (options[DISCOVERONLY].doesOccur)
|
||||
options[AUTO].doesOccur = true;
|
||||
|
||||
// auto implies best if no preference specified
|
||||
if (options[AUTO].doesOccur && choiceType == 0) {
|
||||
options[BEST].doesOccur = true;
|
||||
|
@ -70,21 +82,29 @@ public class CLILoader {
|
|||
if (options[BACKUP].doesOccur)
|
||||
backupDir = new File(options[BACKUP].value);
|
||||
|
||||
// if we're running offline and the local file doesnt exist, we
|
||||
// can't update squat
|
||||
if (options[OFFLINE].doesOccur
|
||||
&& !SourceModel.TZ_LOCAL_FILE.exists()
|
||||
&& !options[DISCOVERONLY].doesOccur)
|
||||
throw new IllegalArgumentException(
|
||||
"Running offline mode but local file does not exist (no sources available)");
|
||||
|
||||
// if the user did not specify to stay offline, go online and find
|
||||
// zoneinfo.res files
|
||||
if (!options[OFFLINE].doesOccur)
|
||||
sourceModel.findSources();
|
||||
|
||||
// load paths from the directory search file
|
||||
// load paths stored in the directory search file
|
||||
pathModel.loadPaths();
|
||||
|
||||
// search the paths for updatable icu4j files
|
||||
try {
|
||||
System.out.println("Search started.");
|
||||
Logger.println("Search started.", Logger.NORMAL);
|
||||
pathModel.searchAll(options[RECURSE].doesOccur, backupDir);
|
||||
System.out.println("Search done.");
|
||||
Logger.println("Search done.", Logger.NORMAL);
|
||||
} catch (InterruptedException ex) {
|
||||
System.out.println("Search interrupted.");
|
||||
Logger.println("Search interrupted.", Logger.NORMAL);
|
||||
}
|
||||
|
||||
// get the name and url associated with the update mode (or null if
|
||||
|
@ -105,6 +125,7 @@ public class CLILoader {
|
|||
chosenVersion = getTZVersionVersion(options[TZVERSION].value);
|
||||
chosenURL = getTZVersionURL(options[TZVERSION].value);
|
||||
}
|
||||
// (do nothing in the case of DISCOVERONLY)
|
||||
|
||||
// create a reader for user input
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(
|
||||
|
@ -115,24 +136,26 @@ public class CLILoader {
|
|||
while (resultIter.hasNext()) {
|
||||
try {
|
||||
ICUFile entry = (ICUFile) resultIter.next();
|
||||
System.out.println();
|
||||
System.out.println("Filename: "
|
||||
+ entry.getFile().getName());
|
||||
System.out.println("Location: "
|
||||
+ entry.getFile().getParent());
|
||||
System.out.println("Current Version: "
|
||||
+ entry.getTZVersion());
|
||||
Logger.println("", Logger.NORMAL);
|
||||
Logger.println("Filename: " + entry.getFile().getName(),
|
||||
Logger.NORMAL);
|
||||
Logger.println("Location: " + entry.getFile().getParent(),
|
||||
Logger.NORMAL);
|
||||
Logger.println("Current Version: " + entry.getTZVersion(),
|
||||
Logger.NORMAL);
|
||||
|
||||
if (!entry.getFile().canRead()
|
||||
|| !entry.getFile().canWrite()) {
|
||||
System.out.println("Missing permissions for "
|
||||
+ entry.getFile().getName() + ".");
|
||||
Logger.println("Missing permissions for "
|
||||
+ entry.getFile().getName() + ".",
|
||||
Logger.NORMAL);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (options[AUTO].doesOccur) // automatic mode
|
||||
{
|
||||
update(entry, chosenName, chosenURL);
|
||||
if (!options[DISCOVERONLY].doesOccur)
|
||||
update(entry, chosenName, chosenURL);
|
||||
} else if (choiceType == 1) // confirmation mode
|
||||
{
|
||||
String input = askConfirm(chosenName, chosenVersion,
|
||||
|
@ -157,65 +180,70 @@ public class CLILoader {
|
|||
skipUpdate();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
// error in command-line input
|
||||
ex.printStackTrace();
|
||||
// error in command-line input ???
|
||||
Logger.errorln("Error in command-line input.");
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println();
|
||||
System.out.println("ICUTZU finished successfully.");
|
||||
Logger.println("", Logger.NORMAL);
|
||||
Logger.println("ICUTZU finished successfully.", Logger.NORMAL);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
System.out.println(ex);
|
||||
Logger.errorln(ex.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private String askConfirm(String chosenString, String chosenVersion,
|
||||
String currentVersion, BufferedReader reader) throws IOException {
|
||||
int betterness = 1; // chosenString.compareToIgnoreCase(currentVersion);
|
||||
int betterness = chosenVersion.compareToIgnoreCase(currentVersion);
|
||||
if (betterness == 0) {
|
||||
System.out.println("Updating should have no effect on this file.");
|
||||
System.out.print("Update anyway?");
|
||||
Logger.println("Updating should have no effect on this file.",
|
||||
Logger.NORMAL);
|
||||
Logger.println("Update anyway?", Logger.NORMAL);
|
||||
} else if (betterness < 0) {
|
||||
System.out
|
||||
.println("Warning: The version specified is older than the one present in the file.");
|
||||
System.out.print("Update anyway?");
|
||||
Logger
|
||||
.println(
|
||||
"Warning: The version specified is older than the one present in the file.",
|
||||
Logger.NORMAL);
|
||||
Logger.println("Update anyway?", Logger.NORMAL);
|
||||
} else {
|
||||
System.out.print("Update to " + chosenVersion + "?");
|
||||
Logger.println("Update to " + chosenVersion + "?", Logger.NORMAL);
|
||||
}
|
||||
|
||||
System.out.print(" [yes (default), no]\n: ");
|
||||
Logger.println(" [yes (default), no]\n: ", Logger.NORMAL);
|
||||
return reader.readLine().trim().toLowerCase();
|
||||
}
|
||||
|
||||
private String askChoice(BufferedReader reader) throws IOException {
|
||||
System.out.print("Available Versions: ");
|
||||
Logger.println("Available Versions: ", Logger.NORMAL);
|
||||
Iterator sourceIter = sourceModel.iterator();
|
||||
|
||||
if (sourceIter.hasNext())
|
||||
System.out.print(((Map.Entry) sourceIter.next()).getKey());
|
||||
Logger.println(getLocalName(), Logger.NORMAL);
|
||||
while (sourceIter.hasNext())
|
||||
System.out.print(", " + ((Map.Entry) sourceIter.next()).getKey());
|
||||
Logger.println(", " + ((Map.Entry) sourceIter.next()).getKey(),
|
||||
Logger.NORMAL);
|
||||
Logger.println("", Logger.NORMAL);
|
||||
|
||||
System.out.println();
|
||||
System.out
|
||||
.println("Update Version? [best (default), <specific version>, local copy, none]");
|
||||
System.out.print(": ");
|
||||
Logger
|
||||
.println(
|
||||
"Update to which version? [best (default), none, local copy, <specific version above>]",
|
||||
Logger.NORMAL);
|
||||
Logger.println(": ", Logger.NORMAL);
|
||||
return reader.readLine().trim().toLowerCase();
|
||||
}
|
||||
|
||||
private void update(ICUFile entry, String chosenString, URL url) {
|
||||
System.out.println("Updating to " + chosenString + "...");
|
||||
Logger.println("Updating to " + chosenString + "...", Logger.NORMAL);
|
||||
try {
|
||||
entry.updateJar(url, backupDir);
|
||||
System.out.println("Update done.");
|
||||
Logger.println("Update done.", Logger.NORMAL);
|
||||
} catch (IOException ex) {
|
||||
System.err.println(ex);
|
||||
Logger.error("Could not update " + entry.getFile().getName());
|
||||
}
|
||||
}
|
||||
|
||||
private void skipUpdate() {
|
||||
System.out.println("Update skipped.");
|
||||
Logger.println("Update skipped.", Logger.NORMAL);
|
||||
}
|
||||
|
||||
private String getBestName() {
|
||||
|
@ -261,7 +289,7 @@ public class CLILoader {
|
|||
}
|
||||
|
||||
private static void showHelp() {
|
||||
System.out.println("Help!");
|
||||
Logger.println("Help!", Logger.NORMAL);
|
||||
}
|
||||
|
||||
private static void syntaxError(String message) {
|
||||
|
|
|
@ -78,7 +78,7 @@ public class GUILoader {
|
|||
|
||||
workerThread = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
System.out.println("Search started.");
|
||||
Logger.println("Search started.", Logger.NORMAL);
|
||||
setCancelSearchEnabled(true);
|
||||
setUpdateEnabled(false);
|
||||
setSearchEnabled(false);
|
||||
|
@ -91,7 +91,7 @@ public class GUILoader {
|
|||
setSearchEnabled(true);
|
||||
setUpdateEnabled(true);
|
||||
setCancelSearchEnabled(false);
|
||||
System.out.println("Search ended.");
|
||||
Logger.println("Search ended.", Logger.NORMAL);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class GUILoader {
|
|||
|
||||
workerThread = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
System.out.println("Search started.");
|
||||
Logger.println("Search started.", Logger.NORMAL);
|
||||
setCancelSearchEnabled(true);
|
||||
setUpdateEnabled(false);
|
||||
setSearchEnabled(false);
|
||||
|
@ -116,7 +116,7 @@ public class GUILoader {
|
|||
setSearchEnabled(true);
|
||||
setUpdateEnabled(true);
|
||||
setCancelSearchEnabled(false);
|
||||
System.out.println("Search ended.");
|
||||
Logger.println("Search ended.", Logger.NORMAL);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -128,7 +128,7 @@ public class GUILoader {
|
|||
|
||||
workerThread = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
System.out.println("Update started.");
|
||||
Logger.println("Update started.", Logger.NORMAL);
|
||||
setCancelUpdateEnabled(true);
|
||||
setUpdateEnabled(false);
|
||||
setSearchEnabled(false);
|
||||
|
@ -139,7 +139,7 @@ public class GUILoader {
|
|||
setUpdateEnabled(true);
|
||||
setSearchEnabled(true);
|
||||
setCancelUpdateEnabled(false);
|
||||
System.out.println("Update ended.");
|
||||
Logger.println("Update ended.", Logger.NORMAL);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -151,7 +151,7 @@ public class GUILoader {
|
|||
|
||||
workerThread = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
System.out.println("Update started.");
|
||||
Logger.println("Update started.", Logger.NORMAL);
|
||||
setCancelUpdateEnabled(true);
|
||||
setUpdateEnabled(false);
|
||||
setSearchEnabled(false);
|
||||
|
@ -162,7 +162,7 @@ public class GUILoader {
|
|||
setUpdateEnabled(true);
|
||||
setSearchEnabled(true);
|
||||
setCancelUpdateEnabled(false);
|
||||
System.out.println("Update ended.");
|
||||
Logger.println("Update ended.", Logger.NORMAL);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ public class ICUFile {
|
|||
|
||||
tzVersion = findEntryTZVersion(file, insertEntry);
|
||||
|
||||
System.out.println("Added: " + file);
|
||||
Logger.println("Added: " + file, Logger.NORMAL);
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
|
@ -104,7 +104,7 @@ public class ICUFile {
|
|||
ostream = new PrintStream(new FileOutputStream(backupDesc));
|
||||
ostream.println(inputFile.toString());
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
// ex.printStackTrace();
|
||||
backupFile.delete();
|
||||
backupDesc.delete();
|
||||
backupDir.delete();
|
||||
|
@ -117,8 +117,8 @@ public class ICUFile {
|
|||
}
|
||||
|
||||
private static boolean copyFile(File inputFile, File outputFile) {
|
||||
System.out.println("Coping from \"" + inputFile + "\" to \""
|
||||
+ outputFile + "\"");
|
||||
Logger.println("Coping from \"" + inputFile + "\" to \"" + outputFile
|
||||
+ "\"", Logger.VERBOSE);
|
||||
InputStream istream = null;
|
||||
OutputStream ostream = null;
|
||||
byte[] buffer = new byte[BUFFER_SIZE];
|
||||
|
@ -134,7 +134,7 @@ public class ICUFile {
|
|||
|
||||
success = true;
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
// ex.printStackTrace();
|
||||
outputFile.delete();
|
||||
} finally {
|
||||
// safely close the streams
|
||||
|
@ -142,13 +142,13 @@ public class ICUFile {
|
|||
try {
|
||||
istream.close();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
// ex.printStackTrace();
|
||||
}
|
||||
if (ostream != null)
|
||||
try {
|
||||
ostream.close();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
// ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
return success;
|
||||
|
@ -156,8 +156,8 @@ public class ICUFile {
|
|||
|
||||
private static boolean copyEntry(File inputFile, JarEntry inputEntry,
|
||||
File outputFile) {
|
||||
// System.out.println("Coping from \"" + inputFile + "!/" + inputEntry +
|
||||
// "\" to \"" + outputFile + "\"");
|
||||
Logger.println("Coping from \"" + inputFile + "!/" + inputEntry
|
||||
+ "\" to \"" + outputFile + "\"", Logger.VERBOSE);
|
||||
JarFile jar = null;
|
||||
InputStream istream = null;
|
||||
OutputStream ostream = null;
|
||||
|
@ -175,7 +175,7 @@ public class ICUFile {
|
|||
|
||||
success = true;
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
// ex.printStackTrace();
|
||||
outputFile.delete();
|
||||
} finally {
|
||||
// safely close the streams
|
||||
|
@ -183,19 +183,19 @@ public class ICUFile {
|
|||
try {
|
||||
jar.close();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
// ex.printStackTrace();
|
||||
}
|
||||
if (istream != null)
|
||||
try {
|
||||
istream.close();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
// ex.printStackTrace();
|
||||
}
|
||||
if (ostream != null)
|
||||
try {
|
||||
ostream.close();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
// ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
return success;
|
||||
|
@ -203,8 +203,8 @@ public class ICUFile {
|
|||
|
||||
private static boolean createUpdatedJar(File inputFile, File outputFile,
|
||||
JarEntry insertEntry, URL inputURL) {
|
||||
System.out.println("Inserting \"" + inputURL + "\" into \"" + inputFile
|
||||
+ "/" + insertEntry + "\"");
|
||||
Logger.println("Inserting \"" + inputURL + "\" into \"" + inputFile
|
||||
+ "/" + insertEntry + "\"", Logger.VERBOSE);
|
||||
JarFile jar = null;
|
||||
JarOutputStream ostream = null;
|
||||
InputStream istream = null;
|
||||
|
@ -245,7 +245,7 @@ public class ICUFile {
|
|||
|
||||
success = true;
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
// ex.printStackTrace();
|
||||
outputFile.delete();
|
||||
} finally {
|
||||
// safely close the streams
|
||||
|
@ -253,25 +253,25 @@ public class ICUFile {
|
|||
try {
|
||||
istream.close();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
// ex.printStackTrace();
|
||||
}
|
||||
if (ostream != null)
|
||||
try {
|
||||
ostream.close();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
// ex.printStackTrace();
|
||||
}
|
||||
if (jstream != null)
|
||||
try {
|
||||
jstream.close();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
// ex.printStackTrace();
|
||||
}
|
||||
if (jar != null)
|
||||
try {
|
||||
jar.close();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
// ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
return success;
|
||||
|
@ -304,17 +304,17 @@ public class ICUFile {
|
|||
}
|
||||
} catch (IOException ex) {
|
||||
// log the unexplained i/o error, but we must drudge on
|
||||
System.out.println("Error with " + file);
|
||||
ex.printStackTrace();
|
||||
Logger.println("Error with " + file, Logger.NORMAL);
|
||||
// ex.printStackTrace();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
// ex.printStackTrace();
|
||||
} finally {
|
||||
// new Throwable().printStackTrace();
|
||||
if (jar != null)
|
||||
try {
|
||||
jar.close();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
// ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
return success;
|
||||
|
@ -338,7 +338,7 @@ public class ICUFile {
|
|||
copyEntry(icuFile, tzEntry, temp);
|
||||
return findTZVersion(temp);
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
// ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ public class ICUFile {
|
|||
copyFile(tzFile, temp);
|
||||
return findTZVersion(temp);
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
// ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -382,6 +382,7 @@ public class ICUFile {
|
|||
// not an error -- some zoneinfo files do not have a version number
|
||||
// included
|
||||
} catch (MalformedURLException ex) {
|
||||
// this should never happen
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,14 +29,14 @@ public class ICUJarFinder {
|
|||
if (backupDir != null)
|
||||
excluded.add(backupDir);
|
||||
|
||||
System.out.println("*************");
|
||||
System.out.println("Included:");
|
||||
Logger.println("*************", Logger.NORMAL);
|
||||
Logger.println("Included:", Logger.NORMAL);
|
||||
for (int i = 0; i < included.size(); i++)
|
||||
System.out.println(included.get(i));
|
||||
System.out.println("Excluded:");
|
||||
Logger.println(included.get(i), Logger.NORMAL);
|
||||
Logger.println("Excluded:", Logger.NORMAL);
|
||||
for (int i = 0; i < excluded.size(); i++)
|
||||
System.out.println(excluded.get(i));
|
||||
System.out.println("*************");
|
||||
Logger.println(excluded.get(i), Logger.NORMAL);
|
||||
Logger.println("*************", Logger.NORMAL);
|
||||
|
||||
for (int i = 0; i < included.size(); i++)
|
||||
search(resultModel, (File) included.get(i), excluded, subdirs, true);
|
||||
|
@ -60,7 +60,7 @@ public class ICUJarFinder {
|
|||
// if it's not an ICU file we care about, ignore it
|
||||
}
|
||||
} else if (file.isDirectory() && (subdirs || firstdip)) {
|
||||
System.out.println(file);
|
||||
Logger.println(file, Logger.NORMAL);
|
||||
File[] dirlist = file.listFiles();
|
||||
if (dirlist != null)
|
||||
for (int i = 0; i < dirlist.length; i++)
|
||||
|
|
|
@ -8,8 +8,7 @@ package com.ibm.icu.dev.tool.tzu;
|
|||
|
||||
public class ICUTZUMain {
|
||||
public static void main(String[] args) {
|
||||
boolean nogui = "true".equals(System.getProperty("nogui"));
|
||||
if (nogui)
|
||||
if ("true".equals(System.getProperty("nogui")))
|
||||
CLILoader.main(args);
|
||||
else
|
||||
GUILoader.main(args);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
package com.ibm.icu.dev.tool.tzu;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
|
||||
public class IncludePath {
|
||||
public IncludePath(File path, boolean include) {
|
||||
|
|
70
icu4j/src/com/ibm/icu/dev/tool/tzu/Logger.java
Normal file
70
icu4j/src/com/ibm/icu/dev/tool/tzu/Logger.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.dev.tool.tzu;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
public class Logger {
|
||||
|
||||
static {
|
||||
try {
|
||||
log = new PrintStream(new FileOutputStream("icutzu.log"));
|
||||
} catch (FileNotFoundException ex) {
|
||||
System.err.println("Could not create a log file.");
|
||||
}
|
||||
}
|
||||
|
||||
private Logger() {
|
||||
}
|
||||
|
||||
public static void setVerbosity(int verbosity) {
|
||||
Logger.verbosity = verbosity;
|
||||
}
|
||||
|
||||
public static int getVerbosity() {
|
||||
return verbosity;
|
||||
}
|
||||
|
||||
public static void print(Object output, int verbosity) {
|
||||
if (verbosity >= Logger.verbosity)
|
||||
System.out.print(output);
|
||||
}
|
||||
|
||||
public static void println(Object output, int verbosity) {
|
||||
if (verbosity >= Logger.verbosity)
|
||||
System.out.println(output);
|
||||
}
|
||||
|
||||
public static void error(Object output) {
|
||||
System.err.print(output);
|
||||
}
|
||||
|
||||
public static void errorln(Object output) {
|
||||
System.err.println(output);
|
||||
}
|
||||
|
||||
public static void log(Object output) {
|
||||
log.print(output);
|
||||
}
|
||||
|
||||
public static void logln(Object output) {
|
||||
log.println(output);
|
||||
}
|
||||
|
||||
public static final int QUIET = -1;
|
||||
|
||||
public static final int NORMAL = 0;
|
||||
|
||||
public static final int VERBOSE = 1;
|
||||
|
||||
private static int verbosity = NORMAL;
|
||||
|
||||
private static PrintStream log;
|
||||
}
|
|
@ -148,17 +148,6 @@ public class ResultComponent extends JComponent {
|
|||
.setHidden(event.getStateChange() == ItemEvent.SELECTED);
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* Iterator iter = sourceList.keySet().iterator(); while
|
||||
* (iter.hasNext()) resultSourceList.addItem(iter.next());
|
||||
*
|
||||
* int n = resultSourceList.getItemCount();
|
||||
* resultSourceList.setSelectedIndex(n - 1); if (n > 1 &&
|
||||
* resultSourceList.getSelectedItem().equals(TZ_LOCAL_CHOICE))
|
||||
* resultSourceList.setSelectedIndex(n - 2);
|
||||
*
|
||||
*/
|
||||
}
|
||||
|
||||
private URL getSelectedSource() {
|
||||
|
|
|
@ -129,7 +129,7 @@ class SourceModel extends AbstractListModel implements ComboBoxModel {
|
|||
|
||||
private TreeMap urlMap = new TreeMap();
|
||||
|
||||
public static final String TZ_LOCAL_CHOICE = "Local Copy";
|
||||
public static String TZ_LOCAL_CHOICE;
|
||||
|
||||
public static final String TZ_BASE_URLSTRING_START = "http://source.icu-project.org/repos/icu/data/trunk/tzdata/icu/";
|
||||
|
||||
|
@ -148,9 +148,20 @@ class SourceModel extends AbstractListModel implements ComboBoxModel {
|
|||
// need to be try-catched
|
||||
try {
|
||||
TZ_BASE_URL = new URL(TZ_BASE_URLSTRING_START);
|
||||
TZ_LOCAL_URL = TZ_LOCAL_FILE.toURL();
|
||||
TZ_LOCAL_VERSION = "tobefixed"; // ICUFile.findFileTZVersion(TZ_LOCAL_FILE);
|
||||
|
||||
if (!TZ_LOCAL_FILE.exists()) {
|
||||
Logger.errorln("Local copy (zoneinfo.res) does not exist.");
|
||||
} else {
|
||||
TZ_LOCAL_URL = TZ_LOCAL_FILE.toURL();
|
||||
TZ_LOCAL_VERSION = ICUFile.findFileTZVersion(TZ_LOCAL_FILE);
|
||||
if (TZ_LOCAL_VERSION == null) {
|
||||
Logger.errorln("Failed to determine version of local copy");
|
||||
} else {
|
||||
TZ_LOCAL_CHOICE = "Local Copy (" + TZ_LOCAL_VERSION + ")";
|
||||
}
|
||||
}
|
||||
} catch (MalformedURLException ex) {
|
||||
// this shouldn't happen
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,17 +21,17 @@ rem Set environmental variables.
|
|||
call "%ICUTZU_HOME%runicutzuenv.bat"
|
||||
rem Double-check that JAVA_HOME is set.
|
||||
@echo Java Home: %JAVA_HOME%
|
||||
IF NOT EXIST "%JAVA_HOME%/bin/java" GOTO MissingJAVAHOME
|
||||
IF NOT EXIST "%JAVA_HOME%\bin\java.exe" GOTO MissingJAVAHOME
|
||||
|
||||
IF EXIST "%ICUTZU_HOME%\Temp" GOTO Next
|
||||
IF EXIST "%ICUTZU_HOME%Temp" GOTO Next
|
||||
rem Create a temporary directory.
|
||||
mkdir "%ICUTZU_HOME%\Temp"
|
||||
mkdir "%ICUTZU_HOME%Temp"
|
||||
:Next
|
||||
|
||||
rem Run the ICUTZU tool.
|
||||
@echo Launching the ICU4J Time Zone Update Utility (ICUTZU) ...
|
||||
@echo "%JAVA_HOME%\bin\java.exe" -cp "%ICUTZU_HOME%icu4j.jar";"%ICUTZU_HOME%icutzu.jar" -Dnogui=%NOGUI% -Ddiscoveronly=%DISCOVERONLY% -Dsilentpatch=%SILENTPATCH% com.ibm.icu.dev.tool.tzu.ICUTZUMain --recurse --backup "%ICUTZU_HOME%Temp"
|
||||
"%JAVA_HOME%\bin\java.exe" -cp "%ICUTZU_HOME%icu4j.jar";"%ICUTZU_HOME%icutzu.jar" -Dnogui=%NOGUI% -Ddiscoveronly=%DISCOVERONLY% -Dsilentpatch=%SILENTPATCH% com.ibm.icu.dev.tool.tzu.ICUTZUMain --recurse --backup "%ICUTZU_HOME%Temp"
|
||||
@echo "%JAVA_HOME%\bin\java.exe" -cp "%ICUTZU_HOME%icu4j.jar";"%ICUTZU_HOME%icutzu.jar" -Dnogui=%NOGUI% -Ddiscoveronly=%DISCOVERONLY% -Dsilentpatch=%SILENTPATCH% com.ibm.icu.dev.tool.tzu.ICUTZUMain --recurse --backup "%ICUTZU_HOME%Temp" %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
"%JAVA_HOME%\bin\java.exe" -cp "%ICUTZU_HOME%icu4j.jar";"%ICUTZU_HOME%icutzu.jar" -Dnogui=%NOGUI% -Ddiscoveronly=%DISCOVERONLY% -Dsilentpatch=%SILENTPATCH% com.ibm.icu.dev.tool.tzu.ICUTZUMain --recurse --backup "%ICUTZU_HOME%Temp" %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
|
||||
GOTO Exit
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue