this 'Priv' wrapper trick isn't portable (seems to work on sun-only

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1033074 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2010-11-09 16:34:34 +00:00
parent 48cfdf0738
commit e3232c3289
1 changed files with 38 additions and 43 deletions

View File

@ -55,7 +55,7 @@ public final class FuzzyTermsEnum extends TermsEnum {
attributes().addAttribute(MultiTermQuery.BoostAttribute.class); attributes().addAttribute(MultiTermQuery.BoostAttribute.class);
private final MultiTermQuery.MaxNonCompetitiveBoostAttribute maxBoostAtt; private final MultiTermQuery.MaxNonCompetitiveBoostAttribute maxBoostAtt;
private final Priv.LevenshteinAutomataAttribute dfaAtt; private final LevenshteinAutomataAttribute dfaAtt;
private float bottom; private float bottom;
private BytesRef bottomTerm; private BytesRef bottomTerm;
@ -110,7 +110,7 @@ public final class FuzzyTermsEnum extends TermsEnum {
for (int cp, i = 0, j = 0; i < utf16.length(); i += Character.charCount(cp)) for (int cp, i = 0, j = 0; i < utf16.length(); i += Character.charCount(cp))
termText[j++] = cp = utf16.codePointAt(i); termText[j++] = cp = utf16.codePointAt(i);
this.termLength = termText.length; this.termLength = termText.length;
this.dfaAtt = atts.addAttribute(Priv.LevenshteinAutomataAttribute.class); this.dfaAtt = atts.addAttribute(LevenshteinAutomataAttribute.class);
//The prefix could be longer than the word. //The prefix could be longer than the word.
//It's kind of silly though. It means we must match the entire word. //It's kind of silly though. It means we must match the entire word.
@ -552,49 +552,44 @@ public final class FuzzyTermsEnum extends TermsEnum {
return scale_factor; return scale_factor;
} }
// Wrapper class to hide the attribute from outside! /** @lucene.internal */
private static final class Priv { public static interface LevenshteinAutomataAttribute extends Attribute {
public List<ByteRunAutomaton> automata();
/** @lucene.internal */ }
public static interface LevenshteinAutomataAttribute extends Attribute {
public List<ByteRunAutomaton> automata();
}
/** @lucene.internal */ /** @lucene.internal */
public static final class LevenshteinAutomataAttributeImpl extends AttributeImpl implements LevenshteinAutomataAttribute { public static final class LevenshteinAutomataAttributeImpl extends AttributeImpl implements LevenshteinAutomataAttribute {
private final List<ByteRunAutomaton> automata = new ArrayList<ByteRunAutomaton>(); private final List<ByteRunAutomaton> automata = new ArrayList<ByteRunAutomaton>();
public List<ByteRunAutomaton> automata() { public List<ByteRunAutomaton> automata() {
return automata; return automata;
} }
@Override @Override
public void clear() { public void clear() {
automata.clear(); automata.clear();
} }
@Override @Override
public int hashCode() { public int hashCode() {
return automata.hashCode(); return automata.hashCode();
} }
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (this == other) if (this == other)
return true; return true;
if (!(other instanceof LevenshteinAutomataAttributeImpl)) if (!(other instanceof LevenshteinAutomataAttributeImpl))
return false; return false;
return automata.equals(((LevenshteinAutomataAttributeImpl) other).automata); return automata.equals(((LevenshteinAutomataAttributeImpl) other).automata);
} }
@Override @Override
public void copyTo(AttributeImpl target) { public void copyTo(AttributeImpl target) {
final List<ByteRunAutomaton> targetAutomata = final List<ByteRunAutomaton> targetAutomata =
((LevenshteinAutomataAttribute) target).automata(); ((LevenshteinAutomataAttribute) target).automata();
targetAutomata.clear(); targetAutomata.clear();
targetAutomata.addAll(automata); targetAutomata.addAll(automata);
}
} }
} }
} }