2002-07-14 22:07:00 +00:00
|
|
|
package com.ibm.text.UCD;
|
|
|
|
import com.ibm.text.utility.*;
|
|
|
|
import java.util.Date;
|
2002-07-30 09:57:18 +00:00
|
|
|
import java.text.DateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.TimeZone;
|
|
|
|
|
2002-07-14 22:07:00 +00:00
|
|
|
|
|
|
|
public final class Default implements UCD_Types {
|
|
|
|
|
2004-02-06 18:32:05 +00:00
|
|
|
private static String ucdVersion = UCD.latestVersion;
|
2004-02-07 01:01:17 +00:00
|
|
|
private static UCD ucd;
|
|
|
|
private static Normalizer nfc;
|
|
|
|
private static Normalizer nfd;
|
|
|
|
private static Normalizer nfkc;
|
|
|
|
private static Normalizer nfkd;
|
|
|
|
private static Normalizer[] nf = new Normalizer[4];
|
2003-03-15 02:36:49 +00:00
|
|
|
|
2002-07-14 22:07:00 +00:00
|
|
|
public static void setUCD(String version) {
|
2004-02-07 01:01:17 +00:00
|
|
|
ucdVersion = version;
|
2002-07-14 22:07:00 +00:00
|
|
|
setUCD();
|
|
|
|
}
|
|
|
|
|
2004-02-12 08:23:19 +00:00
|
|
|
private static boolean inRecursiveCall = false;
|
2004-02-07 01:01:17 +00:00
|
|
|
private static void setUCD() {
|
2004-02-12 08:23:19 +00:00
|
|
|
if (inRecursiveCall) {
|
|
|
|
throw new IllegalArgumentException("Recursive call to setUCD");
|
|
|
|
}
|
|
|
|
inRecursiveCall = true;
|
|
|
|
ucd = UCD.make(ucdVersion);
|
2004-02-07 01:01:17 +00:00
|
|
|
nfd = nf[NFD] = new Normalizer(Normalizer.NFD, ucdVersion());
|
|
|
|
nfc = nf[NFC] = new Normalizer(Normalizer.NFC, ucdVersion());
|
|
|
|
nfkd = nf[NFKD] = new Normalizer(Normalizer.NFKD, ucdVersion());
|
|
|
|
nfkc = nf[NFKC] = new Normalizer(Normalizer.NFKC, ucdVersion());
|
|
|
|
System.out.println("Loaded UCD" + ucd().getVersion() + " " + (new Date(ucd().getDate())));
|
2004-02-12 08:23:19 +00:00
|
|
|
inRecursiveCall = false;
|
2002-07-14 22:07:00 +00:00
|
|
|
}
|
2002-07-30 09:57:18 +00:00
|
|
|
|
2003-03-12 16:01:26 +00:00
|
|
|
static DateFormat myDateFormat = new SimpleDateFormat("yyyy-MM-dd', 'HH:mm:ss' GMT'");
|
2002-07-30 09:57:18 +00:00
|
|
|
static {
|
|
|
|
myDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String getDate() {
|
|
|
|
return myDateFormat.format(new Date());
|
|
|
|
}
|
2002-07-14 22:07:00 +00:00
|
|
|
|
2004-02-07 01:01:17 +00:00
|
|
|
public static String ucdVersion() {
|
2004-02-12 08:23:19 +00:00
|
|
|
if (ucd == null) setUCD();
|
2004-02-07 01:01:17 +00:00
|
|
|
return ucdVersion;
|
2004-02-06 18:32:05 +00:00
|
|
|
}
|
|
|
|
|
2004-02-07 01:01:17 +00:00
|
|
|
public static UCD ucd() {
|
2004-02-12 08:23:19 +00:00
|
|
|
if (ucd == null) setUCD();
|
2004-02-07 01:01:17 +00:00
|
|
|
return ucd;
|
|
|
|
}
|
|
|
|
public static Normalizer nfc() {
|
2004-02-12 08:23:19 +00:00
|
|
|
if (ucd == null) setUCD();
|
2004-02-07 01:01:17 +00:00
|
|
|
return nfc;
|
|
|
|
}
|
|
|
|
public static Normalizer nfd() {
|
2004-02-12 08:23:19 +00:00
|
|
|
if (ucd == null) setUCD();
|
2004-02-07 01:01:17 +00:00
|
|
|
return nfd;
|
|
|
|
}
|
|
|
|
public static Normalizer nfkc() {
|
2004-02-12 08:23:19 +00:00
|
|
|
if (ucd == null) setUCD();
|
2004-02-07 01:01:17 +00:00
|
|
|
return nfkc;
|
|
|
|
}
|
|
|
|
public static Normalizer nfkd() {
|
2004-02-12 08:23:19 +00:00
|
|
|
if (ucd == null) setUCD();
|
2004-02-07 01:01:17 +00:00
|
|
|
return nfkd;
|
|
|
|
}
|
|
|
|
public static Normalizer nf(int index) {
|
2004-02-12 08:23:19 +00:00
|
|
|
if (ucd == null) setUCD();
|
2004-02-07 01:01:17 +00:00
|
|
|
return nf[index];
|
2004-02-06 18:32:05 +00:00
|
|
|
}
|
|
|
|
|
2002-07-14 22:07:00 +00:00
|
|
|
}
|