Search in sources :

Example 1 with CollationIterator

use of android.icu.impl.coll.CollationIterator in project j2objc by google.

the class CollationElementIterator method setText.

/**
 * Set a new source string for iteration, and reset the offset
 * to the beginning of the text.
 *
 * @param source the new source string for iteration.
 */
public void setText(String source) {
    // TODO: do we need to remember the source string in a field?
    string_ = source;
    CollationIterator newIter;
    boolean numeric = rbc_.settings.readOnly().isNumeric();
    if (rbc_.settings.readOnly().dontCheckFCD()) {
        newIter = new UTF16CollationIterator(rbc_.data, numeric, string_, 0);
    } else {
        newIter = new FCDUTF16CollationIterator(rbc_.data, numeric, string_, 0);
    }
    iter_ = newIter;
    otherHalf_ = 0;
    dir_ = 0;
}
Also used : FCDUTF16CollationIterator(android.icu.impl.coll.FCDUTF16CollationIterator) UTF16CollationIterator(android.icu.impl.coll.UTF16CollationIterator) FCDUTF16CollationIterator(android.icu.impl.coll.FCDUTF16CollationIterator) UTF16CollationIterator(android.icu.impl.coll.UTF16CollationIterator) CollationIterator(android.icu.impl.coll.CollationIterator) FCDIterCollationIterator(android.icu.impl.coll.FCDIterCollationIterator) FCDUTF16CollationIterator(android.icu.impl.coll.FCDUTF16CollationIterator) IterCollationIterator(android.icu.impl.coll.IterCollationIterator)

Example 2 with CollationIterator

use of android.icu.impl.coll.CollationIterator in project j2objc by google.

the class CollationElementIterator method setText.

/**
 * Set a new source string iterator for iteration, and reset the
 * offset to the beginning of the text.
 *
 * @param source the new source string iterator for iteration.
 */
public void setText(CharacterIterator source) {
    // Note: In C++, we just setText(source.getText()).
    // In Java, we actually operate on a character iterator.
    // TODO: do we need to remember the iterator in a field?
    // TODO: apparently we don't clone a CharacterIterator in Java,
    // we only clone the text for a UCharacterIterator?? see the old code in the constructors
    UCharacterIterator src = new CharacterIteratorWrapper(source);
    src.setToStart();
    // TODO: do we need to remember the source string in a field?
    string_ = src.getText();
    CollationIterator newIter;
    boolean numeric = rbc_.settings.readOnly().isNumeric();
    if (rbc_.settings.readOnly().dontCheckFCD()) {
        newIter = new IterCollationIterator(rbc_.data, numeric, src);
    } else {
        newIter = new FCDIterCollationIterator(rbc_.data, numeric, src, 0);
    }
    iter_ = newIter;
    otherHalf_ = 0;
    dir_ = 0;
}
Also used : FCDIterCollationIterator(android.icu.impl.coll.FCDIterCollationIterator) UTF16CollationIterator(android.icu.impl.coll.UTF16CollationIterator) CollationIterator(android.icu.impl.coll.CollationIterator) FCDIterCollationIterator(android.icu.impl.coll.FCDIterCollationIterator) FCDUTF16CollationIterator(android.icu.impl.coll.FCDUTF16CollationIterator) IterCollationIterator(android.icu.impl.coll.IterCollationIterator) CharacterIteratorWrapper(android.icu.impl.CharacterIteratorWrapper) FCDIterCollationIterator(android.icu.impl.coll.FCDIterCollationIterator) IterCollationIterator(android.icu.impl.coll.IterCollationIterator)

Example 3 with CollationIterator

use of android.icu.impl.coll.CollationIterator in project j2objc by google.

the class RuleBasedCollator method internalGetCEs.

/**
 * Returns the CEs for the string.
 * @param str the string
 * @deprecated This API is ICU internal only.
 * @hide original deprecated declaration
 * @hide draft / provisional / internal are hidden on Android
 */
