Java Code Examples for com.ibm.icu.lang.UProperty#BINARY_START

The following examples show how to use com.ibm.icu.lang.UProperty#BINARY_START . 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: UnicodeDataTest.java    From es6draft with MIT License 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Test
public void testAllICUBinaryProperties() {
    for (int p = UProperty.BINARY_START; p < UProperty.BINARY_LIMIT; ++p) {
        String shortName = UCharacter.getPropertyName(p, UProperty.NameChoice.SHORT);
        if (shortName != null) {
            // Does not throw.
            isBinaryProperty(shortName);
        }
        String longName = UCharacter.getPropertyName(p, UProperty.NameChoice.LONG);
        if (longName != null) {
            // Does not throw.
            isBinaryProperty(longName);
        }
    }
}
 
Example 2
Source File: UCharacterProperty.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
public boolean hasBinaryProperty(int c, int which) {
     if(which<UProperty.BINARY_START || UProperty.BINARY_LIMIT<=which) {
        // not a known binary property
        return false;
    } else {
        return binProps[which].contains(c);
    }
}
 
Example 3
Source File: UCharacterProperty.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
public int getIntPropertyValue(int c, int which) {
    if(which<UProperty.INT_START) {
        if(UProperty.BINARY_START<=which && which<UProperty.BINARY_LIMIT) {
            return binProps[which].contains(c) ? 1 : 0;
        }
    } else if(which<UProperty.INT_LIMIT) {
        return intProps[which-UProperty.INT_START].getValue(c);
    } else if (which == UProperty.GENERAL_CATEGORY_MASK) {
        return getMask(getType(c));
    }
    return 0; // undefined
}
 
Example 4
Source File: UCharacterProperty.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
public int getIntPropertyMaxValue(int which) {
    if(which<UProperty.INT_START) {
        if(UProperty.BINARY_START<=which && which<UProperty.BINARY_LIMIT) {
            return 1;  // maximum TRUE for all binary properties
        }
    } else if(which<UProperty.INT_LIMIT) {
        return intProps[which-UProperty.INT_START].getMaxValue(which);
    }
    return -1; // undefined
}
 
Example 5
Source File: UCharacterProperty.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
public boolean hasBinaryProperty(int c, int which) {
     if(which<UProperty.BINARY_START || UProperty.BINARY_LIMIT<=which) {
        // not a known binary property
        return false;
    } else {
        return binProps[which].contains(c);
    }
}
 
Example 6
Source File: UCharacterProperty.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
public int getIntPropertyValue(int c, int which) {
    if(which<UProperty.INT_START) {
        if(UProperty.BINARY_START<=which && which<UProperty.BINARY_LIMIT) {
            return binProps[which].contains(c) ? 1 : 0;
        }
    } else if(which<UProperty.INT_LIMIT) {
        return intProps[which-UProperty.INT_START].getValue(c);
    } else if (which == UProperty.GENERAL_CATEGORY_MASK) {
        return getMask(getType(c));
    }
    return 0; // undefined
}
 
Example 7
Source File: UCharacterProperty.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
public int getIntPropertyMaxValue(int which) {
    if(which<UProperty.INT_START) {
        if(UProperty.BINARY_START<=which && which<UProperty.BINARY_LIMIT) {
            return 1;  // maximum TRUE for all binary properties
        }
    } else if(which<UProperty.INT_LIMIT) {
        return intProps[which-UProperty.INT_START].getMaxValue(which);
    }
    return -1; // undefined
}
 
Example 8
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);
}
 
Example 9
Source File: UnicodeData.java    From es6draft with MIT License 5 votes vote down vote up
static BinaryProperty forId(int propertyId) {
    if (propertyId >= UProperty.BINARY_START && propertyId < BINARY_PROPERTY_LIMIT) {
        for (BinaryProperty binary : BinaryProperty.values()) {
            if (binary.propertyId == propertyId) {
                return binary;
            }
        }
    }
    return null;
}
 
