/// <summary>
 /// Create a new <see cref="ICUCollationDocValuesField"/>.
 /// <para/>
 /// NOTE: you should not create a new one for each document, instead
 /// just make one and reuse it during your indexing process, setting
 /// the value via <see cref="SetStringValue(string)"/>.
 /// </summary>
 /// <param name="name">Field name.</param>
 /// <param name="collator">Collator for generating collation keys.</param>
 // TODO: can we make this trap-free? maybe just synchronize on the collator
 // instead?
 public ICUCollationDocValuesField(string name, Collator collator)
     : base(name, SortedDocValuesField.TYPE)
 {
     this.name     = name;
     this.collator = (Collator)collator.Clone();
     FieldsData    = bytes; // so wrong setters cannot be called
 }
Exemple #2
0
 /// <summary>
 /// Creates a new <see cref="ICUCollationKeyFilter"/>.
 /// </summary>
 /// <param name="input">Source token stream.</param>
 /// <param name="collator"><see cref="CollationKey"/> generator.</param>
 public ICUCollationKeyFilter(TokenStream input, Collator collator)
     : base(input)
 {
     // clone the collator: see http://userguide.icu-project.org/collation/architecture
     this.collator = (Collator)collator.Clone();
     this.termAtt  = AddAttribute <ICharTermAttribute>();
 }
        internal override Collator GetInstance(UCultureInfo locale)
        {
            // use service cache, it's faster than instantiation
            //          if (service.isDefault()) {
            //              return new RuleBasedCollator(locale);
            //          }
            //try
            //{
            Collator coll = (Collator)service.Get(locale, out _);

            if (coll == null)
            {
                ////CLOVER:OFF
                //Can't really change coll after it's been initialized
                throw new MissingManifestResourceException("Could not locate Collator data");
                ////CLOVER:ON
            }
            return((Collator)coll.Clone());
            //}
            //catch (CloneNotSupportedException e)
            //{
            //    ////CLOVER:OFF
            //    throw new ICUCloneNotSupportedException(e);
            //    ////CLOVER:ON
            //}
        }
Exemple #4
0
        public void TestThreads()
        {
            Collator theCollator = Collator.GetInstance(new CultureInfo("pl"));
            Random   r           = new Random();
            Control  control     = new Control();

            Thread[] threads = new Thread[10];
            for (int i = 0; i < threads.Length; ++i)
            {
                Collator coll;
                //try
                //{
                coll = (Collator)theCollator.Clone();
                //}
                //catch (CloneNotSupportedException e)
                //{
                //    // should not happen, if it does we'll get an exception right away
                //    Errln("could not clone");
                //    return;
                //}
                Test test = new Test("Collation test thread" + i, (string[])threadTestData.Clone(), coll,
                                     r, control);
                threads[i] = new Thread(() => test.Run());
            }

            RunThreads(threads, control);
        }
Exemple #5
0
        public void Test_clone()
        {
            Collator c  = ILOG.J2CsMapping.Text.Collator.GetInstance(Locale.GERMAN);
            Collator c2 = (Collator)c.Clone();

            NUnit.Framework.Assert.IsTrue(c.Equals(c2), "Clones answered false to equals");
            NUnit.Framework.Assert.IsTrue(c != c2, "Clones were equivalent");
        }
Exemple #6
0
        public void Test_equalsLjava_lang_Object()
        {
            Collator c  = ILOG.J2CsMapping.Text.Collator.GetInstance(Locale.ENGLISH);
            Collator c2 = (Collator)c.Clone();

            NUnit.Framework.Assert.IsTrue(c.Equals(c2), "Cloned collators not equal");
            c2.SetStrength(ILOG.J2CsMapping.Text.Collator.SECONDARY);
            NUnit.Framework.Assert.IsTrue(!c.Equals(c2), "Collators with different strengths equal");
        }
        /// <summary>
        /// Create a new <see cref="ICUCollationDocValuesField"/>.
        /// <para/>
        /// NOTE: you should not create a new one for each document, instead
        /// just make one and reuse it during your indexing process, setting
        /// the value via <see cref="SetStringValue(string)"/>.
        /// </summary>
        /// <param name="name">Field name.</param>
        /// <param name="collator">Collator for generating collation keys.</param>
        /// <exception cref="ArgumentNullException">if <paramref name="name"/> or <paramref name="collator"/> is <c>null</c>.</exception>
        // TODO: can we make this trap-free? maybe just synchronize on the collator
        // instead?
        public ICUCollationDocValuesField(string name, Collator collator)
            : base(name, SortedDocValuesField.TYPE)
        {
            if (collator is null)
            {
                throw new ArgumentNullException(nameof(collator));
            }

            this.name     = name;
            this.collator = (Collator)collator.Clone();
            FieldsData    = bytes; // so wrong setters cannot be called
        }
 /// <summary>
 /// Create a new <see cref="CollatedTermAttributeImpl"/> </summary>
 /// <param name="collator"> Collation key generator </param>
 public CollatedTermAttributeImpl(Collator collator)
 {
     // clone in case JRE doesn't properly sync,
     // or to reduce contention in case they do
     this.collator = (Collator)collator.Clone();
 }
 /// <summary>
 /// Create a new ICUCollatedTermAttribute
 /// </summary>
 /// <param name="collator"><see cref="SortKey"/> generator.</param>
 public ICUCollatedTermAttribute(Collator collator)
 {
     // clone the collator: see http://userguide.icu-project.org/collation/architecture
     this.collator = (Collator)collator.Clone();
 }