org.apache.lucene.analysis.miscellaneous
Class PrefixAwareTokenFilter

java.lang.Object
  extended by org.apache.lucene.util.AttributeSource
      extended by org.apache.lucene.analysis.TokenStream
          extended by org.apache.lucene.analysis.miscellaneous.PrefixAwareTokenFilter

public class PrefixAwareTokenFilter
extends org.apache.lucene.analysis.TokenStream

Joins two token streams and leaves the last token of the first stream available to be used when updating the token values in the second stream based on that token. The default implementation adds last prefix token end offset to the suffix token start and end offsets.

NOTE: This filter might not behave correctly if used with custom Attributes, i.e. Attributes other than the ones located in org.apache.lucene.analysis.tokenattributes.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.lucene.util.AttributeSource
org.apache.lucene.util.AttributeSource.AttributeFactory, org.apache.lucene.util.AttributeSource.State
 
Constructor Summary
PrefixAwareTokenFilter(org.apache.lucene.analysis.TokenStream prefix, org.apache.lucene.analysis.TokenStream suffix)
           
 
Method Summary
 void close()
           
 org.apache.lucene.analysis.TokenStream getPrefix()
           
 org.apache.lucene.analysis.TokenStream getSuffix()
           
 boolean incrementToken()
           
 org.apache.lucene.analysis.Token next()
          Deprecated. Will be removed in Lucene 3.0. This method is final, as it should not be overridden. Delegates to the backwards compatibility layer.
 org.apache.lucene.analysis.Token next(org.apache.lucene.analysis.Token reusableToken)
          Deprecated. Will be removed in Lucene 3.0. This method is final, as it should not be overridden. Delegates to the backwards compatibility layer.
 void reset()
           
 void setPrefix(org.apache.lucene.analysis.TokenStream prefix)
           
 void setSuffix(org.apache.lucene.analysis.TokenStream suffix)
           
 org.apache.lucene.analysis.Token updateSuffixToken(org.apache.lucene.analysis.Token suffixToken, org.apache.lucene.analysis.Token lastPrefixToken)
          The default implementation adds last prefix token end offset to the suffix token start and end offsets.
 
Methods inherited from class org.apache.lucene.analysis.TokenStream
end, getOnlyUseNewAPI, setOnlyUseNewAPI
 
Methods inherited from class org.apache.lucene.util.AttributeSource
addAttribute, addAttributeImpl, captureState, clearAttributes, cloneAttributes, equals, getAttribute, getAttributeClassesIterator, getAttributeFactory, getAttributeImplsIterator, hasAttribute, hasAttributes, hashCode, restoreState, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PrefixAwareTokenFilter

public PrefixAwareTokenFilter(org.apache.lucene.analysis.TokenStream prefix,
                              org.apache.lucene.analysis.TokenStream suffix)
Method Detail

incrementToken

public final boolean incrementToken()
                             throws IOException
Overrides:
incrementToken in class org.apache.lucene.analysis.TokenStream
Throws:
IOException

next

public final org.apache.lucene.analysis.Token next(org.apache.lucene.analysis.Token reusableToken)
                                            throws IOException
Deprecated. Will be removed in Lucene 3.0. This method is final, as it should not be overridden. Delegates to the backwards compatibility layer.

Overrides:
next in class org.apache.lucene.analysis.TokenStream
Throws:
IOException

next

public final org.apache.lucene.analysis.Token next()
                                            throws IOException
Deprecated. Will be removed in Lucene 3.0. This method is final, as it should not be overridden. Delegates to the backwards compatibility layer.

Overrides:
next in class org.apache.lucene.analysis.TokenStream
Throws:
IOException

updateSuffixToken

public org.apache.lucene.analysis.Token updateSuffixToken(org.apache.lucene.analysis.Token suffixToken,
                                                          org.apache.lucene.analysis.Token lastPrefixToken)
The default implementation adds last prefix token end offset to the suffix token start and end offsets.

Parameters:
suffixToken - a token from the suffix stream
lastPrefixToken - the last token from the prefix stream
Returns:
consumer token

close

public void close()
           throws IOException
Overrides:
close in class org.apache.lucene.analysis.TokenStream
Throws:
IOException

reset

public void reset()
           throws IOException
Overrides:
reset in class org.apache.lucene.analysis.TokenStream
Throws:
IOException

getPrefix

public org.apache.lucene.analysis.TokenStream getPrefix()

setPrefix

public void setPrefix(org.apache.lucene.analysis.TokenStream prefix)

getSuffix

public org.apache.lucene.analysis.TokenStream getSuffix()

setSuffix

public void setSuffix(org.apache.lucene.analysis.TokenStream suffix)


Copyright © 2000-2010 Apache Software Foundation. All Rights Reserved.