Java Code Examples for com.ibm.icu.text.UnicodeSet#freeze()

The following examples show how to use com.ibm.icu.text.UnicodeSet#freeze() . 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: ICUFoldingFilterFactory.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
/** Creates a new ICUFoldingFilterFactory */
public ICUFoldingFilterFactory(Map<String,String> args) {
  super(args);

  Normalizer2 normalizer = ICUFoldingFilter.NORMALIZER;
  String filter = get(args, "filter");
  if (filter != null) {
    UnicodeSet set = new UnicodeSet(filter);
    if (!set.isEmpty()) {
      set.freeze();
      normalizer = new FilteredNormalizer2(normalizer, set);
    }
  }
  if (!args.isEmpty()) {
    throw new IllegalArgumentException("Unknown parameters: " + args);
  }
  this.normalizer = normalizer;
}
 
Example 2
Source File: ICUNormalizer2CharFilterFactory.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
/** Creates a new ICUNormalizer2CharFilterFactory */
public ICUNormalizer2CharFilterFactory(Map<String,String> args) {
  super(args);
  String form = get(args, "form", "nfkc_cf");
  String mode = get(args, "mode", Arrays.asList("compose", "decompose"), "compose");
  Normalizer2 normalizer = Normalizer2.getInstance
      (null, form, "compose".equals(mode) ? Normalizer2.Mode.COMPOSE : Normalizer2.Mode.DECOMPOSE);
  
  String filter = get(args, "filter");
  if (filter != null) {
    UnicodeSet set = new UnicodeSet(filter);
    if (!set.isEmpty()) {
      set.freeze();
      normalizer = new FilteredNormalizer2(normalizer, set);
    }
  }
  if (!args.isEmpty()) {
    throw new IllegalArgumentException("Unknown parameters: " + args);
  }
  this.normalizer = normalizer;
}
 
Example 3
Source File: ICUNormalizer2FilterFactory.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
/** Creates a new ICUNormalizer2FilterFactory */
public ICUNormalizer2FilterFactory(Map<String,String> args) {
  super(args);
  String form = get(args, "form", "nfkc_cf");
  String mode = get(args, "mode", Arrays.asList("compose", "decompose"), "compose");
  Normalizer2 normalizer = Normalizer2.getInstance
      (null, form, "compose".equals(mode) ? Normalizer2.Mode.COMPOSE : Normalizer2.Mode.DECOMPOSE);
  
  String filter = get(args, "filter");
  if (filter != null) {
    UnicodeSet set = new UnicodeSet(filter);
    if (!set.isEmpty()) {
      set.freeze();
      normalizer = new FilteredNormalizer2(normalizer, set);
    }
  }
  if (!args.isEmpty()) {
    throw new IllegalArgumentException("Unknown parameters: " + args);
  }
  this.normalizer = normalizer;
}
 
Example 4
Source File: CharacterProperties.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
private static UnicodeSet makeSet(int property) {
    UnicodeSet set = new UnicodeSet();
    UnicodeSet inclusions = CharacterPropertiesImpl.getInclusionsForProperty(property);
    int numRanges = inclusions.getRangeCount();
    int startHasProperty = -1;

    for (int i = 0; i < numRanges; ++i) {
        int rangeEnd = inclusions.getRangeEnd(i);
        for (int c = inclusions.getRangeStart(i); c <= rangeEnd; ++c) {
            // TODO: Get a UCharacterProperty.BinaryProperty to avoid the property dispatch.
            if (UCharacter.hasBinaryProperty(c, property)) {
                if (startHasProperty < 0) {
                    // Transition from false to true.
                    startHasProperty = c;
                }
            } else if (startHasProperty >= 0) {
                // Transition from true to false.
                set.add(startHasProperty, c - 1);
                startHasProperty = -1;
            }
        }
    }
    if (startHasProperty >= 0) {
        set.add(startHasProperty, 0x10FFFF);
    }

    return set.freeze();
}
 
Example 5
Source File: UnicodeData.java    From es6draft with MIT License 4 votes vote down vote up
public IntPredicate predicate() {
    UnicodeSet set = set();
    set.freeze();
    return set::contains;
}
 
Example 6
Source File: UnicodeData.java    From es6draft with MIT License 4 votes vote down vote up
public final IntPredicate predicate(String value) {
    UnicodeSet set = set(getValue(value));
    set.freeze();
    return set::contains;
}