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

The following examples show how to use com.ibm.icu.lang.UCharacter#MAX_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: IntTrieBuilder.java    From fitnotifications with Apache License 2.0 6 votes vote down vote up
/**
 * Get a 32 bit data from the table data
 * @param ch  code point for which data is to be retrieved.
 * @param inBlockZero  Output parameter, inBlockZero[0] returns true if the
 *                      char maps into block zero, otherwise false.
 * @return the 32 bit data value.
 */
public int getValue(int ch, boolean [] inBlockZero) 
{
    // valid, uncompacted trie and valid c?
    if (m_isCompacted_ || ch > UCharacter.MAX_VALUE || ch < 0) {
        if (inBlockZero != null) {
            inBlockZero[0] = true;
        }
        return 0;
    }

    int block = m_index_[ch >> SHIFT_];
    if (inBlockZero != null) {
        inBlockZero[0] = (block == 0);
    }
    return m_data_[Math.abs(block) + (ch & MASK_)];
}
 
Example 2
Source File: IntTrieBuilder.java    From fitnotifications with Apache License 2.0 6 votes vote down vote up
/**
 * Sets a 32 bit data in the table data
 * @param ch codepoint which data is to be set
 * @param value to set
 * @return true if the set is successful, otherwise 
 *              if the table has been compacted return false
 */
public boolean setValue(int ch, int value) 
{
    // valid, uncompacted trie and valid c? 
    if (m_isCompacted_ || ch > UCharacter.MAX_VALUE || ch < 0) {
        return false;
    }

    int block = getDataBlock(ch);
    if (block < 0) {
        return false;
    }

    m_data_[block + (ch & MASK_)] = value;
    return true;
}
 
Example 3
Source File: Trie.java    From fitnotifications with Apache License 2.0 6 votes vote down vote up
/**
* Internal trie getter from a code point.
* Could be faster(?) but longer with
*   if((c32)<=0xd7ff) { (result)=_TRIE_GET_RAW(trie, data, 0, c32); }
* Gets the offset to data which the codepoint points to
* @param ch codepoint
* @return offset to data
*/
protected final int getCodePointOffset(int ch)
{
    // if ((ch >> 16) == 0) slower
    if (ch < 0) {
        return -1;
    } else if (ch < UTF16.LEAD_SURROGATE_MIN_VALUE) {
        // fastpath for the part of the BMP below surrogates (D800) where getRawOffset() works
        return getRawOffset(0, (char)ch);
    } else if (ch < UTF16.SUPPLEMENTARY_MIN_VALUE) {
        // BMP codepoint
        return getBMPOffset((char)ch);
    } else if (ch <= UCharacter.MAX_VALUE) {
        // look at the construction of supplementary characters
        // trail forms the ends of it.
        return getSurrogateOffset(UTF16.getLeadSurrogate(ch),
                                  (char)(ch & SURROGATE_MASK_));
    } else {
        // return -1 if there is an error, in this case we return
        return -1;
    }
}
 
Example 4
Source File: UCharacterName.java    From fitnotifications with Apache License 2.0 6 votes vote down vote up
/**
* Retrieve the name of a Unicode code point.
* Depending on <code>choice</code>, the character name written into the
* buffer is the "modern" name or the name that was defined in Unicode
* version 1.0.
* The name contains only "invariant" characters
* like A-Z, 0-9, space, and '-'.
*
* @param ch the code point for which to get the name.
* @param choice Selector for which name to get.
* @return if code point is above 0x1fff, null is returned
*/
public String getName(int ch, int choice)
{
    if (ch < UCharacter.MIN_VALUE || ch > UCharacter.MAX_VALUE ||
        choice > UCharacterNameChoice.CHAR_NAME_CHOICE_COUNT) {
        return null;
    }

    String result = null;

    result = getAlgName(ch, choice);

    // getting normal character name
    if (result == null || result.length() == 0) {
        if (choice == UCharacterNameChoice.EXTENDED_CHAR_NAME) {
            result = getExtendedName(ch);
        } else {
            result = getGroupName(ch, choice);
        }
    }

    return result;
}
 
