]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - jars/icu4j-52_1/main/classes/core/src/com/ibm/icu/impl/UCharacterProperty.java
Upgrade ICU4J.
[Dictionary.git] / jars / icu4j-52_1 / main / classes / core / src / com / ibm / icu / impl / UCharacterProperty.java
similarity index 95%
rename from jars/icu4j-4_8_1_1/main/classes/core/src/com/ibm/icu/impl/UCharacterProperty.java
rename to jars/icu4j-52_1/main/classes/core/src/com/ibm/icu/impl/UCharacterProperty.java
index 9c8e9aaa713c8270bd6ff24d53f41182c21cb099..8f1340aef8716ccdbe83259731e8a5ff8e24c575 100644 (file)
@@ -1,7 +1,7 @@
 /**
 *******************************************************************************
-* Copyright (C) 1996-2011, International Business Machines Corporation and    *
-* others. All Rights Reserved.                                                *
+* Copyright (C) 1996-2013, International Business Machines Corporation and
+* others. All Rights Reserved.
 *******************************************************************************
 */
 
@@ -116,21 +116,19 @@ public final class UCharacterProperty
 
     /**
      * Gets the unicode additional properties.
-     * C version getUnicodeProperties.
+     * Java version of C u_getUnicodeProperties().
      * @param codepoint codepoint whose additional properties is to be
      *                  retrieved
      * @param column The column index.
      * @return unicode properties
      */
-       public int getAdditional(int codepoint, int column) {
-        if (column == -1) {
-            return getProperty(codepoint);
+    public int getAdditional(int codepoint, int column) {
+        assert column >= 0;
+        if (column >= m_additionalColumnsCount_) {
+            return 0;
         }
-           if (column < 0 || column >= m_additionalColumnsCount_) {
-           return 0;
-       }
-       return m_additionalVectors_[m_additionalTrie_.get(codepoint) + column];
-       }
+        return m_additionalVectors_[m_additionalTrie_.get(codepoint) + column];
+    }
 
     static final int MY_MASK = UCharacterProperty.TYPE_MASK
         & ((1<<UCharacterCategory.UPPERCASE_LETTER) |
@@ -492,8 +490,7 @@ public final class UCharacterProperty
         new IntProperty(0, BLOCK_MASK_, BLOCK_SHIFT_),
         new CombiningClassIntProperty(SRC_NFC) {  // CANONICAL_COMBINING_CLASS
             int getValue(int c) {
-                Normalizer2Impl impl = Norm2AllModes.getNFCInstance().impl;
-                return impl.getCC(impl.getNorm16(c));
+                return Norm2AllModes.getNFCInstance().decomp.getCombiningClass(c);
             }
         },
         new IntProperty(2, DECOMPOSITION_TYPE_MASK_, 0),
@@ -552,17 +549,22 @@ public final class UCharacterProperty
         new NormQuickCheckIntProperty(SRC_NFKC, UProperty.NFKC_QUICK_CHECK, 2),
         new CombiningClassIntProperty(SRC_NFC) {  // LEAD_CANONICAL_COMBINING_CLASS
             int getValue(int c) {
-                return Norm2AllModes.getNFCInstance().impl.getFCDTrie().get(c)>>8;
+                return Norm2AllModes.getNFCInstance().impl.getFCD16(c)>>8;
             }
         },
         new CombiningClassIntProperty(SRC_NFC) {  // TRAIL_CANONICAL_COMBINING_CLASS
             int getValue(int c) {
-                return Norm2AllModes.getNFCInstance().impl.getFCDTrie().get(c)&0xff;
+                return Norm2AllModes.getNFCInstance().impl.getFCD16(c)&0xff;
             }
         },
         new IntProperty(2, GCB_MASK, GCB_SHIFT),  // GRAPHEME_CLUSTER_BREAK
         new IntProperty(2, SB_MASK, SB_SHIFT),  // SENTENCE_BREAK
         new IntProperty(2, WB_MASK, WB_SHIFT),  // WORD_BREAK
+        new BiDiIntProperty() {  // BIDI_PAIRED_BRACKET_TYPE
+            int getValue(int c) {
+                return UBiDiProps.INSTANCE.getPairedBracketType(c);
+            }
+        },
     };
 
     public int getIntPropertyValue(int c, int which) {
@@ -811,7 +813,7 @@ public final class UCharacterProperty
         } else if(ntv<NTV_LARGE_START_) {
             /* fraction */
             return -2;
-        } else if(ntv<NTV_RESERVED_START_) {
+        } else if(ntv<NTV_BASE60_START_) {
             /* large, single-significant-digit integer */
             int mant=(ntv>>5)-14;
             int exp=(ntv&0x1f)+2;
@@ -824,6 +826,30 @@ public final class UCharacterProperty
             } else {
                 return -2;
             }
+        } else if(ntv<NTV_RESERVED_START_) {
+            /* sexagesimal (base 60) integer */
+            int numValue=(ntv>>2)-0xbf;
+            int exp=(ntv&3)+1;
+
+            switch(exp) {
+            case 4:
+                numValue*=60*60*60*60;
+                break;
+            case 3:
+                numValue*=60*60*60;
+                break;
+            case 2:
+                numValue*=60*60;
+                break;
+            case 1:
+                numValue*=60;
+                break;
+            case 0:
+            default:
+                break;
+            }
+
+            return numValue;
         } else {
             /* reserved */
             return -2;
@@ -850,7 +876,7 @@ public final class UCharacterProperty
             int numerator=(ntv>>4)-12;
             int denominator=(ntv&0xf)+1;
             return (double)numerator/denominator;
-        } else if(ntv<NTV_RESERVED_START_) {
+        } else if(ntv<NTV_BASE60_START_) {
             /* large, single-significant-digit integer */
             double numValue;
             int mant=(ntv>>5)-14;
@@ -877,6 +903,30 @@ public final class UCharacterProperty
                 break;
             }
 
