github.com/balzaczyy/golucene@v0.0.0-20151210033525-d0be9ee89713/core/analysis/tokenattributes/factory.go (about)

     1  package tokenattributes
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/balzaczyy/golucene/core/util"
     6  )
     7  
     8  type DefaultAttributeFactory struct{}
     9  
    10  func (fac *DefaultAttributeFactory) Create(name string) util.AttributeImpl {
    11  	switch name {
    12  	case "PositionIncrementAttribute":
    13  		return newPositionIncrementAttributeImpl()
    14  	case "CharTermAttribute":
    15  		return newCharTermAttributeImpl()
    16  	case "OffsetAttribute":
    17  		return newOffsetAttributeImpl()
    18  	case "TypeAttribute":
    19  		return newTypeAttributeImpl()
    20  	case "PayloadAttribute":
    21  		return newPayloadAttributeImpl()
    22  	}
    23  	panic(fmt.Sprintf("not supported yet: %v", name))
    24  }
    25  
    26  /*
    27  This is the default factory that creates AttributeImpls using the
    28  class name of the supplied Attribute interface class by appending
    29  Impl to it.
    30  */
    31  var DEFAULT_ATTRIBUTE_FACTORY = new(DefaultAttributeFactory)