2 *******************************************************************************
\r
3 * Copyright (C) 2009-2010, International Business Machines
\r
4 * Corporation and others. All Rights Reserved.
\r
5 *******************************************************************************
\r
8 package com.ibm.icu.impl;
\r
10 import java.util.MissingResourceException;
\r
12 import com.ibm.icu.util.UResourceBundle;
\r
13 import com.ibm.icu.util.VersionInfo;
\r
15 public final class ICUDataVersion {
\r
16 private static final String U_ICU_VERSION_BUNDLE = "icuver";
\r
17 private static final String U_ICU_STD_BUNDLE = "icustd";
\r
19 private static final String U_ICU_DATA_KEY = "DataVersion";
\r
22 * This function loads up icuver and compares the data version to the wired-in ICU_DATA_VERSION.
\r
23 * If icuver shows something less than ICU_DATA_VERSION it returns TRUE, else FALSE. The version
\r
24 * found will be returned in the first fillin parameter (if non-null), and *isModified will be set
\r
25 * to TRUE if "icustd" is NOT found. Thus, if the data has been repackaged or modified, "icustd"
\r
26 * (standard ICU) will be missing, and the function will alert the caller that the data is not standard.
\r
28 * @param dataVersionFillin icuver data version information to be filled in if not-null
\r
29 * @return TRUE if ICU_DATA_VERSION is newer than icuver, else FALSE
\r
31 public static boolean isDataOlder(VersionInfo dataVersionFillin) {
\r
32 boolean result = true;
\r
34 VersionInfo dataVersion = getDataVersion();
\r
36 if (dataVersion!= null) {
\r
37 if (dataVersion.compareTo(VersionInfo.ICU_DATA_VERSION) != -1) {
\r
41 if (dataVersionFillin != null) {
\r
42 dataVersionFillin = VersionInfo.getInstance(dataVersion.toString());
\r
50 * This function tests whether "icustd" is available in the data. If the data has been repackaged or modified, "icustd"
\r
51 * (standard ICU) will be missing, and the function will alert the caller that the data is not standard.
\r
53 * @return TRUE if data has been modified, else FALSE
\r
55 public static boolean isDataModified() {
\r
56 if (hasICUSTDBundle()) {
\r
63 * This function retrieves the data version from icuver and returns a VersionInfo object with that version information.
\r
65 * @return Current icu data version
\r
67 public static VersionInfo getDataVersion() {
\r
68 UResourceBundle icudatares = null;
\r
70 icudatares = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, ICUDataVersion.U_ICU_VERSION_BUNDLE, ICUResourceBundle.ICU_DATA_CLASS_LOADER);
\r
71 icudatares = icudatares.get(ICUDataVersion.U_ICU_DATA_KEY);
\r
72 } catch (MissingResourceException ex) {
\r
76 return VersionInfo.getInstance(icudatares.getString());
\r
79 private static boolean hasICUSTDBundle() {
\r
81 UResourceBundle.getBundleInstance(ICUDataVersion.U_ICU_STD_BUNDLE);
\r
82 } catch (MissingResourceException ex) {
\r