]> granicus.if.org Git - icu/commitdiff
ICU-10911 added and called UPropertyAliases.getPropertyValueEnumNoThrow, as per Marku...
authorMark Davis <mark@macchiato.com>
Fri, 5 Sep 2014 14:03:52 +0000 (14:03 +0000)
committerMark Davis <mark@macchiato.com>
Fri, 5 Sep 2014 14:03:52 +0000 (14:03 +0000)
X-SVN-Rev: 36356

icu4j/main/classes/core/src/com/ibm/icu/impl/UPropertyAliases.java
icu4j/main/classes/core/src/com/ibm/icu/lang/UCharacter.java

index 600eb205d84225a7a381ddc6bc91b7b71641f7ca..8d010908d6a385f2bf81438136669d9a623d554b 100644 (file)
@@ -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
index 37eb9867eeda726647dfa2b44684f0cb9102bded..0d9b520b2f7bba7670c39b60b0086b65193850ea 100644 (file)
@@ -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);
     }