Example 10
Source File: UCharacterProperty.java    From fitnotifications with Apache License 2.0 4 votes vote down vote up
public final int getSource(int which) {
    if(which<UProperty.BINARY_START) {
        return SRC_NONE; /* undefined */
    } else if(which<UProperty.BINARY_LIMIT) {
        return binProps[which].getSource();
    } else if(which<UProperty.INT_START) {
        return SRC_NONE; /* undefined */
    } else if(which<UProperty.INT_LIMIT) {
        return intProps[which-UProperty.INT_START].getSource();
    } else if(which<UProperty.STRING_START) {
        switch(which) {
        case UProperty.GENERAL_CATEGORY_MASK:
        case UProperty.NUMERIC_VALUE:
            return SRC_CHAR;

        default:
            return SRC_NONE;
        }
    } else if(which<UProperty.STRING_LIMIT) {
        switch(which) {
        case UProperty.AGE:
            return SRC_PROPSVEC;

        case UProperty.BIDI_MIRRORING_GLYPH:
            return SRC_BIDI;

        case UProperty.CASE_FOLDING:
        case UProperty.LOWERCASE_MAPPING:
        case UProperty.SIMPLE_CASE_FOLDING:
        case UProperty.SIMPLE_LOWERCASE_MAPPING:
        case UProperty.SIMPLE_TITLECASE_MAPPING:
        case UProperty.SIMPLE_UPPERCASE_MAPPING:
        case UProperty.TITLECASE_MAPPING:
        case UProperty.UPPERCASE_MAPPING:
            return SRC_CASE;

        case UProperty.ISO_COMMENT:
        case UProperty.NAME:
        case UProperty.UNICODE_1_NAME:
            return SRC_NAMES;

        default:
            return SRC_NONE;
        }
    } else {
        switch(which) {
        case UProperty.SCRIPT_EXTENSIONS:
            return SRC_PROPSVEC;
        default:
            return SRC_NONE; /* undefined */
        }
    }
}
 
Example 11
Source File: UCharacterProperty.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
final int getSource(int which) {
    if(which<UProperty.BINARY_START) {
        return SRC_NONE; /* undefined */
    } else if(which<UProperty.BINARY_LIMIT) {
        return binProps[which].getSource();
    } else if(which<UProperty.INT_START) {
        return SRC_NONE; /* undefined */
    } else if(which<UProperty.INT_LIMIT) {
        return intProps[which-UProperty.INT_START].getSource();
    } else if(which<UProperty.STRING_START) {
        switch(which) {
        case UProperty.GENERAL_CATEGORY_MASK:
        case UProperty.NUMERIC_VALUE:
            return SRC_CHAR;

        default:
            return SRC_NONE;
        }
    } else if(which<UProperty.STRING_LIMIT) {
        switch(which) {
        case UProperty.AGE:
            return SRC_PROPSVEC;

        case UProperty.BIDI_MIRRORING_GLYPH:
            return SRC_BIDI;

        case UProperty.CASE_FOLDING:
        case UProperty.LOWERCASE_MAPPING:
        case UProperty.SIMPLE_CASE_FOLDING:
        case UProperty.SIMPLE_LOWERCASE_MAPPING:
        case UProperty.SIMPLE_TITLECASE_MAPPING:
        case UProperty.SIMPLE_UPPERCASE_MAPPING:
        case UProperty.TITLECASE_MAPPING:
        case UProperty.UPPERCASE_MAPPING:
            return SRC_CASE;

        case UProperty.ISO_COMMENT:
        case UProperty.NAME:
        case UProperty.UNICODE_1_NAME:
            return SRC_NAMES;

        default:
            return SRC_NONE;
        }
    } else {
        switch(which) {
        case UProperty.SCRIPT_EXTENSIONS:
            return SRC_PROPSVEC;
        default:
            return SRC_NONE; /* undefined */
        }
    }
}