The story is quite short and it starts with the few following excerpts from Lucene's classes:
Analyzer:
public abstract class Analyzer implements Closeable {
(...)
public static class TokenStreamComponents { ... }
(...)
}
AnalyzerWrapper:
public abstract class AnalyzerWrapper extends Analyzer {
(...)
@Override
protected final TokenStreamComponents createComponents(String fieldName, Reader aReader) {
return wrapComponents(fieldName, getWrappedAnalyzer(fieldName).createComponents(fieldName, aReader));
}
(...)
}
Now inside a Grails application I define my own class, MyAnalyzer.groovy
class MyAnalyzer extends AnalyzerWrapper {
private final PerFieldAnalyzerWrapper perFieldAnalyzerWrapper
public MyAnalyzer() { ... }
@Override
protected Analyzer getWrappedAnalyzer(String fieldName) {
perFieldAnalyzerWrapper.getWrappedAnalyzer(fieldName)
}
@Override
protected TokenStreamComponents wrapComponents(String fieldName, TokenStreamComponents tokenStreamComponents) {
perFieldAnalyzerWrapper.wrapComponents(fieldName, tokenStreamComponents)
}
}
And when I try to run/compile the application, I get:
[groovyc] Compiling 2 source files to E:\somewhere\...\target\classes
[groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
[groovyc] E:\somewhere\...\MyAnalyzer.groovy: 31: unable to resolve class TokenStreamComponents
[groovyc] @ line 31, column 5.
[groovyc] @Override
[groovyc] ^
[groovyc]
[groovyc] 1 error
However, if I change both occurences of TokenStreamComponents
to Analyzer.TokenStreamComponents
in the definition of the overridden method in MyAnalyzer
, the class compiles fine.
Does anyone know if there is some logical reason behind such behavior, caused e.g. by the way Groovy or Grails behaves, or am I just missing something here?
Just add the line import Analyzer.*; to the import section of your Program. ! let me know if it solved.!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With