Package com.ibm.icu.util

Examples of com.ibm.icu.util.VersionInfo


        // get the options
        doNFKC            = ((indexes[OPTIONS] & NORMALIZATION_ON) > 0);
        checkBiDi         = ((indexes[OPTIONS] & CHECK_BIDI_ON) > 0);
        sprepUniVer   = getVersionInfo(reader.getUnicodeVersion());
        normCorrVer   = getVersionInfo(indexes[NORM_CORRECTNS_LAST_UNI_VERSION]);
        VersionInfo normUniVer = Normalizer.getUnicodeVersion();
        if(normUniVer.compareTo(sprepUniVer) < 0 && /* the Unicode version of SPREP file must be less than the Unicode Vesion of the normalization data */
           normUniVer.compareTo(normCorrVer) < 0 && /* the Unicode version of the NormalizationCorrections.txt file should be less than the Unicode Vesion of the normalization data */
           ((indexes[OPTIONS] & NORMALIZATION_ON) > 0) /* normalization turned on*/
           ){
            throw new IOException("Normalization Correction version not supported");
        }
        b.close();
View Full Code Here


    static {
        initCharFromDirProps();
    }

    private static void initCharFromDirProps() {
        final VersionInfo ucd401 =  VersionInfo.getInstance(4, 0, 1, 0);
        VersionInfo ucdVersion = VersionInfo.getInstance(0, 0, 0, 0);

        /* lazy initialization */
        if (ucdVersion.getMajor() > 0) {
            return;

        }
        ucdVersion = UCharacter.getUnicodeVersion();
        if (ucdVersion.compareTo(ucd401) >= 0) {
            /* Unicode 4.0.1 changes bidi classes for +-/ */
            /* change ES character from / to + */
            charFromDirProp[TestData.ES] = 0x2b;
        }
    }
View Full Code Here

     * Test that the comparison works
     */
    public void TestCompare()
    {
        for (int i = 0; i < COMPARE_NOT_EQUAL_STRING_.length; i += 2) {
            VersionInfo v1 =
                        VersionInfo.getInstance(COMPARE_NOT_EQUAL_STRING_[i]);
            VersionInfo v2 =
                    VersionInfo.getInstance(COMPARE_NOT_EQUAL_STRING_[i + 1]);
            if (v1.compareTo(v2) == 0) {
                errln(COMPARE_NOT_EQUAL_STRING_[i] + " should not equal " +
                      COMPARE_NOT_EQUAL_STRING_[i + 1]);
            }
        }
        for (int i = 0; i < COMPARE_NOT_EQUAL_INT_.length; i += 2) {
            VersionInfo v1 = getInstance(COMPARE_NOT_EQUAL_INT_[i]);
            VersionInfo v2 = getInstance(COMPARE_NOT_EQUAL_INT_[i + 1]);
            if (v1.compareTo(v2) == 0) {
                errln(COMPARE_NOT_EQUAL_INT_[i] + " should not equal " +
                      COMPARE_NOT_EQUAL_INT_[i + 1]);
            }
        }
        for (int i = 0; i < COMPARE_EQUAL_STRING_.length - 1; i ++) {
            VersionInfo v1 =
                        VersionInfo.getInstance(COMPARE_EQUAL_STRING_[i]);
            VersionInfo v2 =
                    VersionInfo.getInstance(COMPARE_EQUAL_STRING_[i + 1]);
            if (v1.compareTo(v2) != 0) {
                errln(COMPARE_EQUAL_STRING_[i] + " should equal " +
                      COMPARE_EQUAL_STRING_[i + 1]);
            }
        }
        for (int i = 0; i < COMPARE_EQUAL_INT_.length - 1; i ++) {
            VersionInfo v1 = getInstance(COMPARE_EQUAL_INT_[i]);
            VersionInfo v2 = getInstance(COMPARE_EQUAL_INT_[i + 1]);
            if (v1.compareTo(v2) != 0) {
                errln(COMPARE_EQUAL_INT_[i] + " should equal " +
                      COMPARE_EQUAL_INT_[i + 1]);
            }
        }
        for (int i = 0; i < COMPARE_LESS_.length - 1; i ++) {
            VersionInfo v1 = VersionInfo.getInstance(COMPARE_LESS_[i]);
            VersionInfo v2 = VersionInfo.getInstance(COMPARE_LESS_[i + 1]);
            if (v1.compareTo(v2) >= 0) {
                errln(COMPARE_LESS_[i] + " should be less than " +
                      COMPARE_LESS_[i + 1]);
            }
            if (v2.compareTo(v1) <= 0) {
                errln(COMPARE_LESS_[i + 1] + " should be greater than " +
                      COMPARE_LESS_[i]);
            }
        }
    }