Example 5
Source File: Trie.java    From trekarta with GNU General Public License v3.0 6 votes vote down vote up
/**
* Internal trie getter from a code point.
* Could be faster(?) but longer with
*   if((c32)<=0xd7ff) { (result)=_TRIE_GET_RAW(trie, data, 0, c32); }
* Gets the offset to data which the codepoint points to
* @param ch codepoint
* @return offset to data
*/
protected final int getCodePointOffset(int ch)
{
    // if ((ch >> 16) == 0) slower
    if (ch < 0) {
        return -1;
    } else if (ch < UTF16.LEAD_SURROGATE_MIN_VALUE) {
        // fastpath for the part of the BMP below surrogates (D800) where getRawOffset() works
        return getRawOffset(0, (char)ch);
    } else if (ch < UTF16.SUPPLEMENTARY_MIN_VALUE) {
        // BMP codepoint
        return getBMPOffset((char)ch);
    } else if (ch <= UCharacter.MAX_VALUE) {
        // look at the construction of supplementary characters
        // trail forms the ends of it.
        return getSurrogateOffset(UTF16.getLeadSurrogate(ch),
                                  (char)(ch & SURROGATE_MASK_));
    } else {
        // return -1 if there is an error, in this case we return
        return -1;
    }
}
 
Example 6
Source File: UCharacterName.java    From trekarta with GNU General Public License v3.0 6 votes vote down vote up
/**
* Retrieve the name of a Unicode code point.
* Depending on <code>choice</code>, the character name written into the
* buffer is the "modern" name or the name that was defined in Unicode
* version 1.0.
* The name contains only "invariant" characters
* like A-Z, 0-9, space, and '-'.
*
* @param ch the code point for which to get the name.
* @param choice Selector for which name to get.
* @return if code point is above 0x1fff, null is returned
*/
public String getName(int ch, int choice)
{
    if (ch < UCharacter.MIN_VALUE || ch > UCharacter.MAX_VALUE ||
        choice > UCharacterNameChoice.CHAR_NAME_CHOICE_COUNT) {
        return null;
    }

    String result = null;

    result = getAlgName(ch, choice);

    // getting normal character name
    if (result == null || result.length() == 0) {
        if (choice == UCharacterNameChoice.EXTENDED_CHAR_NAME) {
            result = getExtendedName(ch);
        } else {
            result = getGroupName(ch, choice);
        }
    }

    return result;
}
 
Example 7
Source File: TrieBuilder.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
/**
 * Checks if the character belongs to a zero block in the trie
 * @param ch codepoint which data is to be retrieved
 * @return true if ch is in the zero block
 */
public boolean isInZeroBlock(int ch) 
{
    // valid, uncompacted trie and valid c?
    if (m_isCompacted_ || ch > UCharacter.MAX_VALUE 
        || ch < UCharacter.MIN_VALUE) {
        return true;
    }

    return m_index_[ch >> SHIFT_] == 0;
}
 
Example 8
Source File: IntTrieBuilder.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
/**
 * Gets a 32 bit data from the table data
 * @param ch codepoint which data is to be retrieved
 * @return the 32 bit data
 */
public int getValue(int ch) 
{
    // valid, uncompacted trie and valid c?
    if (m_isCompacted_ || ch > UCharacter.MAX_VALUE || ch < 0) {
        return 0;
    }

    int block = m_index_[ch >> SHIFT_];
    return m_data_[Math.abs(block) + (ch & MASK_)];
}
 
Example 9
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 10
Source File: UCharacterName.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
/**
* Sets the information for accessing the algorithmic names
* @param rangestart starting code point that lies within this name group
* @param rangeend end code point that lies within this name group
* @param type algorithm type. There's 2 kinds of algorithmic type. First
*        which uses code point as part of its name and the other uses
*        variant postfix strings
* @param variant algorithmic variant
* @return true if values are valid
*/
boolean setInfo(int rangestart, int rangeend, byte type, byte variant)
{
    if (rangestart >= UCharacter.MIN_VALUE && rangestart <= rangeend
        && rangeend <= UCharacter.MAX_VALUE &&
        (type == TYPE_0_ || type == TYPE_1_)) {
        m_rangestart_ = rangestart;
        m_rangeend_ = rangeend;
        m_type_ = type;
        m_variant_ = variant;
        return true;
    }
    return false;
}
 
Example 11
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 12
Source File: UCharacterName.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
/**
* Sets the information for accessing the algorithmic names
* @param rangestart starting code point that lies within this name group
* @param rangeend end code point that lies within this name group
* @param type algorithm type. There's 2 kinds of algorithmic type. First
*        which uses code point as part of its name and the other uses
*        variant postfix strings
* @param variant algorithmic variant
* @return true if values are valid
*/
boolean setInfo(int rangestart, int rangeend, byte type, byte variant)
{
    if (rangestart >= UCharacter.MIN_VALUE && rangestart <= rangeend
        && rangeend <= UCharacter.MAX_VALUE &&
        (type == TYPE_0_ || type == TYPE_1_)) {
        m_rangestart_ = rangestart;
        m_rangeend_ = rangeend;
        m_type_ = type;
        m_variant_ = variant;
        return true;
    }
    return false;
}