com.ibm.icu.text.Collator.getRawCollationKey()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中com.ibm.icu.text.Collator.getRawCollationKey()方法的一些代码示例,展示了Collator.getRawCollationKey()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Collator.getRawCollationKey()方法的具体详情如下:
包路径:com.ibm.icu.text.Collator
类名称:Collator
方法名:getRawCollationKey

Collator.getRawCollationKey介绍

[英]Returns the simpler form of a CollationKey for the String source following the rules of this Collator and stores the result into the user provided argument key. If key has a internal byte array of length that's too small for the result, the internal byte array will be grown to the exact required size.

Note that collation keys are often less efficient than simply doing comparison. For more details, see the ICU User Guide.
[中]按照此排序器的规则返回字符串源的排序规则键的更简单形式,并将结果存储到用户提供的参数键中。如果键的内部字节数组的长度对于结果来说太小,则内部字节数组将增长到所需的精确大小。
请注意,排序键的效率通常低于简单地进行比较。有关更多详细信息,请参阅ICU用户指南。

代码示例

代码示例来源:origin: org.apache.lucene/lucene-analyzers-icu

@Override
 public void setStringValue(String value) {
  collator.getRawCollationKey(value, key);
  bytes.bytes = key.bytes;
  bytes.offset = 0;
  bytes.length = key.size;
 }
}

代码示例来源:origin: org.apache.lucene/lucene-analyzers-icu

@Override
 public BytesRef getBytesRef() {
  collator.getRawCollationKey(toString(), key);
  final BytesRef ref = this.builder.get();
  ref.bytes = key.bytes;
  ref.offset = 0;
  ref.length = key.size;
  return ref;
 }
}

代码示例来源:origin: org.apache.lucene/lucene-collation

@Override
 public boolean incrementToken() throws IOException {
  if (input.incrementToken()) {
   char[] termBuffer = termAtt.termBuffer();
   String termText = new String(termBuffer, 0, termAtt.termLength());
   collator.getRawCollationKey(termText, reusableKey);
   ByteBuffer collationKeyBuf = ByteBuffer.wrap(reusableKey.bytes, 0, reusableKey.size);
   int encodedLength
    = IndexableBinaryStringTools.getEncodedLength(collationKeyBuf);
   if (encodedLength > termBuffer.length) {
    termAtt.resizeTermBuffer(encodedLength);
   }
   termAtt.setTermLength(encodedLength);
   CharBuffer wrappedTermBuffer = CharBuffer.wrap(termAtt.termBuffer());
   IndexableBinaryStringTools.encode(collationKeyBuf, wrappedTermBuffer);
   return true;
  } else {
   return false;
  }
 }
}

代码示例来源:origin: org.elasticsearch.plugin/analysis-icu

@Override
 public boolean incrementToken() throws IOException {
  if (input.incrementToken()) {
   char[] termBuffer = termAtt.buffer();
   String termText = new String(termBuffer, 0, termAtt.length());
   collator.getRawCollationKey(termText, reusableKey);
   int encodedLength = IndexableBinaryStringTools.getEncodedLength(
     reusableKey.bytes, 0, reusableKey.size);
   if (encodedLength > termBuffer.length) {
    termAtt.resizeBuffer(encodedLength);
   }
   termAtt.setLength(encodedLength);
   IndexableBinaryStringTools.encode(reusableKey.bytes, 0, reusableKey.size,
     termAtt.buffer(), 0, encodedLength);
   return true;
  } else {
   return false;
  }
 }
}

代码示例来源:origin: org.apache.lucene/lucene-icu

@Override
 public boolean incrementToken() throws IOException {
  if (input.incrementToken()) {
   char[] termBuffer = termAtt.buffer();
   String termText = new String(termBuffer, 0, termAtt.length());
   collator.getRawCollationKey(termText, reusableKey);
   int encodedLength = IndexableBinaryStringTools.getEncodedLength(
     reusableKey.bytes, 0, reusableKey.size);
   if (encodedLength > termBuffer.length) {
    termAtt.resizeBuffer(encodedLength);
   }
   termAtt.setLength(encodedLength);
   IndexableBinaryStringTools.encode(reusableKey.bytes, 0, reusableKey.size,
     termAtt.buffer(), 0, encodedLength);
   return true;
  } else {
   return false;
  }
 }
}

相关文章