org.globus.cog.gridshell.model
Class ShellHistoryImpl

java.lang.Object
  extended byorg.globus.cog.gridshell.model.ShellHistoryImpl
All Implemented Interfaces:
Serializable, ShellHistory

public class ShellHistoryImpl
extends Object
implements Serializable, ShellHistory

See Also:
Serialized Form

Field Summary
static int DEFAULT_HISTORY_SIZE
           
 
Constructor Summary
ShellHistoryImpl()
           
ShellHistoryImpl(int historySize)
           
 
Method Summary
 void appendHistory(Object newHistory)
          If history is larger than 0, then it appends newHistory to the history which may override values
 boolean decPeekIndex()
          Will decrement the peek index which ranges from -historySize to historySize
 Object get(int i)
          returns if(i>0) the ith command since the shell is active.
 int getCount()
          Gets the number of items in the history
 Object[] getHistory()
          returns the history as Object[]
 int getHistorySize()
          Gets the max items for the history
 Object getLast()
          Gets the last history value
 boolean incPeekIndex()
          Will increment the peek index which ranges from -historySize to historySize
static void main(String[] args)
          main is used to test this class
 Object peek()
          Looks at Object get(peekIndex) if peekIndex is 0 returns null
 void setHistory(Object[] value)
          Set the history to a Object[]
 void setHistoryAt(int i, Object value)
          Set the history value at index i
 void setHistorySize(int value)
          Resizes the history and preserves as many history objects as permitted by the new history size
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_HISTORY_SIZE

public static final int DEFAULT_HISTORY_SIZE
See Also:
Constant Field Values
Constructor Detail

ShellHistoryImpl

public ShellHistoryImpl()

ShellHistoryImpl

public ShellHistoryImpl(int historySize)
Method Detail

appendHistory

public void appendHistory(Object newHistory)
Description copied from interface: ShellHistory
If history is larger than 0, then it appends newHistory to the history which may override values

Specified by:
appendHistory in interface ShellHistory
Parameters:
newHistory - - the history object to append

get

public Object get(int i)
           throws ShellHistoryException
Description copied from interface: ShellHistory
returns if(i>0) the ith command since the shell is active. if(i <0) it is the ith command since the last submited command else returns null

Specified by:
get in interface ShellHistory
Parameters:
i - - specifies which command to return
Returns:
- the ith command since the shell is active
Throws:
ShellHistoryException

getCount

public int getCount()
Description copied from interface: ShellHistory
Gets the number of items in the history

Specified by:
getCount in interface ShellHistory
Returns:

getLast

public Object getLast()
               throws ShellHistoryException
Description copied from interface: ShellHistory
Gets the last history value

Specified by:
getLast in interface ShellHistory
Returns:
@throws ShellHistoryException - if now items in history
Throws:
ShellHistoryException

setHistoryAt

public void setHistoryAt(int i,
                         Object value)
                  throws ShellHistoryException
Description copied from interface: ShellHistory
Set the history value at index i

Specified by:
setHistoryAt in interface ShellHistory
Parameters:
i - - index to set the history at
value - - value to set
Throws:
ShellHistoryException - - if index is out of bounds

setHistorySize

public void setHistorySize(int value)
                    throws ShellHistoryException
Description copied from interface: ShellHistory
Resizes the history and preserves as many history objects as permitted by the new history size

Specified by:
setHistorySize in interface ShellHistory
Parameters:
value -
Throws:
ShellHistoryException

getHistorySize

public int getHistorySize()
Description copied from interface: ShellHistory
Gets the max items for the history

Specified by:
getHistorySize in interface ShellHistory
Returns:

toString

public String toString()

peek

public Object peek()
Description copied from interface: ShellHistory
Looks at Object get(peekIndex) if peekIndex is 0 returns null

Specified by:
peek in interface ShellHistory
Returns:

incPeekIndex

public boolean incPeekIndex()
Description copied from interface: ShellHistory
Will increment the peek index which ranges from -historySize to historySize

Specified by:
incPeekIndex in interface ShellHistory
Returns:
- if it fails to increment (because peek index goes out of range) returns false, else true

decPeekIndex

public boolean decPeekIndex()
Description copied from interface: ShellHistory
Will decrement the peek index which ranges from -historySize to historySize

Specified by:
decPeekIndex in interface ShellHistory
Returns:
- if it fails to decrement (because peek index goes out of range) returns false, else true

getHistory

public Object[] getHistory()
Description copied from interface: ShellHistory
returns the history as Object[]

Specified by:
getHistory in interface ShellHistory
Returns:

setHistory

public void setHistory(Object[] value)
Description copied from interface: ShellHistory
Set the history to a Object[]

Specified by:
setHistory in interface ShellHistory
Parameters:
value -

main

public static void main(String[] args)
                 throws ShellHistoryException
main is used to test this class

Parameters:
args - String[]
Throws:
ShellHistoryException