Java Code Examples for com.ibm.icu.util.VersionInfo#getInstance()

The following examples show how to use com.ibm.icu.util.VersionInfo#getInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestICUVersionRecord.java    From database with GNU General Public License v2.0 6 votes vote down vote up
public void test_roundTrip2() {

        final ICUVersionRecord r1 = new ICUVersionRecord(
                VersionInfo.getInstance(3, 6, 2, 1),//
                VersionInfo.getInstance(1, 8, 5, 7),//
                VersionInfo.getInstance(6, 3, 1, 8),//
                VersionInfo.getInstance(4, 6, 8, 12)//
                );

        final ICUVersionRecord r2 = new ICUVersionRecord( 
            VersionInfo.getInstance(3, 6, 2, 1),//
            VersionInfo.getInstance(1, 8, 5, 7),//
            VersionInfo.getInstance(6, 3, 1, 8),//
            VersionInfo.getInstance(4, 6, 8, 12)//
            );
        
        assertTrue(r1.equals(r2));
        
        assertFalse(r1.equals(ICUVersionRecord.newInstance()));
        
        final ICUVersionRecord r3 = (ICUVersionRecord) SerializerUtil
                .deserialize(SerializerUtil.serialize(r1));

        assertTrue(r1.equals(r3));

    }
 
Example 2
Source File: RuleBasedCollator.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
/**
 * Get the version of this collator object.
 * 
 * @return the version object associated with this collator
 * @stable ICU 2.8
 */
@Override
public VersionInfo getVersion() {
    int version = tailoring.version;
    int rtVersion = VersionInfo.UCOL_RUNTIME_VERSION.getMajor();
    return VersionInfo.getInstance(
            (version >>> 24) + (rtVersion << 4) + (rtVersion >> 4),
            ((version >> 16) & 0xff), ((version >> 8) & 0xff), (version & 0xff));
}
 
Example 3
Source File: RuleBasedCollator.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
/**
 * Get the UCA version of this collator object.
 * 
 * @return the version object associated with this collator
 * @stable ICU 2.8
 */
@Override
public VersionInfo getUCAVersion() {
    VersionInfo v = getVersion();
    // Note: This is tied to how the current implementation encodes the UCA version
    // in the overall getVersion().
    // Alternatively, we could load the root collator and get at lower-level data from there.
    // Either way, it will reflect the input collator's UCA version only
    // if it is a known implementation.
    // (C++ comment) It would be cleaner to make this a virtual Collator method.
    // (In Java, it is virtual.)
    return VersionInfo.getInstance(v.getMinor() >> 3, v.getMinor() & 7, v.getMilli() >> 6, 0);
}
 
Example 4
Source File: StringPrep.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
private static VersionInfo getVersionInfo(int comp){
    int micro = comp & 0xFF;
    int milli =(comp >> 8)  & 0xFF;
    int minor =(comp >> 16) & 0xFF;
    int major =(comp >> 24) & 0xFF;
    return VersionInfo.getInstance(major,minor,milli,micro);
}
 
Example 5
Source File: ICUDataVersion.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
/**
 * This function retrieves the data version from icuver and returns a VersionInfo object with that version information.
 *
 * @return Current icu data version
 */
public static VersionInfo getDataVersion() {
    UResourceBundle icudatares = null;
    try {
        icudatares = UResourceBundle.getBundleInstance(
                ICUData.ICU_BASE_NAME,
                ICUDataVersion.U_ICU_VERSION_BUNDLE,
                ICUResourceBundle.ICU_DATA_CLASS_LOADER);
        icudatares = icudatares.get(ICUDataVersion.U_ICU_DATA_KEY);
    } catch (MissingResourceException ex) {
        return null;
    }
    
    return  VersionInfo.getInstance(icudatares.getString());
}
 
Example 6
Source File: ICUDebug.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
public static VersionInfo getInstanceLenient(String s) {
    // Extracting ASCII numbers up to 4 delimited by
    // any non digit characters
    int[] ver = new int[4];
    boolean numeric = false;
    int i = 0, vidx = 0;
    while (i < s.length()) {
        char c = s.charAt(i++);
        if (c < '0' || c > '9') {
            if (numeric) {
                if (vidx == 3) {
                    // up to 4 numbers
                    break;
                }
                numeric = false;
                vidx++;
            }
        } else {
            if (numeric) {
                ver[vidx] = ver[vidx] * 10 + (c - '0');
                if (ver[vidx] > 255) {
                    // VersionInfo does not support numbers
                    // greater than 255.  In such case, we
                    // ignore the number and the rest
                    ver[vidx] = 0;
                    break;
                }
            } else {
                numeric = true;
                ver[vidx] = c - '0';
            }
        }
    }

    return VersionInfo.getInstance(ver[0], ver[1], ver[2], ver[3]);
}
 
Example 7
Source File: CollationTailoring.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
static VersionInfo makeBaseVersion(VersionInfo ucaVersion) {
    return VersionInfo.getInstance(
            VersionInfo.UCOL_BUILDER_VERSION.getMajor(),
            (ucaVersion.getMajor() << 3) + ucaVersion.getMinor(),
            ucaVersion.getMilli() << 6,
            0);
}
 
