コード例 #1
0
 /**
  * Unpacks the caseless match data. Called from {@link #getCaselessMatches(int)} to lazily
  * initialize.
  */
 private void initCaselessMatches() {
   caselessMatches = new IntCharSet[maximumCodePoint + 1];
   int[] members = new int[caselessMatchPartitionSize];
   for (int index = 0; index < caselessMatchPartitions.length(); ) {
     IntCharSet partition = new IntCharSet();
     for (int n = 0; n < caselessMatchPartitionSize; ++n) {
       int c = caselessMatchPartitions.codePointAt(index);
       index += Character.charCount(c);
       members[n] = c;
       if (c > 0) partition.add(c); // ignore trailing zero padding
     }
     if (partition.containsElements()) {
       for (int n = 0; n < caselessMatchPartitionSize; ++n) {
         if (members[n] > 0) caselessMatches[members[n]] = partition;
       }
     }
   }
 }
コード例 #2
0
 /**
  * Unpacks data for the selected Unicode version, populating {@link #propertyValueIntervals}.
  *
  * @param propertyValues The list of property values, in same order as the packed data
  *     corresponding to them, in the given intervals, for the selected Unicode version.
  * @param intervals The packed character intervals corresponding to and in the same order as the
  *     given propertyValues, for the selected Unicode version.
  * @param propertyValueAliases Key/value pairs mapping property value aliases to property values,
  *     for the selected Unicode version.
  * @param maximumCodePoint The maximum code point for the selected Unicode version.
  * @param caselessMatchPartitions The packed caseless match partition data for the selected
  *     Unicode version
  * @param caselessMatchPartitionSize The partition data record length (the maximum number of
  *     elements in a caseless match partition) for the selected Unicode version.
  */
 private void bind(
     String[] propertyValues,
     String[] intervals,
     String[] propertyValueAliases,
     int maximumCodePoint,
     String caselessMatchPartitions,
     int caselessMatchPartitionSize) {
   // IntCharSet caselessMatches[] is lazily initialized - don't unpack here
   this.caselessMatchPartitions = caselessMatchPartitions;
   this.caselessMatchPartitionSize = caselessMatchPartitionSize;
   this.maximumCodePoint = maximumCodePoint;
   for (int n = 0; n < propertyValues.length; ++n) {
     String propertyValue = propertyValues[n];
     String propertyIntervals = intervals[n];
     IntCharSet set = new IntCharSet();
     for (int index = 0; index < propertyIntervals.length(); ) {
       int start = propertyIntervals.codePointAt(index);
       index += Character.charCount(start);
       int end = propertyIntervals.codePointAt(index);
       index += Character.charCount(end);
       set.add(new Interval(start, end));
     }
     propertyValueIntervals.put(propertyValue, set);
     if (2 == propertyValue.length()) {
       String singleLetter = propertyValue.substring(0, 1);
       IntCharSet singleLetterPropValueSet = propertyValueIntervals.get(singleLetter);
       if (null == singleLetterPropValueSet) {
         singleLetterPropValueSet = new IntCharSet();
         propertyValueIntervals.put(singleLetter, singleLetterPropValueSet);
       }
       singleLetterPropValueSet.add(set);
     }
   }
   for (int n = 0; n < propertyValueAliases.length; n += 2) {
     String alias = propertyValueAliases[n];
     String propertyValue = propertyValueAliases[n + 1];
     IntCharSet targetSet = propertyValueIntervals.get(propertyValue);
     if (null != targetSet) {
       propertyValueIntervals.put(alias, targetSet);
     }
   }
   bindInvariantIntervals();
 }