本文整理汇总了Java中org.apache.lucene.analysis.util.ResourceLoader.newInstance方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceLoader.newInstance方法的具体用法?Java ResourceLoader.newInstance怎么用?Java ResourceLoader.newInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.analysis.util.ResourceLoader
的用法示例。
在下文中一共展示了ResourceLoader.newInstance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadRewriteChain
import org.apache.lucene.analysis.util.ResourceLoader; //导入方法依赖的package包/类
/**
* Loads the whole {@link RewriteChain}s from the args and returns a list of
* them.
*/
private RewriteChain loadRewriteChain(ResourceLoader loader) throws IOException {
NamedList<?> chainConfig = (NamedList<?>) initArgs.get("rewriteChain");
List<RewriterFactory> factories = new LinkedList<>();
if (chainConfig != null) {
@SuppressWarnings("unchecked")
List<NamedList<?>> rewriterConfigs = (List<NamedList<?>>) chainConfig.getAll("rewriter");
if (rewriterConfigs != null) {
for (NamedList<?> config : rewriterConfigs) {
RewriterFactoryAdapter factory = loader.newInstance((String) config.get("class"),
RewriterFactoryAdapter.class);
factories.add(factory.createRewriterFactory(config, loader));
}
}
}
return new RewriteChain(factories);
}
示例2: createRewriterFactory
import org.apache.lucene.analysis.util.ResourceLoader; //导入方法依赖的package包/类
@Override
public RewriterFactory createRewriterFactory(NamedList<?> args,
ResourceLoader resourceLoader) throws IOException {
String rulesResourceName = (String) args.get("rules");
if (rulesResourceName == null) {
throw new IllegalArgumentException("Property 'rules' not configured");
}
Boolean ignoreCase = args.getBooleanArg("ignoreCase");
// querqy parser for queries that are part of the instructions in the
// rules
String rulesQuerqyParser = (String) args.get("querqyParser");
QuerqyParserFactory querqyParser = null;
if (rulesQuerqyParser != null) {
rulesQuerqyParser = rulesQuerqyParser.trim();
if (rulesQuerqyParser.length() > 0) {
querqyParser = resourceLoader.newInstance(rulesQuerqyParser, QuerqyParserFactory.class);
}
}
return new querqy.rewrite.commonrules.SimpleCommonRulesRewriterFactory(
new InputStreamReader(resourceLoader.openResource(rulesResourceName), "UTF-8"), querqyParser, ignoreCase != null && ignoreCase);
}
示例3: inform
import org.apache.lucene.analysis.util.ResourceLoader; //导入方法依赖的package包/类
@Override
public void inform(ResourceLoader loader) {
if (encoderClass.equals("float")){
encoder = new FloatEncoder();
} else if (encoderClass.equals("integer")){
encoder = new IntegerEncoder();
} else if (encoderClass.equals("identity")){
encoder = new IdentityEncoder();
} else {
encoder = loader.newInstance(encoderClass, PayloadEncoder.class);
}
}
示例4: inform
import org.apache.lucene.analysis.util.ResourceLoader; //导入方法依赖的package包/类
@Override
public void inform(ResourceLoader loader) throws IOException {
NamedList<?> parserConfig = (NamedList<?>) initArgs.get("parser");
if (parserConfig == null) {
throw new IOException("Missing querqy parser configuration");
}
String className = (String) parserConfig.get("factory");
if (className == null) {
throw new IOException("Missing attribute 'factory' in querqy parser configuration");
}
SolrQuerqyParserFactory factory = loader.newInstance(className, SolrQuerqyParserFactory.class);
factory.init(parserConfig, loader);
rewriteChain = loadRewriteChain(loader);
termQueryCacheName = (String) initArgs.get(CONF_CACHE_NAME);
Boolean updateCache = initArgs.getBooleanArg(CONF_CACHE_UPDATE);
if (termQueryCacheName == null && updateCache != null) {
throw new IOException("Configuration property " + CONF_CACHE_NAME + " required if " + CONF_CACHE_UPDATE + " is set");
}
ignoreTermQueryCacheUpdates = (updateCache != null) && !updateCache;
this.querqyParserFactory = factory;
}
示例5: inform
import org.apache.lucene.analysis.util.ResourceLoader; //导入方法依赖的package包/类
public void inform(ResourceLoader loader) {
String className = "org.apache.lucene.morphology." + language.toLowerCase() + "." + language + "LuceneMorphology";
luceneMorphology = loader.newInstance(className, LuceneMorphology.class);
}