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

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

complete session names. But not the session we are currently in, since we don't want to switch to our own session, right ?

Definition at line 180 of file ConnectCommand.java.

References henplus::AbstractCommand::argumentCount(), and currentSessionName.

    {
      if (partialCommand.startsWith("connect")) {
          if (argumentCount(partialCommand) >
            ("".equals(lastWord) ? 1 : 2)) {
            return null;
          }
          final Iterator it = knownUrls.tailSet(lastWord).iterator();
          return new Iterator() {
                String url = null;
                public boolean hasNext() {
                  while (it.hasNext()) {
                      url = (String) it.next();
                      if (!url.startsWith(lastWord)) {
                        return false;
                      }
                      return true;
                  }
                  return false;
                }
                public Object  next() { return url; }
                public void remove() { 
                  throw new UnsupportedOperationException("no!");
                }
            };
      }
      
      else if (partialCommand.startsWith("switch")) {
          if (argumentCount(partialCommand) >
            ("".equals(lastWord) ? 1 : 2)) {
            return null;
          }
          final Iterator it = _sessionManager.getSessionNames().tailSet(lastWord).iterator();
          return new Iterator() {
                String sessionName = null;
                public boolean hasNext() {
                  while (it.hasNext()) {
                      sessionName = (String) it.next();
                      if (!sessionName.startsWith(lastWord)) {
                        return false;
                      }
                      if (sessionName.equals(currentSessionName)) {
                        continue;
                      }
                      return true;
                  }
                  return false;
                }
                public Object  next() { return sessionName; }
                public void remove() { 
                  throw new UnsupportedOperationException("no!");
                }
            };
      }
      return null; 
    }


Generated by  Doxygen 1.6.0   Back to index