Ejemplo n.º 1
0
        public void ForCodePoint(CollationData d, int c)
        {
            int ce32 = d.GetCE32(c);

            if (ce32 == Collation.FALLBACK_CE32)
            {
                d    = d.Base;
                ce32 = d.GetCE32(c);
            }
            data = d;
            HandleCE32(c, c, ce32);
        }
Ejemplo n.º 2
0
 // Java porting note: ICU4C returns U_SUCCESS(error) and it's not applicable to ICU4J.
 //  Also, ICU4C requires handleCE32() to be public because it is used by the callback
 //  function (enumTailoredRange()). This is not necessary for Java implementation.
 private void HandleCE32(int start, int end, int ce32)
 {
     Debug.Assert(ce32 != Collation.FALLBACK_CE32);
     if (Collation.IsSpecialCE32(ce32))
     {
         ce32 = data.GetIndirectCE32(ce32);
         if (ce32 == Collation.FALLBACK_CE32)
         {
             return;
         }
     }
     do
     {
         int baseCE32 = baseData.GetFinalCE32(baseData.GetCE32(start));
         // Do not just continue if ce32 == baseCE32 because
         // contractions and expansions in different data objects
         // normally differ even if they have the same data offsets.
         if (Collation.IsSelfContainedCE32(ce32) && Collation.IsSelfContainedCE32(baseCE32))
         {
             // fastpath
             if (ce32 != baseCE32)
             {
                 tailored.Add(start);
             }
         }
         else
         {
             Compare(start, ce32, baseCE32);
         }
     } while (++start <= end);
 }
Ejemplo n.º 3
0
        private void GetCEs(CollationData data)
        {
            int i = 0;

            for (char c = (char)0; ; ++i, ++c)
            {
                if (c == CollationFastLatin.LatinLimit)
                {
                    c = (char)CollationFastLatin.PUNCT_START;
                }
                else if (c == CollationFastLatin.PUNCT_LIMIT)
                {
                    break;
                }
                CollationData d;
                int           ce32 = data.GetCE32(c);
                if (ce32 == Collation.FALLBACK_CE32)
                {
                    d    = data.Base;
                    ce32 = d.GetCE32(c);
                }
                else
                {
                    d = data;
                }
                if (GetCEsFromCE32(d, c, ce32))
                {
                    charCEs[i][0] = ce0;
                    charCEs[i][1] = ce1;
                    AddUniqueCE(ce0);
                    AddUniqueCE(ce1);
                }
                else
                {
                    // bail out for c
                    charCEs[i][0] = ce0 = Collation.NoCE;
                    charCEs[i][1] = ce1 = 0;
                }
                if (c == 0 && !IsContractionCharCE(ce0))
                {
                    // Always map U+0000 to a contraction.
                    // Write a contraction list with only a default value if there is no real contraction.
                    Debug.Assert(contractionCEs.Count == 0);
                    AddContractionEntry(CollationFastLatin.CONTR_CHAR_MASK, ce0, ce1);
                    charCEs[0][0] = (Collation.NO_CE_PRIMARY << 32) | CONTRACTION_FLAG;
                    charCEs[0][1] = 0;
                }
            }
            // Terminate the last contraction list.
            contractionCEs.Add(CollationFastLatin.CONTR_CHAR_MASK);
        }