Java Code Examples for java.text.Collator#clone()

The following examples show how to use java.text.Collator#clone() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CollatorTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * @tests java.text.Collator#clone()
 */
public void test_clone() {
	Collator c = Collator.getInstance(Locale.GERMAN);
	Collator c2 = (Collator) c.clone();
	assertTrue("Clones answered false to equals", c.equals(c2));
	assertTrue("Clones were equivalent", c != c2);
}
 
Example 2
Source File: CollatorTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * @tests java.text.Collator#equals(java.lang.Object)
 */
public void test_equalsLjava_lang_Object() {
	Collator c = Collator.getInstance(Locale.ENGLISH);
	Collator c2 = (Collator) c.clone();
	assertTrue("Cloned collators not equal", c.equals(c2));
	c2.setStrength(Collator.SECONDARY);
	assertTrue("Collators with different strengths equal", !c.equals(c2));
}
 
Example 3
Source File: CollatedTermAttributeImpl.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
/**
 * Create a new CollatedTermAttributeImpl
 * @param collator Collation key generator
 */
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();
}
 
Example 4
Source File: CollationDocValuesField.java    From lucene-solr with Apache License 2.0 3 votes vote down vote up
/**
 * Create a new ICUCollationDocValuesField.
 * <p>
 * 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 {@link #setStringValue(String)}.
 * @param name field name
 * @param collator Collator for generating collation keys.
 */
// TODO: can we make this trap-free? maybe just synchronize on the collator
// instead? 
public CollationDocValuesField(String name, Collator collator) {
  super(name, SortedDocValuesField.TYPE);
  this.name = name;
  this.collator = (Collator) collator.clone();
  fieldsData = bytes; // so wrong setters cannot be called
}