org.knime.core.node.util
Class StringHistory

java.lang.Object
  extended by org.knime.core.node.util.StringHistory

public final class StringHistory
extends Object

Utility class that keeps a list of recently used String, mostly used in File-Reader and Writer that keep track of a list of recently accessed file names. This class also makes sure that the list is made persistent and saved to disk when the application closes. The list is read again from file on startup.

Usage in a short way: Determine a (possibly unique) ID for your history to use (I assume that there are not that many?) and get a history object by invoking StringHistory.getInstance(yourID). You can add recently used String to this object by invoking the add(String) method and get a list of String from the getHistory() method which will return the history in the order the add method on the String objects has been called with the last element added being the first element in the history result.

Author:
Bernd Wiswedel, University of Konstanz

Method Summary
 void add(String str)
          Adds a new String to the history.
 String[] getHistory()
          Get the history in an array with the most recently added element first.
static StringHistory getInstance(String id)
          Get a history for an ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static StringHistory getInstance(String id)
Get a history for an ID. If that ID doesn't yet exist, a new object is created.

Parameters:
id - The ID of interest
Returns:
The History for this id. If this id has been used in a previous run, the history is loaded from file

add

public void add(String str)
Adds a new String to the history. If this string alread exists in the history, it is marked as most recently added and will be returned first on a immediate call of getHistory()

Parameters:
str - The string to add.
Throws:
NullPointerException - If argument is null.

getHistory

public String[] getHistory()
Get the history in an array with the most recently added element first.

Returns:
The history.


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.