FileDocCategorySizeDatePackage
SimpleFragmenter.javaAPI DocApache Lucene 1.92007Mon Feb 20 09:18:22 GMT 2006org.apache.lucene.search.highlight

SimpleFragmenter

public class SimpleFragmenter extends Object implements Fragmenter
{@link Fragmenter} implementation which breaks text up into same-size fragments with no concerns over spotting sentence boundaries.
author
mark@searcharea.co.uk

Fields Summary
private static final int
DEFAULT_FRAGMENT_SIZE
private int
currentNumFrags
private int
fragmentSize
Constructors Summary
public SimpleFragmenter()



	 
	
		this(DEFAULT_FRAGMENT_SIZE);
	
public SimpleFragmenter(int fragmentSize)

param
fragmentSize size in bytes of each fragment

		this.fragmentSize=fragmentSize;
	
Methods Summary
public intgetFragmentSize()

return
size in bytes of each fragment

		return fragmentSize;
	
public booleanisNewFragment(org.apache.lucene.analysis.Token token)

		boolean isNewFrag= token.endOffset()>=(fragmentSize*currentNumFrags);
		if(isNewFrag)
		{
			currentNumFrags++;
		}
		return isNewFrag;
	
public voidsetFragmentSize(int size)

param
size size in bytes of each fragment

		fragmentSize = size;
	
public voidstart(java.lang.String originalText)

		currentNumFrags=1;