|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.gremwell.history.History
public class History
History class implements persistent and transient input history storage for use with autocomplete text components.
It keeps a list of strings that were entered by the user and allows to retrieve a subset based on a substring match. The input history items are weighted according to the number of times they were used. This allows to return the input history to the user in order of relevance - most often used items first.
An application can maintain multiple input histories. For example, you may want a different history for the street name and for postal code. To distinguish between different histories, this class uses historyKey property. Call setKey("street name") after instantiating a history to create a separate history for street names.
History uses Java preferences to store the input history between application invocations. If you don't want the history to persist, use setKey(null).
| Constructor Summary | |
|---|---|
History()
Creates a new persistent history with the key "Default". |
|
History(java.lang.String key)
Creates a new history with the specified history key. |
|
| Method Summary | |
|---|---|
void |
addItem(java.lang.String item)
Adds item to history. |
void |
clear()
Clears the history. |
java.util.List<java.lang.String> |
getAll()
Returns all items in the history, most used first |
java.util.List<java.lang.String> |
getFiltered(java.lang.String filter,
boolean fromStart)
Returns the history filtered by substring, sorted by usage |
java.lang.String |
getFilteredItem(int n,
java.lang.String filter,
boolean fromStart)
Returns the nth most used item from the filtered history. |
java.lang.String |
getItem(int n)
Returns one item in history, nth most used. |
java.lang.String |
getKey()
Returns history key for this history. |
void |
setKey(java.lang.String key)
Sets the history key for this history. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public History()
public History(java.lang.String key)
key - - History key| Method Detail |
|---|
public java.lang.String getKey()
public void setKey(java.lang.String key)
key - History keypublic java.util.List<java.lang.String> getAll()
public java.lang.String getItem(int n)
n -
public java.util.List<java.lang.String> getFiltered(java.lang.String filter,
boolean fromStart)
filter - String to match history items. Match is case-sensitivefromStart - If fromStart is true, the filter is matched to the start
of the history items, using item.startsWith(filter), otherwise it is
matched anywhere in the item, using item.contains(filter)
public java.lang.String getFilteredItem(int n,
java.lang.String filter,
boolean fromStart)
n - Which item to return.filter - String to match history items. Match is case-sensitivefromStart - If fromStart is true, the filter is matched to the start
of the history items, using item.startsWith(filter), otherwise it is
matched anywhere in the item, using item.contains(filter)
public void addItem(java.lang.String item)
item -
public void clear()
throws java.util.prefs.BackingStoreException
java.util.prefs.BackingStoreException
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||