Package org.jesterj.ingest.utils
Class SolrSchemaUtil
- java.lang.Object
-
- org.jesterj.ingest.utils.SolrSchemaUtil
-
public class SolrSchemaUtil extends java.lang.ObjectA stateful utility bean for working with schema documents. This class is not thread safe.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSCHEMA_XML_ANALYZER_CHAR_FILTERstatic java.lang.StringSCHEMA_XML_ANALYZER_FILTERstatic java.lang.StringSCHEMA_XML_ANALYZER_TOKENIZER
-
Constructor Summary
Constructors Constructor Description SolrSchemaUtil()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> java.lang.Class<? extends T>findClass(java.lang.String cname, java.lang.Class<T> expectedType, java.lang.String... subpackages)This method loads a class either with its FQN or a short-name (solr.class-simplename or class-simplename).protected java.lang.String[]getDefaultPackages()org.apache.solr.schema.FieldTypegetFieldType(org.w3c.dom.Document doc, java.lang.String fieldTypeName, java.lang.String luceneMatch, float schemaVersion, ClassSubPathResourceLoader loader)protected java.lang.StringgetFieldTypeXPathExpressions()org.w3c.dom.DocumentgetSchemaDocument(java.lang.String schemaFile, ClassSubPathResourceLoader classLoader)<T> voidload(org.w3c.dom.NodeList nodes, java.lang.String errRef, java.util.List<T> list, java.lang.Class<T> clazz, java.lang.String luceneMatch, org.apache.lucene.util.ResourceLoader loader)Initializes and each plugin in the list.<T> TnewInstance(java.lang.String cName, java.lang.Class<T> expectedType, java.lang.String[] subPackages, java.lang.Class[] params, java.lang.Object[] args)Create a new instance as per the parameters.
-
-
-
Field Detail
-
SCHEMA_XML_ANALYZER_FILTER
public static final java.lang.String SCHEMA_XML_ANALYZER_FILTER
- See Also:
- Constant Field Values
-
SCHEMA_XML_ANALYZER_TOKENIZER
public static final java.lang.String SCHEMA_XML_ANALYZER_TOKENIZER
- See Also:
- Constant Field Values
-
SCHEMA_XML_ANALYZER_CHAR_FILTER
public static final java.lang.String SCHEMA_XML_ANALYZER_CHAR_FILTER
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSchemaDocument
public org.w3c.dom.Document getSchemaDocument(java.lang.String schemaFile, ClassSubPathResourceLoader classLoader) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException- Throws:
javax.xml.parsers.ParserConfigurationExceptionorg.xml.sax.SAXExceptionjava.io.IOException
-
getFieldType
public org.apache.solr.schema.FieldType getFieldType(org.w3c.dom.Document doc, java.lang.String fieldTypeName, java.lang.String luceneMatch, float schemaVersion, ClassSubPathResourceLoader loader) throws javax.xml.xpath.XPathExpressionException, java.lang.InstantiationException, java.lang.IllegalAccessException- Throws:
javax.xml.xpath.XPathExpressionExceptionjava.lang.InstantiationExceptionjava.lang.IllegalAccessException
-
load
public <T> void load(org.w3c.dom.NodeList nodes, java.lang.String errRef, java.util.List<T> list, java.lang.Class<T> clazz, java.lang.String luceneMatch, org.apache.lucene.util.ResourceLoader loader)Initializes and each plugin in the list. Given a NodeList from XML in the form:<plugins> <plugin name="name1" class="solr.ClassName" > ... </plugin> <plugin name="name2" class="solr.ClassName" > ... </plugin> </plugins>This will attempt to initialize each plugin from the list. Plugins with factories that pull additional information from a SolrResourceLoader or with constructors requiring parameters may not work unless that logic is pulled into this class. As of this writing this has only been done for TokenFilterFactory, TokenizerFactory and CharFilterFactory. This is similar to SolrResourceLoader but contains class specific logic, skips all class registration and does not perform default checking.
- Type Parameters:
T- the generic type of the plugins to load- Parameters:
nodes- the nodelist specifying the plugin.errRef- a string to include with error messageslist- a list to which loaded plugin objects will be addedclazz- a type for which the loaded plugins should have the same class or be a subclass ofluceneMatch- the lucene match version to be supplied to plugins that care about it.loader- the resource loader with which to load additional resources (e.g. stopwords.txt)
-
newInstance
public <T> T newInstance(java.lang.String cName, java.lang.Class<T> expectedType, java.lang.String[] subPackages, java.lang.Class[] params, java.lang.Object[] args)Create a new instance as per the parameters. This serves as a replacement for SolrResourceLoader.newInstance(), but doesn't concern it self with SolrCoreAware, ResourceLoaderAware, or SolrInfoBean.- Type Parameters:
T- The type that will be loaded- Parameters:
cName- The name of the class to loadexpectedType- The type that should be loaded (must be passed due to type erasure)subPackages- The package names to checkparams- The types of the parameters for the constructor to be usedargs- The values for the parameters to the constructor to be used- Returns:
- A freshly constructed instance.
-
findClass
public <T> java.lang.Class<? extends T> findClass(java.lang.String cname, java.lang.Class<T> expectedType, java.lang.String... subpackages)This method loads a class either with its FQN or a short-name (solr.class-simplename or class-simplename). It tries to load the class with the name that is given first and if it fails, it tries all the known solr packages. This method caches the FQN of a short-name in a static map in-order to make subsequent lookups for the same class faster. The caching is done only if the class is loaded by the webapp classloader and it is loaded using a short name.The classloader used is the current thread's class loader (instead of one from a SolrResourceLoader)
- Type Parameters:
T- the generic type that the type returned should extend- Parameters:
cname- The name or the short name of the class.expectedType- The type which must be equal to or a super class of the returned typesubpackages- the packages to be tried if the cname starts with solr.- Returns:
- the loaded class. An exception is thrown if it fails
-
getFieldTypeXPathExpressions
protected java.lang.String getFieldTypeXPathExpressions()
-
getDefaultPackages
protected java.lang.String[] getDefaultPackages()
-
-