Logo Search packages:      
Sourcecode: henplus version File versions  Download package

Iterator henplus::commands::DumpCommand::complete ( CommandDispatcher  disp,
String  partialCommand,
String  lastWord 
) [inline]

complete the table name.

Reimplemented from henplus::AbstractCommand.

Definition at line 1114 of file DumpCommand.java.

References henplus::commands::ListUserObjectsCommand::columnsFor(), henplus::commands::ListUserObjectsCommand::completeTableName(), and henplus::view::util::NameCompleter::getAlternatives().

    {
      StringTokenizer st = new StringTokenizer(partialCommand);
      String cmd = (String) st.nextElement();
      int argc = st.countTokens();
      if (lastWord.length() > 0) {
          argc--;
      }
      
      if ("dump-conditional".equals(cmd)) {
          if (argc == 0) {
            return new FileCompletionIterator(partialCommand, lastWord);
          }
          else if (argc == 1) {
            if (lastWord.startsWith("\"")) {
                lastWord = lastWord.substring(1);
            }
            return _tableCompleter.completeTableName(HenPlus.getInstance().getCurrentSession(), lastWord);
          }
          else if (argc > 1) {
            st.nextElement(); // discard filename.
            String table = (String) st.nextElement();
            Collection columns = _tableCompleter.columnsFor(table);
            NameCompleter compl = new NameCompleter(columns);
            return compl.getAlternatives(lastWord);
          }
      }
      else if ("dump-out".equals(cmd)) {
          // this is true for dump-out und verify-dump
          if (argc == 0) {
            return new FileCompletionIterator(partialCommand, lastWord);
          }
          if (argc > 0) {
            if (lastWord.startsWith("\"")) {
                lastWord = lastWord.substring(1);
            }
            final HashSet  alreadyGiven = new HashSet();
            /*
             * do not complete the tables we already gave on the
             * commandline.
             */
            while (st.hasMoreElements()) {
                alreadyGiven.add((String) st.nextElement());
            }
            final Iterator it = _tableCompleter.completeTableName(HenPlus.getInstance().getCurrentSession(), lastWord);
            return new Iterator() {
                  String table = null;
                  public boolean hasNext() {
                      while (it.hasNext()) {
                        table = (String) it.next();
                        if (alreadyGiven.contains(table)) {
                            continue;
                        }
                        return true;
                      }
                      return false;
                  }
                  public Object  next() { return table; }
                  public void remove() { 
                      throw new UnsupportedOperationException("no!");
                  }
                };
          }
      }
      else {
          if (argc == 0) {
            return new FileCompletionIterator(partialCommand, lastWord);
          }
      }
      return null;
    }


Generated by  Doxygen 1.6.0   Back to index