+            return numValue;
+        } else if(ntv<NTV_RESERVED_START_) {
+            /* sexagesimal (base 60) integer */
+            int numValue=(ntv>>2)-0xbf;
+            int exp=(ntv&3)+1;
+
+            switch(exp) {
+            case 4:
+                numValue*=60*60*60*60;
+                break;
+            case 3:
+                numValue*=60*60*60;
+                break;
+            case 2:
+                numValue*=60*60;
+                break;
+            case 1:
+                numValue*=60;
+                break;
+            case 0:
+            default:
+                break;
+            }
+
             return numValue;
         } else {
             /* reserved */
@@ -951,13 +1001,29 @@ public final class UCharacterProperty
         return props >> NUMERIC_TYPE_VALUE_SHIFT_;
     }
     /* constants for the storage form of numeric types and values */
+    /** No numeric value. */
     private static final int NTV_NONE_ = 0;
+    /** Decimal digits: nv=0..9 */
     private static final int NTV_DECIMAL_START_ = 1;
+    /** Other digits: nv=0..9 */
     private static final int NTV_DIGIT_START_ = 11;
+    /** Small integers: nv=0..154 */
     private static final int NTV_NUMERIC_START_ = 21;
+    /** Fractions: ((ntv>>4)-12) / ((ntv&0xf)+1) = -1..17 / 1..16 */
     private static final int NTV_FRACTION_START_ = 0xb0;
+    /**
+     * Large integers:
+     * ((ntv>>5)-14) * 10^((ntv&0x1f)+2) = (1..9)*(10^2..10^33)
+     * (only one significant decimal digit)
+     */
     private static final int NTV_LARGE_START_ = 0x1e0;
-    private static final int NTV_RESERVED_START_ = 0x300;
+    /**
+     * Sexagesimal numbers:
+     * ((ntv>>2)-0xbf) * 60^((ntv&3)+1) = (1..9)*(60^1..60^4)
+     */
+    private static final int NTV_BASE60_START_=0x300;
+    /** No numeric value (yet). */
+    private static final int NTV_RESERVED_START_ = NTV_BASE60_START_ + 36;  // 0x300+9*4=0x324
 
     private static final int ntvGetType(int ntv) {
         return