// Use a predefined list of known Tokenizers
// TODO: publish more tokenizers... (when they are ready/good enough/abstract enough)
public DataTokenizer buildTokenizerInstance( String tokenizerType ) {
        // Use a predefined list of known Tokenizers
        // TODO: publish more tokenizers... (when they are ready/good enough/abstract enough)
        if ("CSVTokenizer".equals( tokenizerType )) {
            return new CSVTokenizerImpl();
        }
        // Use the name of a class and instantiate this tokenizer
        try {
            // use classloader  and search for named class in class path...
            ClassLoader classLoader = this.getClass().getClassLoader();
            Class<?> loadedClass = classLoader.loadClass( tokenizerType );
            // TODO: check if superclass is registered as a DataTokenizer....
            // and check if it implements DataTokenizer
            Class<?>[] interfaces = loadedClass.getInterfaces();
            if (Arrays.asList( interfaces ).contains( DataTokenizer.class )) {
                // create the class using the unparametereized the constructor. 
                return (DataTokenizer) loadedClass.getDeclaredConstructor().newInstance();
            }
        }
        catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
                        | NoSuchMethodException | SecurityException e) {
            e.printStackTrace();
        }
        throw new IllegalArgumentException();
    }
public DataTokenizer buildTokenizerInstance( String tokenizerType ) {
// Use a predefined list of known Tokenizers
// TODO: publish more tokenizers... (when they are ready/good enough/abstract enough)
if ("CSVTokenizer".equals( tokenizerType )) {
return new CSVTokenizerImpl();
public DataTokenizer buildTokenizerInstance( String tokenizerType ) {
// Use a predefined list of known Tokenizers
// TODO: publish more tokenizers... (when they are ready/good enough/abstract enough)
if ("CSVTokenizer".equals( tokenizerType )) {
return new CSVTokenizerImpl();
}
// Use the name of a class and instantiate this tokenizer
try {
// use classloader and search for named class in class path...
ClassLoader classLoader = this.getClass().getClassLoader();
Class<?> loadedClass = classLoader.loadClass( tokenizerType );
// TODO: check if superclass is registered as a DataTokenizer....
// and check if it implements DataTokenizer
public DataTokenizer buildTokenizerInstance( String tokenizerType ) {
// Use a predefined list of known Tokenizers
// TODO: publish more tokenizers... (when they are ready/good enough/abstract enough)
if ("CSVTokenizer".equals( tokenizerType )) {
return new CSVTokenizerImpl();
}
// Use the name of a class and instantiate this tokenizer
try {
// use classloader and search for named class in class path...
ClassLoader classLoader = this.getClass().getClassLoader();
Class<?> loadedClass = classLoader.loadClass( tokenizerType );
// TODO: check if superclass is registered as a DataTokenizer....
// and check if it implements DataTokenizer
Class<?>[] interfaces = loadedClass.getInterfaces();
if (Arrays.asList( interfaces ).contains( DataTokenizer.class )) {
// create the class using the unparametereized the constructor.
return (DataTokenizer) loadedClass.getDeclaredConstructor().newInstance();
}
}
catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException e) {
e.printStackTrace();
}