Example 8
Source File: StringPrep.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
private static VersionInfo getVersionInfo(int comp){
    int micro = comp & 0xFF;
    int milli =(comp >> 8)  & 0xFF;
    int minor =(comp >> 16) & 0xFF;
    int major =(comp >> 24) & 0xFF;
    return VersionInfo.getInstance(major,minor,milli,micro);
}
 
Example 9
Source File: ICUDebug.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
public static VersionInfo getInstanceLenient(String s) {
    // Extracting ASCII numbers up to 4 delimited by
    // any non digit characters
    int[] ver = new int[4];
    boolean numeric = false;
    int i = 0, vidx = 0;
    while (i < s.length()) {
        char c = s.charAt(i++);
        if (c < '0' || c > '9') {
            if (numeric) {
                if (vidx == 3) {
                    // up to 4 numbers
                    break;
                }
                numeric = false;
                vidx++;
            }
        } else {
            if (numeric) {
                ver[vidx] = ver[vidx] * 10 + (c - '0');
                if (ver[vidx] > 255) {
                    // VersionInfo does not support numbers
                    // greater than 255.  In such case, we
                    // ignore the number and the rest
                    ver[vidx] = 0;
                    break;
                }
            } else {
                numeric = true;
                ver[vidx] = c - '0';
            }
        }
    }

    return VersionInfo.getInstance(ver[0], ver[1], ver[2], ver[3]);
}
 
Example 10
Source File: StringPrep.java    From fitnotifications with Apache License 2.0 4 votes vote down vote up
private static VersionInfo getVersionInfo(byte[] version){
    if(version.length != 4){
        return null;
    }
    return VersionInfo.getInstance((int)version[0],(int) version[1],(int) version[2],(int) version[3]);
}
 
Example 11
Source File: ICUBinary.java    From fitnotifications with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a VersionInfo for the bytes in the compact version integer.
 */
public static VersionInfo getVersionInfoFromCompactInt(int version) {
    return VersionInfo.getInstance(
            version >>> 24, (version >> 16) & 0xff, (version >> 8) & 0xff, version & 0xff);
}
 
Example 12
Source File: StringPrep.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
private static VersionInfo getVersionInfo(byte[] version){
    if(version.length != 4){
        return null;
    }
    return VersionInfo.getInstance((int)version[0],(int) version[1],(int) version[2],(int) version[3]);
}
 
Example 13
Source File: ICUBinary.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns a VersionInfo for the bytes in the compact version integer.
 */
public static VersionInfo getVersionInfoFromCompactInt(int version) {
    return VersionInfo.getInstance(
            version >>> 24, (version >> 16) & 0xff, (version >> 8) & 0xff, version & 0xff);
}
 
Example 14
Source File: UCharacterProperty.java    From fitnotifications with Apache License 2.0 3 votes vote down vote up
/**
 * <p>Get the "age" of the code point.</p>
 * <p>The "age" is the Unicode version when the code point was first
 * designated (as a non-character or for Private Use) or assigned a
 * character.</p>
 * <p>This can be useful to avoid emitting code points to receiving
 * processes that do not accept newer characters.</p>
 * <p>The data is from the UCD file DerivedAge.txt.</p>
 * <p>This API does not check the validity of the codepoint.</p>
 * @param codepoint The code point.
 * @return the Unicode version number
 */
public VersionInfo getAge(int codepoint)
{
    int version = getAdditional(codepoint, 0) >> AGE_SHIFT_;
    return VersionInfo.getInstance(
                       (version >> FIRST_NIBBLE_SHIFT_) & LAST_NIBBLE_MASK_,
                       version & LAST_NIBBLE_MASK_, 0, 0);
}
 
Example 15
Source File: UCharacterProperty.java    From trekarta with GNU General Public License v3.0 3 votes vote down vote up
/**
 * <p>Get the "age" of the code point.</p>
 * <p>The "age" is the Unicode version when the code point was first
 * designated (as a non-character or for Private Use) or assigned a
 * character.</p>
 * <p>This can be useful to avoid emitting code points to receiving
 * processes that do not accept newer characters.</p>
 * <p>The data is from the UCD file DerivedAge.txt.</p>
 * <p>This API does not check the validity of the codepoint.</p>
 * @param codepoint The code point.
 * @return the Unicode version number
 */
public VersionInfo getAge(int codepoint)
{
    int version = getAdditional(codepoint, 0) >> AGE_SHIFT_;
    return VersionInfo.getInstance(
                       (version >> FIRST_NIBBLE_SHIFT_) & LAST_NIBBLE_MASK_,
                       version & LAST_NIBBLE_MASK_, 0, 0);
}
 
Example 16
Source File: ICUVersionRecord.java    From database with GNU General Public License v2.0 3 votes vote down vote up
private VersionInfo readVersionInfo(final ObjectInput in) throws IOException {

        final int major = in.readInt();
        final int minor = in.readInt();
        final int micro = in.readInt();
        final int milli = in.readInt();
        
        return VersionInfo.getInstance(major, minor, milli, micro);
        
    }