org.mockftpserver.core.command
Class InvocationRecord

java.lang.Object
  extended by org.mockftpserver.core.command.InvocationRecord

public class InvocationRecord
extends Object

Represents information about a single FTP Command invocation. Manages and provides access to the Command, the host address (InetAddress) of the client that submitted the Command and the timestamp of the Command submission.

This class also supports storing zero or more arbitrary mappings of key to value, where key is a String and value is any Object. Convenience methods are provided that enable retrieving type-specific data by its key. The data stored in an InvocationRecord is CommandHandler-specific.

The lock() method makes an instance of this class immutable. After an instance is locked, calling the set(String, Object) method will throw an AssertFailedException.

Version:
$Revision: 193 $ - $Date: 2008-12-07 08:07:10 -0500 (Sun, 07 Dec 2008) $
Author:
Chris Mair

Constructor Summary
InvocationRecord(Command command, InetAddress clientHost)
          Create a new instance
 
Method Summary
 boolean containsKey(String key)
          Returns true if this object contains a mapping for the specified key.
 InetAddress getClientHost()
           
 Command getCommand()
           
 Object getObject(String key)
          Get the Object value associated with the specified key.
 String getString(String key)
          Get the String value associated with the specified key.
 Date getTime()
           
 boolean isLocked()
          Return true if this object has been locked, false otherwise.
 Set keySet()
          Returns a Set view of the keys for the data stored in this object.
 void lock()
          Lock this instance, making it immutable.
 void set(String key, Object value)
          Store the value for the specified key.
 String toString()
          Return the String representation of this object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InvocationRecord

public InvocationRecord(Command command,
                        InetAddress clientHost)
Create a new instance

Parameters:
command - - the Command
clientHost - - the client host
Method Detail

lock

public void lock()
Lock this instance, making it immutable. After an instance is locked, calling the set(String, Object) method will throw an AssertFailedException.


isLocked

public boolean isLocked()
Return true if this object has been locked, false otherwise. See lock().

Returns:
true if this object has been locked, false otherwise.

getClientHost

public InetAddress getClientHost()
Returns:
the client host that submitted the command, as an InetAddress

getCommand

public Command getCommand()
Returns:
the Command

getTime

public Date getTime()
Returns:
the time that the command was processed; this may differ slightly from when the command was received.

set

public void set(String key,
                Object value)
Store the value for the specified key. If this object already contained a mapping for this key, the old value is replaced by the specified value. This method throws an AssertFailedException if this object has been locked. See lock().

Parameters:
key - - the key; must not be null
value - - the value to store for the specified key
Throws:
AssertFailedException - - if the key is null or this object has been locked.

containsKey

public boolean containsKey(String key)
Returns true if this object contains a mapping for the specified key.

Parameters:
key - - the key; must not be null
Returns:
true if there is a mapping for the key
Throws:
AssertFailedException - - if the key is null

keySet

public Set keySet()
Returns a Set view of the keys for the data stored in this object. Changes to the returned Set have no effect on the data stored within this object .

Returns:
the Set of keys for the data stored within this object

getString

public String getString(String key)
Get the String value associated with the specified key. Returns null if there is no mapping for this key. A return value of null does not necessarily indicate that this object contains no mapping for the key; it's also possible that the value was explicitly set to null for the key. The containsKey operation may be used to distinguish these two cases.

Parameters:
key - - the key; must not be null
Returns:
the String data stored at the specified key; may be null
Throws:
ClassCastException - - if the object for the specified key is not a String
AssertFailedException - - if the key is null

getObject

public Object getObject(String key)
Get the Object value associated with the specified key. Returns null if there is no mapping for this key. A return value of null does not necessarily indicate that this object contains no mapping for the key; it's also possible that the value was explicitly set to null for the key. The containsKey operation may be used to distinguish these two cases.

Parameters:
key - - the key; must not be null
Returns:
the data stored at the specified key, as an Object; may be null
Throws:
AssertFailedException - - if the key is null

toString

public String toString()
Return the String representation of this object

Overrides:
toString in class Object
See Also:
Object.toString()


Copyright © 2014. All rights reserved.