Search in sources :

Example 11 with ICUUncheckedIOException

use of android.icu.util.ICUUncheckedIOException in project j2objc by google.

the class CaseMapImpl method fold.

public static <A extends Appendable> A fold(int options, CharSequence src, A dest, Edits edits) {
    try {
        if (edits != null) {
            edits.reset();
        }
        int length = src.length();
        for (int i = 0; i < length; ) {
            int c = Character.codePointAt(src, i);
            int cpLength = Character.charCount(c);
            i += cpLength;
            c = UCaseProps.INSTANCE.toFullFolding(c, dest, options);
            appendResult(c, dest, cpLength, options, edits);
        }
        return dest;
    } catch (IOException e) {
        throw new ICUUncheckedIOException(e);
    }
}
Also used : ICUUncheckedIOException(android.icu.util.ICUUncheckedIOException) ICUUncheckedIOException(android.icu.util.ICUUncheckedIOException) IOException(java.io.IOException)

Example 12 with ICUUncheckedIOException

use of android.icu.util.ICUUncheckedIOException in project j2objc by google.

the class CaseMapImpl method toLower.

public static <A extends Appendable> A toLower(int caseLocale, int options, CharSequence src, A dest, Edits edits) {
    try {
        if (edits != null) {
            edits.reset();
        }
        StringContextIterator iter = new StringContextIterator(src);
        internalToLower(caseLocale, options, iter, dest, edits);
        return dest;
    } catch (IOException e) {
        throw new ICUUncheckedIOException(e);
    }
}
Also used : ICUUncheckedIOException(android.icu.util.ICUUncheckedIOException) ICUUncheckedIOException(android.icu.util.ICUUncheckedIOException) IOException(java.io.IOException)

Example 13 with ICUUncheckedIOException

use of android.icu.util.ICUUncheckedIOException in project j2objc by google.

the class Normalizer2Impl method load.

public Normalizer2Impl load(ByteBuffer bytes) {
    try {
        dataVersion = ICUBinary.readHeaderAndDataVersion(bytes, DATA_FORMAT, IS_ACCEPTABLE);
        // inIndexes[IX_NORM_TRIE_OFFSET]/4
        int indexesLength = bytes.getInt() / 4;
        if (indexesLength <= IX_MIN_LCCC_CP) {
            throw new ICUUncheckedIOException("Normalizer2 data: not enough indexes");
        }
        int[] inIndexes = new int[indexesLength];
        inIndexes[0] = indexesLength * 4;
        for (int i = 1; i < indexesLength; ++i) {
            inIndexes[i] = bytes.getInt();
        }
        minDecompNoCP = inIndexes[IX_MIN_DECOMP_NO_CP];
        minCompNoMaybeCP = inIndexes[IX_MIN_COMP_NO_MAYBE_CP];
        minLcccCP = inIndexes[IX_MIN_LCCC_CP];
        minYesNo = inIndexes[IX_MIN_YES_NO];
        minYesNoMappingsOnly = inIndexes[IX_MIN_YES_NO_MAPPINGS_ONLY];
        minNoNo = inIndexes[IX_MIN_NO_NO];
        minNoNoCompBoundaryBefore = inIndexes[IX_MIN_NO_NO_COMP_BOUNDARY_BEFORE];
        minNoNoCompNoMaybeCC = inIndexes[IX_MIN_NO_NO_COMP_NO_MAYBE_CC];
        minNoNoEmpty = inIndexes[IX_MIN_NO_NO_EMPTY];
        limitNoNo = inIndexes[IX_LIMIT_NO_NO];
        minMaybeYes = inIndexes[IX_MIN_MAYBE_YES];
        // 8-aligned for noNoDelta bit fields
        assert ((minMaybeYes & 7) == 0);
        centerNoNoDelta = (minMaybeYes >> DELTA_SHIFT) - MAX_DELTA - 1;
        // Read the normTrie.
        int offset = inIndexes[IX_NORM_TRIE_OFFSET];
        int nextOffset = inIndexes[IX_EXTRA_DATA_OFFSET];
        normTrie = Trie2_16.createFromSerialized(bytes);
        int trieLength = normTrie.getSerializedLength();
        if (trieLength > (nextOffset - offset)) {
            throw new ICUUncheckedIOException("Normalizer2 data: not enough bytes for normTrie");
        }
        // skip padding after trie bytes
        ICUBinary.skipBytes(bytes, (nextOffset - offset) - trieLength);
        // Read the composition and mapping data.
        offset = nextOffset;
        nextOffset = inIndexes[IX_SMALL_FCD_OFFSET];
        int numChars = (nextOffset - offset) / 2;
        if (numChars != 0) {
            maybeYesCompositions = ICUBinary.getString(bytes, numChars, 0);
            extraData = maybeYesCompositions.substring((MIN_NORMAL_MAYBE_YES - minMaybeYes) >> OFFSET_SHIFT);
        }
        // smallFCD: new in formatVersion 2
        offset = nextOffset;
        smallFCD = new byte[0x100];
        bytes.get(smallFCD);
        return this;
    } catch (IOException e) {
        throw new ICUUncheckedIOException(e);
    }
}
Also used : ICUUncheckedIOException(android.icu.util.ICUUncheckedIOException) ICUUncheckedIOException(android.icu.util.ICUUncheckedIOException) IOException(java.io.IOException)

Aggregations

ICUUncheckedIOException (android.icu.util.ICUUncheckedIOException)13 IOException (java.io.IOException)13 ByteBuffer (java.nio.ByteBuffer)3 MissingResourceException (java.util.MissingResourceException)2 ICUResourceBundle (android.icu.impl.ICUResourceBundle)1 Norm2AllModes (android.icu.impl.Norm2AllModes)1 ULocale (android.icu.util.ULocale)1 UResourceBundle (android.icu.util.UResourceBundle)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1