Example usage for org.apache.lucene.util AttributeFactory createAttributeInstance

List of usage examples for org.apache.lucene.util AttributeFactory createAttributeInstance

Introduction

In this page you can find the example usage for org.apache.lucene.util AttributeFactory createAttributeInstance.

Prototype

public abstract AttributeImpl createAttributeInstance(Class<? extends Attribute> attClass)
        throws UndeclaredThrowableException;

Source Link

Document

Returns an AttributeImpl for the supplied Attribute interface class.

Usage

From source file:com.o19s.RegexPathHierarchyTokenizer.java

License:Apache License

public RegexPathHierarchyTokenizer(AttributeFactory factory, Reader input, int bufferSize, String delimiter,
        int depthPrefixNumChars) {

    super(factory, input);
    if (bufferSize < 0) {
        throw new IllegalArgumentException("bufferSize cannot be negative");
    }/*from  w w w . j a va2  s  .  c om*/

    if (depthPrefixNumChars > 0) {
        termAttFormatter = new Formatter(termAtt);
        zeroPaddingString = "%0" + depthPrefixNumChars + "d";
    }

    termBuffer = new StringBuilder(bufferSize);
    termAtt.resizeBuffer(bufferSize);
    this.delimiter = Pattern.compile(delimiter);
    this.depthPrefixNumChars = depthPrefixNumChars;
    keyWordTokenizerTermAtt = (CharTermAttribute) factory.createAttributeInstance(CharTermAttribute.class);
    matcher = this.delimiter.matcher(keyWordTokenizerTermAtt);
}