-package tool;\r
-\r
-import java.security.MessageDigest;\r
-import java.util.TimeZone;\r
-\r
-import gnu.regexp.RE;\r
-import mir.util.StringRoutines;\r
-\r
-/**\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
-\r
-public class ConfigTool {\r
- public ConfigTool() {\r
- }\r
-\r
- public static void timezone(String aSpecification) {\r
- try {\r
- RE specification = new RE(aSpecification);\r
- String[] timeZoneIds = TimeZone.getAvailableIDs();\r
-\r
- System.out.println("ID\tOffset\tDST?\tName");\r
- for (int i=0; i<timeZoneIds.length; i++) {\r
- if (specification.isMatch(timeZoneIds[i])) {\r
- TimeZone timeZone = TimeZone.getTimeZone(timeZoneIds[i]);\r
- long offset = timeZone.getRawOffset()/(1000*60);\r
- String sign = "";\r
- if (offset<0) {\r
- offset=-offset;\r
- sign = "-";\r
- }\r
-\r
- System.out.println(timeZone.getID() + "\t" + sign + offset/60 + ":" + StringRoutines.padStringLeft(Long.toString(offset%60),2,'0')+"\t"+(timeZone.useDaylightTime()?"yes":"no")+"\t"+ timeZone.getDisplayName());\r
- }\r
- }\r
- }\r
- catch (Throwable t) {\r
- System.err.println(t.toString());\r
- }\r
- }\r
-\r
- public static void digest(String aDigest, String aData) {\r
- try {\r
- MessageDigest messageDigest = MessageDigest.getInstance(aDigest);\r
-\r
- System.out.println(StringRoutines.convertToHex(messageDigest.digest(aData.getBytes("UTF-8"))));\r
- }\r
- catch (Throwable t) {\r
- System.err.println(t.toString());\r
- }\r
- }\r
-\r
- public static void main(String[] anArguments) {\r
- String command = "help";\r
-\r
- if (anArguments.length >= 1) {\r
- command = anArguments[0];\r
-\r
- if (command.equals("timezone")) {\r
- if (anArguments.length<=2) {\r
- if (anArguments.length==2)\r
- timezone(anArguments[1]);\r
- else\r
- timezone(".*");\r
- }\r
-\r
- return;\r
- }\r
- else if (command.equals("digest")) {\r
- if (anArguments.length == 3) {\r
- digest(anArguments[1], anArguments[2]);\r
-\r
- return;\r
- }\r
- }\r
- }\r
-\r
-\r
-\r
- System.out.println("Usage:");\r
-\r
- System.out.println(" ConfigTool timezone [regexp]");\r
- System.out.println("");\r
- System.out.println(" Shows the available timezones");\r
- System.out.println("");\r
- System.out.println(" BundleTool digest <digestname> <string>");\r
- System.out.println("");\r
- System.out.println(" Calculates the digest of a string.");\r
- System.out.println("");\r
- }\r
+/*
+ * Copyright (C) 2001, 2002 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package tool;
+
+import java.security.MessageDigest;
+import java.util.TimeZone;
+
+import mir.util.StringRoutines;
+import org.apache.oro.text.regex.Perl5Compiler;
+import org.apache.oro.text.regex.Pattern;
+import org.apache.oro.text.regex.Perl5Matcher;
+import org.apache.oro.text.regex.PatternMatcher;
+
+/**
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+
+public class ConfigTool {
+ public ConfigTool() {
+ }
+
+ public static void timezone(String aSpecification) {
+ try {
+ PatternMatcher matcher = new Perl5Matcher();
+ Pattern specification = new Perl5Compiler().compile(aSpecification);
+ String[] timeZoneIds = TimeZone.getAvailableIDs();
+
+ System.out.println("ID\tOffset\tDST?\tName");
+ for (int i=0; i<timeZoneIds.length; i++) {
+ if (matcher.contains(timeZoneIds[i], specification)) {
+ TimeZone timeZone = TimeZone.getTimeZone(timeZoneIds[i]);
+ long offset = timeZone.getRawOffset()/(1000*60);
+ String sign = "";
+ if (offset<0) {
+ offset=-offset;
+ sign = "-";
+ }
+
+ System.out.println(timeZone.getID() + "\t" + sign + offset/60 + ":" + StringRoutines.padStringLeft(Long.toString(offset%60),2,'0')+"\t"+(timeZone.useDaylightTime()?"yes":"no")+"\t"+ timeZone.getDisplayName());
+ }
+ }
+ }
+ catch (Throwable t) {
+ System.err.println(t.toString());
+ }
+ }
+
+ public static void digest(String aDigest, String aData) {
+ try {
+ MessageDigest messageDigest = MessageDigest.getInstance(aDigest);
+
+ System.out.println(StringRoutines.convertToHex(messageDigest.digest(aData.getBytes("UTF-8"))));
+ }
+ catch (Throwable t) {
+ System.err.println(t.toString());
+ }
+ }
+
+ public static void main(String[] anArguments) {
+ String command;
+
+ if (anArguments.length >= 1) {
+ command = anArguments[0];
+
+ if ("timezone".equals(command)) {
+ if (anArguments.length<=2) {
+ if (anArguments.length==2)
+ timezone(anArguments[1]);
+ else
+ timezone(".*");
+ }
+
+ return;
+ }
+ else if ("digest".equals(command)) {
+ if (anArguments.length == 3) {
+ digest(anArguments[1], anArguments[2]);
+
+ return;
+ }
+ }
+ }
+
+
+
+ System.out.println("Usage:");
+
+ System.out.println(" ConfigTool timezone [regexp]");
+ System.out.println("");
+ System.out.println(" Shows the available timezones");
+ System.out.println("");
+ System.out.println(" BundleTool digest <digestname> <string>");
+ System.out.println("");
+ System.out.println(" Calculates the digest of a string.");
+ System.out.println("");
+ }
}
\ No newline at end of file