From: Mark Davis Date: Fri, 5 Sep 2014 14:03:52 +0000 (+0000) Subject: ICU-10911 added and called UPropertyAliases.getPropertyValueEnumNoThrow, as per Marku... X-Git-Tag: milestone-59-0-1~1621 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0fe58423828184a63e83395df5a6f30933ad08b3;p=icu ICU-10911 added and called UPropertyAliases.getPropertyValueEnumNoThrow, as per Markus's suggestion X-SVN-Rev: 36356 --- diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/UPropertyAliases.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/UPropertyAliases.java index 600eb205d84..8d010908d6a 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/UPropertyAliases.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/UPropertyAliases.java @@ -305,6 +305,33 @@ public final class UPropertyAliases { // where the first word is the BytesTrie offset. return getPropertyOrValueEnum(valueMaps[valueMapIndex], alias); } + + /** + * Returns a value enum given a property enum and one of its value names. Does not throw. + * @param property + * @param alias + * @return value enum, or UProperty.UNDEFINED if not defined for that property + * @internal + * @deprecated This API is ICU internal only. + */ + @Deprecated + public int getPropertyValueEnumNoThrow(int property, CharSequence alias) { + try { + int valueMapIndex=findProperty(property); + if(valueMapIndex==0) { + return UProperty.UNDEFINED; + } + valueMapIndex=valueMaps[valueMapIndex+1]; + if(valueMapIndex==0) { + return UProperty.UNDEFINED; + } + // valueMapIndex is the start of the property's valueMap, + // where the first word is the BytesTrie offset. + return getPropertyOrValueEnum(valueMaps[valueMapIndex], alias); + } catch (Exception e) { + return UProperty.UNDEFINED; + } + } /** * Compare two property names, returning <0, 0, or >0. The diff --git a/icu4j/main/classes/core/src/com/ibm/icu/lang/UCharacter.java b/icu4j/main/classes/core/src/com/ibm/icu/lang/UCharacter.java index 37eb9867eed..0d9b520b2f7 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/lang/UCharacter.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/lang/UCharacter.java @@ -4640,13 +4640,7 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection */ @Deprecated public static int getPropertyValueEnumNoThrow(int property, CharSequence valueAlias) { - int propEnum; - try { - propEnum = UPropertyAliases.INSTANCE.getPropertyValueEnum(property, valueAlias); - } catch (Exception e) { - propEnum = UProperty.UNDEFINED; - } - return propEnum; + return UPropertyAliases.INSTANCE.getPropertyValueEnumNoThrow(property, valueAlias); }