本文整理汇总了Java中org.apache.lucene.util.BytesRef.toString方法的典型用法代码示例。如果您正苦于以下问题:Java BytesRef.toString方法的具体用法?Java BytesRef.toString怎么用?Java BytesRef.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.util.BytesRef
的用法示例。
在下文中一共展示了BytesRef.toString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: brToString
import org.apache.lucene.util.BytesRef; //导入方法依赖的package包/类
@SuppressWarnings("unused")
static String brToString(BytesRef b) {
try {
return b.utf8ToString() + " " + b;
} catch (Throwable t) {
// If BytesRef isn't actually UTF8, or it's eg a
// prefix of UTF8 that ends mid-unicode-char, we
// fallback to hex:
return b.toString();
}
}
示例2: brToString
import org.apache.lucene.util.BytesRef; //导入方法依赖的package包/类
String brToString(BytesRef b) {
if (b == null) {
return "null";
} else {
try {
return b.utf8ToString() + " " + b;
} catch (Throwable t) {
// If BytesRef isn't actually UTF8, or it's eg a
// prefix of UTF8 that ends mid-unicode-char, we
// fallback to hex:
return b.toString();
}
}
}
示例3: toString
import org.apache.lucene.util.BytesRef; //导入方法依赖的package包/类
/** Returns human-readable form of the term text. If the term is not unicode,
* the raw bytes will be printed instead. */
public static final String toString(BytesRef termText) {
// the term might not be text, but usually is. so we make a best effort
CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder()
.onMalformedInput(CodingErrorAction.REPORT)
.onUnmappableCharacter(CodingErrorAction.REPORT);
try {
return decoder.decode(ByteBuffer.wrap(termText.bytes, termText.offset, termText.length)).toString();
} catch (CharacterCodingException e) {
return termText.toString();
}
}
示例4: outputToString
import org.apache.lucene.util.BytesRef; //导入方法依赖的package包/类
@Override
public String outputToString(BytesRef output) {
return output.toString();
}