@Override public Command next() { if (!hasNext()) throw new NoSuchElementException(); if (fCommand == null) return fIterator.next(); if (!fIterator.hasNext()) { final Command tempCommand= fCommand; fCommand= null; return tempCommand; } final Command command= fIterator.next(); final int compareValue= command.compareTo(fCommand); if ((compareValue < 0) ^ !fForward) { return command; } else if ((compareValue > 0) ^ !fForward) { final Command tempCommand= fCommand; fCommand= command; return tempCommand; } else { throw new IllegalArgumentException(); } }
for (final Iterator<Command> iterator= new CommandIterator(fCommands, originalCommand, false); iterator.hasNext(); ) iterator.next().execute(document);
for (final Iterator<Command> iterator= new CommandIterator(fCommands, originalCommand, false); iterator.hasNext(); ) iterator.next().execute(document);
@Override public Command next() { if (!hasNext()) throw new NoSuchElementException(); if (fCommand == null) return fIterator.next(); if (!fIterator.hasNext()) { final Command tempCommand= fCommand; fCommand= null; return tempCommand; } final Command command= fIterator.next(); final int compareValue= command.compareTo(fCommand); if ((compareValue < 0) ^ !fForward) { return command; } else if ((compareValue > 0) ^ !fForward) { final Command tempCommand= fCommand; fCommand= command; return tempCommand; } else { throw new IllegalArgumentException(); } }
/** * Returns an iterator over the commands in ascending position order. * The iterator includes the original document command. * Commands cannot be removed. * * @return returns the command iterator */ public Iterator<Command> getCommandIterator() { Command command= new Command(offset, length, text, owner); return new CommandIterator(fCommands, command, true); }
/** * Returns an iterator over the commands in ascending position order. * The iterator includes the original document command. * Commands cannot be removed. * * @return returns the command iterator */ public Iterator<Command> getCommandIterator() { Command command= new Command(offset, length, text, owner); return new CommandIterator(fCommands, command, true); }