Java 类org.apache.lucene.analysis.path.PathHierarchyTokenizer 实例源码

项目:elasticsearch_my    文件:PathHierarchyTokenizerFactory.java   
public PathHierarchyTokenizerFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
    super(indexSettings, name, settings);
    bufferSize = settings.getAsInt("buffer_size", 1024);
    String delimiter = settings.get("delimiter");
    if (delimiter == null) {
        this.delimiter = PathHierarchyTokenizer.DEFAULT_DELIMITER;
    } else if (delimiter.length() > 1) {
        throw new IllegalArgumentException("delimiter can only be a one char value");
    } else {
        this.delimiter = delimiter.charAt(0);
    }

    String replacement = settings.get("replacement");
    if (replacement == null) {
        this.replacement = this.delimiter;
    } else if (replacement.length() > 1) {
        throw new IllegalArgumentException("replacement can only be a one char value");
    } else {
        this.replacement = replacement.charAt(0);
    }
    this.skip = settings.getAsInt("skip", PathHierarchyTokenizer.DEFAULT_SKIP);
    this.reverse =
        settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "reverse", false, deprecationLogger);
}
项目:Elasticsearch    文件:PathHierarchyTokenizerFactory.java   
@Inject
public PathHierarchyTokenizerFactory(Index index, IndexSettingsService indexSettingsService, @Assisted String name, @Assisted Settings settings) {
    super(index, indexSettingsService.getSettings(), name, settings);
    bufferSize = settings.getAsInt("buffer_size", 1024);
    String delimiter = settings.get("delimiter");
    if (delimiter == null) {
        this.delimiter = PathHierarchyTokenizer.DEFAULT_DELIMITER;
    } else if (delimiter.length() > 1) {
        throw new IllegalArgumentException("delimiter can only be a one char value");
    } else {
        this.delimiter = delimiter.charAt(0);
    }

    String replacement = settings.get("replacement");
    if (replacement == null) {
        this.replacement = this.delimiter;
    } else if (replacement.length() > 1) {
        throw new IllegalArgumentException("replacement can only be a one char value");
    } else {
        this.replacement = replacement.charAt(0);
    }
    this.skip = settings.getAsInt("skip", PathHierarchyTokenizer.DEFAULT_SKIP);
    this.reverse = settings.getAsBoolean("reverse", false);
}
项目:elasticsearch_my    文件:PathHierarchyTokenizerFactory.java   
@Override
public Tokenizer create() {
    if (reverse) {
        return new ReversePathHierarchyTokenizer(bufferSize, delimiter, replacement, skip);
    }
    return new PathHierarchyTokenizer(bufferSize, delimiter, replacement, skip);
}
项目:Elasticsearch    文件:PathHierarchyTokenizerFactory.java   
@Override
public Tokenizer create() {
    if (reverse) {
        return new ReversePathHierarchyTokenizer(bufferSize, delimiter, replacement, skip);
    }
    return new PathHierarchyTokenizer(bufferSize, delimiter, replacement, skip);
}
项目:elasticsearch-analysis-url    文件:URLTokenizer.java   
private List<Token> getPathTokens(String url, String partStringRaw, String partString) throws IOException {
    int start = getStartIndex(url, partStringRaw);
    if (!tokenizePath) {
        int end = getEndIndex(start, partStringRaw);
        return Collections.singletonList(new Token(partString, URLPart.PATH, start, end));
    }
    return tokenize(URLPart.PATH, addReader(new PathHierarchyTokenizer('/', '/'), new StringReader(partString)), start);
}
项目:NYBC    文件:PathHierarchyTokenizerFactory.java   
@Override
public Tokenizer create(Reader input) {
  if( reverse ) {
    return new ReversePathHierarchyTokenizer(input, delimiter, replacement, skip);
  }
  return new PathHierarchyTokenizer(input, delimiter, replacement, skip);
}
项目:NYBC    文件:PathHierarchyTokenizerFactory.java   
/**
 * Require a configured pattern
 */
@Override
public void init(Map<String,String> args){
  super.init( args );

  String v = args.get( "delimiter" );
  if( v != null ){
    if( v.length() != 1 ){
      throw new IllegalArgumentException("delimiter should be a char. \"" + v + "\" is invalid");
    }
    else{
      delimiter = v.charAt(0);
    }
  }
  else{
    delimiter = PathHierarchyTokenizer.DEFAULT_DELIMITER;
  }

  v = args.get( "replace" );
  if( v != null ){
    if( v.length() != 1 ){
      throw new IllegalArgumentException("replace should be a char. \"" + v + "\" is invalid");
    }
    else{
      replacement = v.charAt(0);
    }
  }
  else{
    replacement = delimiter;
  }

  v = args.get( "reverse" );
  if( v != null ){
    reverse = "true".equals( v );
  }

  v = args.get( "skip" );
  if( v != null ){
    skip = Integer.parseInt( v );
  }
}