@Deprecated
public long[] internalGetCEs(CharSequence str) {
    CollationBuffer buffer = null;
    try {
        buffer = getCollationBuffer();
        boolean numeric = settings.readOnly().isNumeric();
        CollationIterator iter;
        if (settings.readOnly().dontCheckFCD()) {
            buffer.leftUTF16CollIter.setText(numeric, str, 0);
            iter = buffer.leftUTF16CollIter;
        } else {
            buffer.leftFCDUTF16Iter.setText(numeric, str, 0);
            iter = buffer.leftFCDUTF16Iter;
        }
        int length = iter.fetchCEs() - 1;
        assert length >= 0 && iter.getCE(length) == Collation.NO_CE;
        long[] ces = new long[length];
        System.arraycopy(iter.getCEs(), 0, ces, 0, length);
        return ces;
    } finally {
        releaseCollationBuffer(buffer);
    }
}
Also used : FCDUTF16CollationIterator(android.icu.impl.coll.FCDUTF16CollationIterator) UTF16CollationIterator(android.icu.impl.coll.UTF16CollationIterator) CollationIterator(android.icu.impl.coll.CollationIterator)

Example 4 with CollationIterator

use of android.icu.impl.coll.CollationIterator in project j2objc by google.

the class CollationElementIterator method setText.

/**
 * Set a new source string iterator for iteration, and reset the
 * offset to the beginning of the text.
 *
 * <p>The source iterator's integrity will be preserved since a new copy
 * will be created for use.
 * @param source the new source string iterator for iteration.
 */
public void setText(UCharacterIterator source) {
    // TODO: do we need to remember the source string in a field?
    string_ = source.getText();
    // Note: In C++, we just setText(source.getText()).
    // In Java, we actually operate on a character iterator.
    // (The old code apparently did so only for a CharacterIterator;
    // for a UCharacterIterator it also just used source.getText()).
    // TODO: do we need to remember the cloned iterator in a field?
    UCharacterIterator src;
    try {
        src = (UCharacterIterator) source.clone();
    } catch (CloneNotSupportedException e) {
        // Fall back to ICU 52 behavior of iterating over the text contents
        // of the UCharacterIterator.
        setText(source.getText());
        return;
    }
    src.setToStart();
    CollationIterator newIter;
    boolean numeric = rbc_.settings.readOnly().isNumeric();
    if (rbc_.settings.readOnly().dontCheckFCD()) {
        newIter = new IterCollationIterator(rbc_.data, numeric, src);
    } else {
        newIter = new FCDIterCollationIterator(rbc_.data, numeric, src, 0);
    }
    iter_ = newIter;
    otherHalf_ = 0;
    dir_ = 0;
}
Also used : FCDIterCollationIterator(android.icu.impl.coll.FCDIterCollationIterator) UTF16CollationIterator(android.icu.impl.coll.UTF16CollationIterator) CollationIterator(android.icu.impl.coll.CollationIterator) FCDIterCollationIterator(android.icu.impl.coll.FCDIterCollationIterator) FCDUTF16CollationIterator(android.icu.impl.coll.FCDUTF16CollationIterator) IterCollationIterator(android.icu.impl.coll.IterCollationIterator) FCDIterCollationIterator(android.icu.impl.coll.FCDIterCollationIterator) IterCollationIterator(android.icu.impl.coll.IterCollationIterator)

Aggregations

CollationIterator (android.icu.impl.coll.CollationIterator)4 FCDUTF16CollationIterator (android.icu.impl.coll.FCDUTF16CollationIterator)4 UTF16CollationIterator (android.icu.impl.coll.UTF16CollationIterator)4 FCDIterCollationIterator (android.icu.impl.coll.FCDIterCollationIterator)3 IterCollationIterator (android.icu.impl.coll.IterCollationIterator)3 CharacterIteratorWrapper (android.icu.impl.CharacterIteratorWrapper)1