Java Code Examples for com.ibm.icu.lang.UCharacter#SUPPLEMENTARY_MIN_VALUE

The following examples show how to use com.ibm.icu.lang.UCharacter#SUPPLEMENTARY_MIN_VALUE . 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: TrieIterator.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
/**
* <p>Returns true if we are not at the end of the iteration, false
* otherwise.</p>
* <p>The next set of codepoints with the same value type will be
* calculated during this call and returned in the arguement element.</p>
* @param element return result
* @return true if we are not at the end of the iteration, false otherwise.
* @exception NoSuchElementException - if no more elements exist.
* @see com.ibm.icu.util.RangeValueIterator.Element
*/
@Override
public final boolean next(Element element)
{
    if (m_nextCodepoint_ > UCharacter.MAX_VALUE) {
        return false;
    }
    if (m_nextCodepoint_ < UCharacter.SUPPLEMENTARY_MIN_VALUE &&
        calculateNextBMPElement(element)) {
        return true;
    }
    calculateNextSupplementaryElement(element);
    return true;
}
 
Example 2
Source File: TrieIterator.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
/**
* <p>Returns true if we are not at the end of the iteration, false
* otherwise.</p>
* <p>The next set of codepoints with the same value type will be
* calculated during this call and returned in the arguement element.</p>
* @param element return result
* @return true if we are not at the end of the iteration, false otherwise.
* @exception NoSuchElementException - if no more elements exist.
* @see com.ibm.icu.util.RangeValueIterator.Element
*/
@Override
public final boolean next(Element element)
{
    if (m_nextCodepoint_ > UCharacter.MAX_VALUE) {
        return false;
    }
    if (m_nextCodepoint_ < UCharacter.SUPPLEMENTARY_MIN_VALUE &&
        calculateNextBMPElement(element)) {
        return true;
    }
    calculateNextSupplementaryElement(element);
    return true;
}
 
Example 3
Source File: TrieIterator.java    From fitnotifications with Apache License 2.0 4 votes vote down vote up
/**
* Finding the next element.
* This method is called just before returning the result of
* next().
* We always store the next element before it is requested.
* In the case that we have to continue calculations into the
* supplementary planes, a false will be returned.
* @param element return result object
* @return true if the next range is found, false if we have to proceed to
*         the supplementary range.
*/
private final boolean calculateNextBMPElement(Element element)
{
    int currentValue    = m_nextValue_;
    m_currentCodepoint_ = m_nextCodepoint_;
    m_nextCodepoint_ ++;
    m_nextBlockIndex_ ++;
    if (!checkBlockDetail(currentValue)) {
        setResult(element, m_currentCodepoint_, m_nextCodepoint_,
                  currentValue);
        return true;
    }
    // synwee check that next block index == 0 here
    // enumerate BMP - the main loop enumerates data blocks
    while (m_nextCodepoint_ < UCharacter.SUPPLEMENTARY_MIN_VALUE) {
        // because of the way the character is split to form the index
        // the lead surrogate and trail surrogate can not be in the
        // mid of a block
        if (m_nextCodepoint_ == LEAD_SURROGATE_MIN_VALUE_) {
            // skip lead surrogate code units,
            // go to lead surrogate codepoints
            m_nextIndex_ = BMP_INDEX_LENGTH_;
        }
        else if (m_nextCodepoint_ == TRAIL_SURROGATE_MIN_VALUE_) {
            // go back to regular BMP code points
            m_nextIndex_ = m_nextCodepoint_ >> Trie.INDEX_STAGE_1_SHIFT_;
        } else {
            m_nextIndex_ ++;
        }

        m_nextBlockIndex_ = 0;
        if (!checkBlock(currentValue)) {
            setResult(element, m_currentCodepoint_, m_nextCodepoint_,
                      currentValue);
            return true;
        }
    }
    m_nextCodepoint_ --;   // step one back since this value has not been
    m_nextBlockIndex_ --;  // retrieved yet.
    return false;
}
 
Example 4
Source File: TrieIterator.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
/**
* Finding the next element.
* This method is called just before returning the result of
* next().
* We always store the next element before it is requested.
* In the case that we have to continue calculations into the
* supplementary planes, a false will be returned.
* @param element return result object
* @return true if the next range is found, false if we have to proceed to
*         the supplementary range.
*/
private final boolean calculateNextBMPElement(Element element)
{
    int currentValue    = m_nextValue_;
    m_currentCodepoint_ = m_nextCodepoint_;
    m_nextCodepoint_ ++;
    m_nextBlockIndex_ ++;
    if (!checkBlockDetail(currentValue)) {
        setResult(element, m_currentCodepoint_, m_nextCodepoint_,
                  currentValue);
        return true;
    }
    // synwee check that next block index == 0 here
    // enumerate BMP - the main loop enumerates data blocks
    while (m_nextCodepoint_ < UCharacter.SUPPLEMENTARY_MIN_VALUE) {
        // because of the way the character is split to form the index
        // the lead surrogate and trail surrogate can not be in the
        // mid of a block
        if (m_nextCodepoint_ == LEAD_SURROGATE_MIN_VALUE_) {
            // skip lead surrogate code units,
            // go to lead surrogate codepoints
            m_nextIndex_ = BMP_INDEX_LENGTH_;
        }
        else if (m_nextCodepoint_ == TRAIL_SURROGATE_MIN_VALUE_) {
            // go back to regular BMP code points
            m_nextIndex_ = m_nextCodepoint_ >> Trie.INDEX_STAGE_1_SHIFT_;
        } else {
            m_nextIndex_ ++;
        }

        m_nextBlockIndex_ = 0;
        if (!checkBlock(currentValue)) {
            setResult(element, m_currentCodepoint_, m_nextCodepoint_,
                      currentValue);
            return true;
        }
    }
    m_nextCodepoint_ --;   // step one back since this value has not been
    m_nextBlockIndex_ --;  // retrieved yet.
    return false;
}