com.mucommander.shell
Class ShellHistoryManager

java.lang.Object
  extended by com.mucommander.shell.ShellHistoryManager

public class ShellHistoryManager
extends java.lang.Object

Used to manage shell history.

Using this class is fairly basic: you can add elements to the shell history through add(String) and browse it through getHistoryIterator().

Author:
Nicolas Rinaudo

Method Summary
static void add(java.lang.String command)
          Adds the specified command to shell history.
static void addListener(ShellHistoryListener listener)
          Registers a listener to changes in the shell history.
static void clear()
          Completely empties the shell history.
static AbstractFile getHistoryFile()
          Returns the path to the shell history file.
static java.util.Iterator getHistoryIterator()
          Returns a non thread-safe iterator on the history.
static void loadHistory()
          Loads the shell history.
static void setHistoryFile(AbstractFile file)
          Sets the path of the shell history file.
static void setHistoryFile(java.io.File file)
          Sets the path of the shell history file.
static void setHistoryFile(java.lang.String path)
          Sets the path of the shell history file.
static void writeHistory()
          Writes the shell history to hard drive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addListener

public static void addListener(ShellHistoryListener listener)
Registers a listener to changes in the shell history.

Parameters:
listener - listener to register.

clear

public static void clear()
Completely empties the shell history.


getHistoryIterator

public static java.util.Iterator getHistoryIterator()
Returns a non thread-safe iterator on the history.

Returns:
an iterator on the history.

add

public static void add(java.lang.String command)
Adds the specified command to shell history.

Parameters:
command - command to add to the shell history.

setHistoryFile

public static void setHistoryFile(java.lang.String path)
                           throws java.io.FileNotFoundException
Sets the path of the shell history file.

Parameters:
path - where to load the shell history from.
Throws:
java.io.FileNotFoundException - if path is not accessible.
See Also:
getHistoryFile(), setHistoryFile(File), setHistoryFile(AbstractFile)

setHistoryFile

public static void setHistoryFile(java.io.File file)
                           throws java.io.FileNotFoundException
Sets the path of the shell history file.

Parameters:
file - where to load the shell history from.
Throws:
java.io.FileNotFoundException - if path is not accessible.
See Also:
getHistoryFile(), setHistoryFile(AbstractFile), setHistoryFile(String)

setHistoryFile

public static void setHistoryFile(AbstractFile file)
                           throws java.io.FileNotFoundException
Sets the path of the shell history file.

Parameters:
file - where to load the shell history from.
Throws:
java.io.FileNotFoundException - if path is not accessible.
See Also:
getHistoryFile(), setHistoryFile(File), setHistoryFile(String)

getHistoryFile

public static AbstractFile getHistoryFile()
                                   throws java.io.IOException
Returns the path to the shell history file.

This method cannot guarantee the file's existence, and it's up to the caller to deal with the fact that the user might not actually have created a history file yet.

This method's return value can be modified through setHistoryFile(String). If this wasn't called, the default path will be used: DEFAULT_HISTORY_FILE_NAME in the preferences folder.

Returns:
the path to the shell history file.
Throws:
java.io.IOException - if an error occured while locating the default shell history file.
See Also:
setHistoryFile(File), setHistoryFile(String), setHistoryFile(AbstractFile)

writeHistory

public static void writeHistory()
                         throws java.io.IOException
Writes the shell history to hard drive.

Throws:
java.io.IOException - if an I/O error occurs.

loadHistory

public static void loadHistory()
                        throws java.lang.Exception
Loads the shell history.

Throws:
java.lang.Exception - if an error occurs.


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard