Package org.apache.lucene.util

Examples of org.apache.lucene.util.AttributeImpl


          while (tokenStream.incrementToken()) {
            // TODO: this is a simple workaround to still work with tokens, not very effective, but as far as I know, this writer should get removed soon:
            final Token token = new Token();
            for (Iterator<AttributeImpl> atts = tokenStream.getAttributeImplsIterator(); atts.hasNext();) {
              final AttributeImpl att = atts.next();
              try {
                att.copyTo(token);
              } catch (Exception e) {
                // ignore unsupported attributes,
                // this may fail to copy some attributes, if a special combined AttributeImpl is used, that
                // implements basic attributes supported by Token and also other customized ones in one class.
              }
View Full Code Here


public class TestSingleTokenTokenFilter extends LuceneTestCase {

  public void test() throws IOException {
    Token token = new Token();
    SingleTokenTokenStream ts = new SingleTokenTokenStream(token);
    AttributeImpl tokenAtt = (AttributeImpl) ts.addAttribute(TermAttribute.class);
    assertTrue(tokenAtt instanceof Token);
    ts.reset();

    assertTrue(ts.incrementToken());
    assertEquals(token, tokenAtt);
View Full Code Here

    getAttributes().add( attr );
  }

  @Override
  public void addCharTermAttribute(CharSequence sequence) {
    AttributeImpl attr = AttributeSource.AttributeFactory
        .DEFAULT_ATTRIBUTE_FACTORY
        .createAttributeInstance( CharTermAttribute.class );
    ( (CharTermAttribute) attr ).append( sequence );
    getAttributes().add( attr );
  }
View Full Code Here

    getAttributes().add( attr );
  }

  @Override
  public void addPayloadAttribute(byte[] payloads) {
    AttributeImpl attr = AttributeSource.AttributeFactory
        .DEFAULT_ATTRIBUTE_FACTORY
        .createAttributeInstance( PayloadAttribute.class );
    ( (PayloadAttribute) attr ).setPayload( new Payload( payloads ) );
    getAttributes().add( attr );
  }
View Full Code Here

    getAttributes().add( attr );
  }

  @Override
  public void addKeywordAttribute(boolean isKeyword) {
    AttributeImpl attr = AttributeSource.AttributeFactory
        .DEFAULT_ATTRIBUTE_FACTORY
        .createAttributeInstance( KeywordAttribute.class );
    ( (KeywordAttribute) attr ).setKeyword( isKeyword );
    getAttributes().add( attr );
  }
View Full Code Here

    getAttributes().add( attr );
  }

  @Override
  public void addPositionIncrementAttribute(int positionIncrement) {
    AttributeImpl attr = AttributeSource.AttributeFactory
        .DEFAULT_ATTRIBUTE_FACTORY
        .createAttributeInstance( PositionIncrementAttribute.class );
    ( (PositionIncrementAttribute) attr ).setPositionIncrement( positionIncrement );
    getAttributes().add( attr );
  }
View Full Code Here

    getAttributes().add( attr );
  }

  @Override
  public void addFlagsAttribute(int flags) {
    AttributeImpl attr = AttributeSource.AttributeFactory
        .DEFAULT_ATTRIBUTE_FACTORY
        .createAttributeInstance( FlagsAttribute.class );
    ( (FlagsAttribute) attr ).setFlags( flags );
    getAttributes().add( attr );
  }
View Full Code Here

    getAttributes().add( attr );
  }

  @Override
  public void addTypeAttribute(String type) {
    AttributeImpl attr = AttributeSource.AttributeFactory
        .DEFAULT_ATTRIBUTE_FACTORY
        .createAttributeInstance( TypeAttribute.class );
    ( (TypeAttribute) attr ).setType( type );
    getAttributes().add( attr );
  }
View Full Code Here

    getAttributes().add( attr );
  }

  @Override
  public void addOffsetAttribute(int startOffset, int endOffset) {
    AttributeImpl attr = AttributeSource.AttributeFactory
        .DEFAULT_ATTRIBUTE_FACTORY
        .createAttributeInstance( OffsetAttribute.class );
    ( (OffsetAttribute) attr ).setOffset( startOffset, endOffset );
    getAttributes().add( attr );
  }
View Full Code Here

    getAttributes().add( attr );
  }

  @Override
  public void addCharTermAttribute(CharSequence sequence) {
    AttributeImpl attr = AttributeSource.AttributeFactory
        .DEFAULT_ATTRIBUTE_FACTORY
        .createAttributeInstance( CharTermAttribute.class );
    ( (CharTermAttribute) attr ).append( sequence );
    getAttributes().add( attr );
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.util.AttributeImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.