Java Code Examples for com.ibm.icu.lang.UCharacter#getPropertyEnum()

The following examples show how to use com.ibm.icu.lang.UCharacter#getPropertyEnum() . 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: UnicodeData.java    From es6draft with MIT License 5 votes vote down vote up
static Property from(String name) {
    // Don't allow loose matching.
    int property;
    CHECK: try {
        property = UCharacter.getPropertyEnum(name);
        // Filter out synthetic names.
        if (property == UProperty.GENERAL_CATEGORY_MASK) {
            return null;
        }
        String shortName = UCharacter.getPropertyName(property, UProperty.NameChoice.SHORT);
        if (shortName != null && shortName.equals(name)) {
            break CHECK;
        }
        for (int i = 0;; ++i) {
            String longName = UCharacter.getPropertyName(property, UProperty.NameChoice.LONG + i);
            if (longName != null && longName.equals(name)) {
                break CHECK;
            }
        }
    } catch (IllegalArgumentException e) {
        return null;
    }
    if (property >= UProperty.BINARY_START && property < BINARY_PROPERTY_LIMIT) {
        return BinaryProperty.forId(property);
    }
    return EnumProperty.forId(property);
}