org.apache.lucene.analysis.Token.initTermBuffer()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(243)

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

Token.initTermBuffer介绍

暂无

代码示例

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

  1. /** Returns the internal termBuffer character array which
  2. * you can then directly alter. If the array is too
  3. * small for your token, use {@link
  4. * #resizeTermBuffer(int)} to increase it. After
  5. * altering the buffer be sure to call {@link
  6. * #setTermLength} to record the number of valid
  7. * characters that were placed into the termBuffer. */
  8. public final char[] termBuffer() {
  9. initTermBuffer();
  10. return termBuffer;
  11. }

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

  1. /** Return number of valid characters (length of the term)
  2. * in the termBuffer array. */
  3. public final int termLength() {
  4. initTermBuffer();
  5. return termLength;
  6. }

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

  1. /** Returns the internal termBuffer character array which
  2. * you can then directly alter. If the array is too
  3. * small for your token, use {@link
  4. * #resizeTermBuffer(int)} to increase it. After
  5. * altering the buffer be sure to call {@link
  6. * #setTermLength} to record the number of valid
  7. * characters that were placed into the termBuffer. */
  8. public final char[] termBuffer() {
  9. initTermBuffer();
  10. return termBuffer;
  11. }

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

  1. /** Return number of valid characters (length of the term)
  2. * in the termBuffer array. */
  3. public final int termLength() {
  4. initTermBuffer();
  5. return termLength;
  6. }

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

  1. /** Set number of valid characters (length of the term) in
  2. * the termBuffer array. Use this to truncate the termBuffer
  3. * or to synchronize with external manipulation of the termBuffer.
  4. * Note: to grow the size of the array,
  5. * use {@link #resizeTermBuffer(int)} first.
  6. * @param length the truncated length
  7. */
  8. public final void setTermLength(int length) {
  9. initTermBuffer();
  10. if (length > termBuffer.length)
  11. throw new IllegalArgumentException("length " + length + " exceeds the size of the termBuffer (" + termBuffer.length + ")");
  12. termLength = length;
  13. }

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

  1. /** Set number of valid characters (length of the term) in
  2. * the termBuffer array. Use this to truncate the termBuffer
  3. * or to synchronize with external manipulation of the termBuffer.
  4. * Note: to grow the size of the array,
  5. * use {@link #resizeTermBuffer(int)} first.
  6. * @param length the truncated length
  7. */
  8. public final void setTermLength(int length) {
  9. initTermBuffer();
  10. if (length > termBuffer.length)
  11. throw new IllegalArgumentException("length " + length + " exceeds the size of the termBuffer (" + termBuffer.length + ")");
  12. termLength = length;
  13. }

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

  1. /** Returns the Token's term text.
  2. *
  3. * This method has a performance penalty
  4. * because the text is stored internally in a char[]. If
  5. * possible, use {@link #termBuffer()} and {@link
  6. * #termLength()} directly instead. If you really need a
  7. * String, use this method, which is nothing more than
  8. * a convenience call to <b>new String(token.termBuffer(), 0, token.termLength())</b>
  9. */
  10. public final String term() {
  11. if (termText != null)
  12. return termText;
  13. initTermBuffer();
  14. return new String(termBuffer, 0, termLength);
  15. }

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

  1. /** Returns the Token's term text.
  2. *
  3. * This method has a performance penalty
  4. * because the text is stored internally in a char[]. If
  5. * possible, use {@link #termBuffer()} and {@link
  6. * #termLength()} directly instead. If you really need a
  7. * String, use this method, which is nothing more than
  8. * a convenience call to <b>new String(token.termBuffer(), 0, token.termLength())</b>
  9. */
  10. public final String term() {
  11. if (termText != null)
  12. return termText;
  13. initTermBuffer();
  14. return new String(termBuffer, 0, termLength);
  15. }

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

  1. public String toString() {
  2. StringBuffer sb = new StringBuffer();
  3. sb.append('(');
  4. initTermBuffer();
  5. if (termBuffer == null)
  6. sb.append("null");
  7. else
  8. sb.append(termBuffer, 0, termLength);
  9. sb.append(',').append(startOffset).append(',').append(endOffset);
  10. if (!type.equals("word"))
  11. sb.append(",type=").append(type);
  12. if (positionIncrement != 1)
  13. sb.append(",posIncr=").append(positionIncrement);
  14. sb.append(')');
  15. return sb.toString();
  16. }

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

  1. public String toString() {
  2. StringBuffer sb = new StringBuffer();
  3. sb.append('(');
  4. initTermBuffer();
  5. if (termBuffer == null)
  6. sb.append("null");
  7. else
  8. sb.append(termBuffer, 0, termLength);
  9. sb.append(',').append(startOffset).append(',').append(endOffset);
  10. if (!type.equals("word"))
  11. sb.append(",type=").append(type);
  12. if (positionIncrement != 1)
  13. sb.append(",posIncr=").append(positionIncrement);
  14. sb.append(')');
  15. return sb.toString();
  16. }

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

  1. /**
  2. * Copy the prototype token's fields into this one. Note: Payloads are shared.
  3. * @param prototype
  4. */
  5. public void reinit(Token prototype) {
  6. prototype.initTermBuffer();
  7. setTermBuffer(prototype.termBuffer, 0, prototype.termLength);
  8. positionIncrement = prototype.positionIncrement;
  9. flags = prototype.flags;
  10. startOffset = prototype.startOffset;
  11. endOffset = prototype.endOffset;
  12. type = prototype.type;
  13. payload = prototype.payload;
  14. }

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

  1. /**
  2. * Copy the prototype token's fields into this one. Note: Payloads are shared.
  3. * @param prototype
  4. */
  5. public void reinit(Token prototype) {
  6. prototype.initTermBuffer();
  7. setTermBuffer(prototype.termBuffer, 0, prototype.termLength);
  8. positionIncrement = prototype.positionIncrement;
  9. flags = prototype.flags;
  10. startOffset = prototype.startOffset;
  11. endOffset = prototype.endOffset;
  12. type = prototype.type;
  13. payload = prototype.payload;
  14. }

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

  1. public boolean equals(Object obj) {
  2. if (obj == this)
  3. return true;
  4. if (obj instanceof Token) {
  5. Token other = (Token) obj;
  6. initTermBuffer();
  7. other.initTermBuffer();
  8. if (termLength == other.termLength &&
  9. startOffset == other.startOffset &&
  10. endOffset == other.endOffset &&
  11. flags == other.flags &&
  12. positionIncrement == other.positionIncrement &&
  13. subEqual(type, other.type) &&
  14. subEqual(payload, other.payload)) {
  15. for(int i=0;i<termLength;i++)
  16. if (termBuffer[i] != other.termBuffer[i])
  17. return false;
  18. return true;
  19. } else
  20. return false;
  21. } else
  22. return false;
  23. }

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

  1. public boolean equals(Object obj) {
  2. if (obj == this)
  3. return true;
  4. if (obj instanceof Token) {
  5. Token other = (Token) obj;
  6. initTermBuffer();
  7. other.initTermBuffer();
  8. if (termLength == other.termLength &&
  9. startOffset == other.startOffset &&
  10. endOffset == other.endOffset &&
  11. flags == other.flags &&
  12. positionIncrement == other.positionIncrement &&
  13. subEqual(type, other.type) &&
  14. subEqual(payload, other.payload)) {
  15. for(int i=0;i<termLength;i++)
  16. if (termBuffer[i] != other.termBuffer[i])
  17. return false;
  18. return true;
  19. } else
  20. return false;
  21. } else
  22. return false;
  23. }

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

  1. public int hashCode() {
  2. initTermBuffer();
  3. int code = termLength;
  4. code = code * 31 + startOffset;
  5. code = code * 31 + endOffset;
  6. code = code * 31 + flags;
  7. code = code * 31 + positionIncrement;
  8. code = code * 31 + type.hashCode();
  9. code = (payload == null ? code : code * 31 + payload.hashCode());
  10. code = code * 31 + ArrayUtil.hashCode(termBuffer, 0, termLength);
  11. return code;
  12. }

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

  1. public int hashCode() {
  2. initTermBuffer();
  3. int code = termLength;
  4. code = code * 31 + startOffset;
  5. code = code * 31 + endOffset;
  6. code = code * 31 + flags;
  7. code = code * 31 + positionIncrement;
  8. code = code * 31 + type.hashCode();
  9. code = (payload == null ? code : code * 31 + payload.hashCode());
  10. code = code * 31 + ArrayUtil.hashCode(termBuffer, 0, termLength);
  11. return code;
  12. }

相关文章