作者:z1996y | 来源:互联网 | 2023-07-16 15:53
本文整理了Java中org.apache.lucene.analysis.util.ResourceLoader.newInstance方法的一些代码示例,展示了
本文整理了Java中org.apache.lucene.analysis.util.ResourceLoader.newInstance
方法的一些代码示例,展示了ResourceLoader.newInstance
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceLoader.newInstance
方法的具体详情如下:
包路径:org.apache.lucene.analysis.util.ResourceLoader
类名称:ResourceLoader
方法名:newInstance
ResourceLoader.newInstance介绍
[英]Creates a class of the name and expected type
[中]创建名称和预期类型的类
代码示例
代码示例来源:origin: org.apache.lucene/lucene-analyzers-common
@Override
public T newInstance(String cname, Class expectedType) {
return delegate.newInstance(cname, expectedType);
}
代码示例来源:origin: org.apache.lucene/lucene-analyzers-common
@Override
public void inform(ResourceLoader loader) throws IOException {
String className = "org.tartarus.snowball.ext." + language + "Stemmer";
stemClass = loader.newInstance(className, SnowballProgram.class).getClass();
if (wordFiles != null) {
protectedWords = getWordSet(loader, wordFiles, false);
}
}
代码示例来源:origin: org.apache.lucene/lucene-analyzers-common
@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);
}
}
}
代码示例来源:origin: gncloud/fastcatsearch
@Override
public T newInstance(String cname, Class expectedType) {
return delegate.newInstance(cname, expectedType);
}
}
代码示例来源:origin: org.infinispan/infinispan-embedded-query
@Override
public T newInstance(String cname, Class expectedType) {
return delegate.newInstance(cname, expectedType);
}
代码示例来源:origin: AKuznetsov/russianmorphology
public void inform(ResourceLoader loader) {
String className = "org.apache.lucene.morphology." + language.toLowerCase() + "." + language + "LuceneMorphology";
luceneMorphology = loader.newInstance(className, LuceneMorphology.class);
}
代码示例来源:origin: org.infinispan/infinispan-embedded-query
@Override
public void inform(ResourceLoader loader) throws IOException {
String className = "org.tartarus.snowball.ext." + language + "Stemmer";
stemClass = loader.newInstance(className, SnowballProgram.class).getClass();
if (wordFiles != null) {
protectedWords = getWordSet(loader, wordFiles, false);
}
}
代码示例来源:origin: org.infinispan/infinispan-embedded-query
@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);
}
}
}
代码示例来源:origin: renekrie/querqy
/**
* Loads the whole {@link RewriteChain}s from the args and returns a list of
* them.
*/
private RewriteChain loadRewriteChain(final ResourceLoader loader) throws IOException {
final NamedList> chainCOnfig= (NamedList>) initArgs.get("rewriteChain");
final List factories = new LinkedList<>();
if (chainConfig != null) {
@SuppressWarnings("unchecked")
final List> rewriterCOnfigs= (List>) 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);
}
代码示例来源:origin: renekrie/querqy
@Override
public RewriterFactory createRewriterFactory(final NamedList> args,
final ResourceLoader resourceLoader) throws IOException {
final String rulesResourceName = (String) args.get("rules");
if (rulesResourceName == null) {
throw new IllegalArgumentException("Property 'rules' not configured");
}
final 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);
}
}
if (querqyParser == null) {
querqyParser = new WhiteSpaceQuerqyParserFactory();
}
return new querqy.rewrite.commonrules.SimpleCommonRulesRewriterFactory(
new InputStreamReader(resourceLoader.openResource(rulesResourceName), "UTF-8"),
querqyParser,
ignoreCase == null || ignoreCase);
}
代码示例来源:origin: renekrie/querqy
protected SolrQuerqyParserFactory loadSolrQuerqyParserFactory(final ResourceLoader loader,
final NamedList> args) throws IOException {
final Object parserCOnfig= args.get("parser");
if (parserCOnfig== null) {
final SimpleQuerqyQParserFactory factory = new SimpleQuerqyQParserFactory();
factory.setQuerqyParserClass(WhiteSpaceQuerqyParser.class);
return factory;
} else if (parserConfig instanceof String) {
final SimpleQuerqyQParserFactory factory = new SimpleQuerqyQParserFactory();
factory.init((String) parserConfig, loader);
return factory;
} else {
NamedList> parserCOnfigMap= (NamedList>) parserConfig;
if (parserCOnfig== null) {
throw new IOException("Missing querqy parser configuration");
}
final String className = (String) parserConfigMap.get("factory");
final SolrQuerqyParserFactory factory = className == null
? new SimpleQuerqyQParserFactory()
: loader.newInstance(className, SolrQuerqyParserFactory.class);
factory.init(parserConfigMap, loader);
return factory;
}
}