本文整理匯總了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();
}