View Full Code Here

     * Test that the getter function works
     */
    public void TestGetter()
    {
        for (int i = 0; i < GET_STRING_.length; i ++) {
            VersionInfo v = VersionInfo.getInstance(GET_STRING_[i]);
            if (v.getMajor() != GET_RESULT_[i << 2] ||
                v.getMinor() != GET_RESULT_[(i << 2) + 1] ||
                v.getMilli() != GET_RESULT_[(i << 2) + 2] ||
                v.getMicro() != GET_RESULT_[(i << 2) + 3]) {
                errln(GET_STRING_[i] + " should return major=" +
                      GET_RESULT_[i << 2] + " minor=" +
                      GET_RESULT_[(i << 2) + 1] + " milli=" +
                      GET_RESULT_[(i << 2) + 2] + " micro=" +
                      GET_RESULT_[(i << 2) + 3])
            }
            v = getInstance(GET_INT_[i]);
            if (v.getMajor() != GET_RESULT_[i << 2] ||
                v.getMinor() != GET_RESULT_[(i << 2) + 1] ||
                v.getMilli() != GET_RESULT_[(i << 2) + 2] ||
                v.getMicro() != GET_RESULT_[(i << 2) + 3]) {
                errln(GET_STRING_[i] + " should return major=" +
                      GET_RESULT_[i << 2] + " minor=" +
                      GET_RESULT_[(i << 2) + 1] + " milli=" +
                      GET_RESULT_[(i << 2) + 2] + " micro=" +
                      GET_RESULT_[(i << 2) + 3])
View Full Code Here

            static String[] AGES = null;
            private String[] getAges() {
                if (AGES == null) {
                  Set ages = new TreeSet();
                  for (int i = 0; i < 0x10FFFF; ++i) {
                    VersionInfo age = UCharacter.getAge(i);
                    ages.add(age.toString());
                  }
                  AGES = (String[]) ages.toArray(new String[ages.size()]);
                }
                return AGES;
            }
View Full Code Here

            }
        }
    }
    public void TestCLDRVersion() {
        //VersionInfo zeroVersion = VersionInfo.getInstance(0, 0, 0, 0);
        VersionInfo testExpect;
        VersionInfo testCurrent;
        VersionInfo cldrVersion;
        cldrVersion = ULocale.getCLDRVersion();
       
        this.logln("uloc_getCLDRVersion() returned: '"+cldrVersion+"'");
       
        // why isn't this public for tests somewhere?
        final ClassLoader testLoader = ICUResourceBundleTest.class.getClassLoader();
        UResourceBundle bundle = (UResourceBundle) UResourceBundle.getBundleInstance("com/ibm/icu/dev/data/testdata", ULocale.ROOT, testLoader);
       
        testExpect = VersionInfo.getInstance(bundle.getString("ExpectCLDRVersionAtLeast"));
        testCurrent = VersionInfo.getInstance(bundle.getString("CurrentCLDRVersion"));

       
        logln("(data) ExpectCLDRVersionAtLeast { "+testExpect+"");
        if(cldrVersion.compareTo(testExpect)<0) {
            errln("CLDR version is too old, expect at least "+testExpect+".");
        }

        int r = cldrVersion.compareTo(testCurrent);
        if ( r < 0 ) {
            logln("CLDR version is behind 'current' (for testdata/root.txt) "+testCurrent+". Some things may fail.\n");
        } else if ( r > 0) {
            logln("CLDR version is ahead of 'current' (for testdata/root.txt) "+testCurrent+". Some things may fail.\n");
        } else {
View Full Code Here

        logln("Test ctors : ");
        Collator col = Collator.getInstance(Locale.ENGLISH);

   
        logln("Test getVersion");
        VersionInfo expectedVersion = VersionInfo.getInstance(0x31, 0xC0, 0x00, 0x05);
        doAssert(col.getVersion().equals(expectedVersion), "Expected version "+expectedVersion.toString()+" got "+col.getVersion().toString());
       
        logln("Test getUCAVersion");
        VersionInfo expectedUCAVersion = VersionInfo.getInstance(0x05, 1, 0, 0);
        doAssert(col.getUCAVersion().equals(expectedUCAVersion), "Expected UCA version "+expectedUCAVersion.toString()+" got "+col.getUCAVersion().toString());
       
        doAssert((col.compare("ab", "abc") < 0), "ab < abc comparison failed");
        doAssert((col.compare("ab", "AB") < 0), "ab < AB comparison failed");
        doAssert((col.compare("blackbird", "black-bird") > 0), "black-bird > blackbird comparison failed");
        doAssert((col.compare("black bird", "black-bird") < 0), "black bird > black-bird comparison failed");
View Full Code Here

        // get the options
        doNFKC            = ((indexes[OPTIONS] & NORMALIZATION_ON) > 0);
        checkBiDi         = ((indexes[OPTIONS] & CHECK_BIDI_ON) > 0);
        sprepUniVer   = getVersionInfo(reader.getUnicodeVersion());
        normCorrVer   = getVersionInfo(indexes[NORM_CORRECTNS_LAST_UNI_VERSION]);
        VersionInfo normUniVer = UCharacter.getUnicodeVersion();
        if(normUniVer.compareTo(sprepUniVer) < 0 && /* the Unicode version of SPREP file must be less than the Unicode Vesion of the normalization data */
           normUniVer.compareTo(normCorrVer) < 0 && /* the Unicode version of the NormalizationCorrections.txt file should be less than the Unicode Vesion of the normalization data */
           ((indexes[OPTIONS] & NORMALIZATION_ON) > 0) /* normalization turned on*/
           ){
            throw new IOException("Normalization Correction version not supported");
        }
        b.close();
View Full Code Here

          throw new IllegalArgumentException("Unicode_1_Name (na1) not supported");
        case UProperty.AGE: {
          // Must munge name, since
          // VersionInfo.getInstance() does not do
          // 'loose' matching.
          VersionInfo version = VersionInfo.getInstance(mungeCharName(valueAlias));
          applyFilter(new VersionFilter(version), UCharacterProperty.SRC_PROPSVEC);
          return this;
        }
        case UProperty.SCRIPT_EXTENSIONS:
          v = UCharacter.getPropertyValueEnum(UProperty.SCRIPT, valueAlias);
View Full Code Here

    VersionFilter(final VersionInfo version) {
      this.version = version;
    }

    public boolean contains(final int ch) {
      VersionInfo v = UCharacter.getAge(ch);
      // Reference comparison ok; VersionInfo caches and reuses
      // unique objects.
      return v != NO_VERSION && v.compareTo(version) <= 0;
    }
View Full Code Here

TOP

Related Classes of com.ibm.icu.util.VersionInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.