final HashSet<String> alreadyGiven = new HashSet<String>();
while (st.hasMoreElements()) {
alreadyGiven.add(st.nextToken());
}
final ListUserObjectsCommand objectList = HenPlus.getInstance().getObjectLister();
final Iterator<String> iter = objectList.completeTableName(session, lastWord);
return new Iterator<String>() {
String table = null;
@Override
public boolean hasNext() {
while (iter.hasNext()) {
table = iter.next();
if (alreadyGiven.contains(table) && !lastWord.equals(table)) {
continue;
}
return true;
}
return false;
}
@Override
public String next() {
return table;
}
@Override
public void remove() {
throw new UnsupportedOperationException("no!");
}
};
} else if (partialCommand.indexOf(OPTION_SINGLE_DB) == -1 && argIndex == 0) {
// !singledb && process the first session
return HenPlus.getInstance().getSessionManager().completeSessionName(lastWord);
} else if (partialCommand.indexOf(OPTION_SINGLE_DB) == -1 && argIndex == 1) {
// !singledb && process the second session
final String firstSession = st.nextToken();
return getSecondSessionCompleter(lastWord, firstSession);
} else if (argIndex > 1) {
// process tables
final SessionManager sessionManager = HenPlus.getInstance().getSessionManager();
final SQLSession first = sessionManager.getSessionByName(st.nextToken());
final SQLSession second = sessionManager.getSessionByName(st.nextToken());
final HashSet<String> alreadyGiven = new HashSet<String>();
while (st.hasMoreElements()) {
alreadyGiven.add(st.nextToken());
}
final ListUserObjectsCommand objectList = HenPlus.getInstance().getObjectLister();
final Iterator<String> firstIter = objectList.completeTableName(first, lastWord);
final Iterator<String> secondIter = objectList.completeTableName(second, lastWord);
final Iterator<String> intersectionIter = getIntersection(firstIter, secondIter);
return new Iterator<String>() {
String table = null;