LUCENE-3842: refactor: don't make spooky State methods public

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1391703 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2012-09-29 00:15:43 +00:00
parent e2540f1a04
commit 93cc814108
2 changed files with 15 additions and 19 deletions

View File

@ -62,7 +62,7 @@ public class State implements Comparable<State> {
/**
* Resets transition set.
*/
public final void resetTransitions() {
final void resetTransitions() {
transitionsArray = new Transition[0];
numTransitions = 0;
}
@ -169,7 +169,7 @@ public class State implements Comparable<State> {
* {@code to} state. This is implemented by copying all
* transitions from {@code to} to this state, and if {@code
* to} is an accept state then set accept for this state. */
public void addEpsilon(State to) {
void addEpsilon(State to) {
if (to.accept) accept = true;
for (Transition t : to.getTransitions())
addTransition(t);

View File

@ -224,6 +224,15 @@ public class AnalyzingSuggester extends Lookup {
return fst == null ? 0 : fst.sizeInBytes();
}
private void copyDestTransitions(State from, State to, List<Transition> transitions) {
if (to.isAccept()) {
from.setAccept(true);
}
for(Transition t : to.getTransitions()) {
transitions.add(t);
}
}
// Replaces SEP with epsilon or remaps them if
// we were asked to preserve them:
private void replaceSep(Automaton a) {
@ -240,15 +249,10 @@ public class AnalyzingSuggester extends Lookup {
if (t.getMin() == TokenStreamToAutomaton.POS_SEP) {
if (preserveSep) {
// Remap to SEP_LABEL:
t = new Transition(SEP_LABEL, t.getDest());
newTransitions.add(new Transition(SEP_LABEL, t.getDest()));
} else {
// NOTE: sort of weird because this will grow
// the transition array we are iterating over,
// but because we are going in reverse topo sort
// it will not add any SEP/HOLE transitions:
state.addEpsilon(t.getDest());
copyDestTransitions(state, t.getDest(), newTransitions);
a.setDeterministic(false);
t = null;
}
} else if (t.getMin() == TokenStreamToAutomaton.HOLE) {
@ -259,20 +263,12 @@ public class AnalyzingSuggester extends Lookup {
// that's somehow a problem we can always map HOLE
// to a dedicated byte (and escape it in the
// input).
// NOTE: sort of weird because this will grow
// the transition array we are iterating over,
// but because we are going in reverse topo sort
// it will not add any SEP/HOLE transitions:
state.addEpsilon(t.getDest());
copyDestTransitions(state, t.getDest(), newTransitions);
a.setDeterministic(false);
t = null;
}
if (t != null) {
} else {
newTransitions.add(t);
}
}
state.resetTransitions();
state.setTransitions(newTransitions.toArray(new Transition[newTransitions.size()]));
}
}