Java Code Examples for com.ibm.icu.text.Collator#clone()

The following examples show how to use com.ibm.icu.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: GlobalizationPreferences.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
/**
 * Explicitly set the collator for this object.
 * @param collator The collator object to be passed.
 * @return this, for chaining
 * @draft ICU 3.6
 * @provisional This API might change or be removed in a future release.
 */
public GlobalizationPreferences setCollator(Collator collator) {
    if (isFrozen()) {
        throw new UnsupportedOperationException("Attempt to modify immutable object");
    }
    try {
        this.collator = (Collator) collator.clone(); // clone for safety
    } catch (CloneNotSupportedException e) {
            throw new ICUCloneNotSupportedException("Error in cloning collator", e);
    }
    return this;
}
 
Example 2
Source File: ICUCollatedTermAttributeImpl.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new ICUCollatedTermAttributeImpl
 * @param collator Collation key generator
 */
public ICUCollatedTermAttributeImpl(Collator collator) {
  // clone the collator: see http://userguide.icu-project.org/collation/architecture
  try {
    this.collator = (Collator) collator.clone();
  } catch (CloneNotSupportedException e) {
    throw new RuntimeException(e);
  }
}
 
Example 3
Source File: ICUCollationDocValuesField.java    From lucene-solr with Apache License 2.0 5 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 ICUCollationDocValuesField(String name, Collator collator) {
  super(name, SortedDocValuesField.TYPE);
  this.name = name;
  try {
    this.collator = (Collator) collator.clone();
  } catch (CloneNotSupportedException e) {
    throw new RuntimeException(e);
  }
  fieldsData = bytes; // so wrong setters cannot be called
}
 
Example 4
Source File: IcuCollationAttributeFactory.java    From elasticsearch-plugin-bundle with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Create a new ICU c ollated term attribute implementation.
 * @param collator Collation key generator
 */
IcuCollatedTermAttributeImpl(Collator collator) {
    // clone the collator: see http://userguide.icu-project.org/collation/architecture
    try {
        this.collator = (Collator) collator.clone();
    } catch (CloneNotSupportedException e) {
        throw new UnsupportedOperationException(e);
    }
}