--- /dev/null 2015-04-26 06:51:08.003313989 -0700 +++ new/jdk/src/jdk.jline/share/classes/jdk/internal/jline/console/history/History.java 2015-06-18 03:04:45.866672591 -0700 @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2002-2012, the original author or authors. + * + * This software is distributable under the BSD license. See the terms of the + * BSD license in the documentation provided with this software. + * + * http://www.opensource.org/licenses/bsd-license.php + */ +package jdk.internal.jline.console.history; + +import java.util.Iterator; +import java.util.ListIterator; + +/** + * Console history. + * + * @author Marc Prud'hommeaux + * @author Jason Dillon + * @since 2.3 + */ +public interface History + extends Iterable +{ + int size(); + + boolean isEmpty(); + + int index(); + + void clear(); + + CharSequence get(int index); + + void add(CharSequence line); + + /** + * Set the history item at the given index to the given CharSequence. + * + * @param index the index of the history offset + * @param item the new item + * @since 2.7 + */ + void set(int index, CharSequence item); + + /** + * Remove the history element at the given index. + * + * @param i the index of the element to remove + * @return the removed element + * @since 2.7 + */ + CharSequence remove(int i); + + /** + * Remove the first element from history. + * + * @return the removed element + * @since 2.7 + */ + CharSequence removeFirst(); + + /** + * Remove the last element from history + * + * @return the removed element + * @since 2.7 + */ + CharSequence removeLast(); + + void replace(CharSequence item); + + // + // Entries + // + + interface Entry + { + int index(); + + CharSequence value(); + } + + ListIterator entries(int index); + + ListIterator entries(); + + Iterator iterator(); + + // + // Navigation + // + + CharSequence current(); + + boolean previous(); + + boolean next(); + + boolean moveToFirst(); + + boolean moveToLast(); + + boolean moveTo(int index); + + void moveToEnd(); +}