org.marketcetera.ors.info
Class RequestInfoImpl

java.lang.Object
  extended by org.marketcetera.ors.info.RequestInfoImpl
All Implemented Interfaces:
ReadInfo, ReadWriteInfo, RequestInfo

public class RequestInfoImpl
extends Object
implements RequestInfo

A store for key-value pairs specific to a request: implementation.

This class is not intended to be thread-safe.

Since:
2.0.0
Version:
$Id: RequestInfoImpl.java 16154 2012-07-14 16:34:05Z colin $
Author:
tlerios@marketcetera.com

Field Summary
 
Fields inherited from interface org.marketcetera.ors.info.RequestInfo
BROKER, BROKER_ID, CURRENT_MESSAGE, FIX_MESSAGE_FACTORY, ORIGINATOR
 
Constructor Summary
RequestInfoImpl(SessionInfo sessionInfo)
          Creates a new store with an automatically assigned name and encompassed by the given session store.
RequestInfoImpl(String name, SessionInfo sessionInfo)
          Creates a new store with the given name and encompassed by the given session store.
 
Method Summary
 boolean contains(String key)
          Checks whether the given key is associated with a value (which may or may not be null) in the receiver's map.
 String getName()
          Returns the receiver's name.
 String getPath()
          Returns the receiver's path name.
 SessionInfo getSessionInfo()
          Returns the receiver's session store.
 Object getValue(String key)
          Returns the value associated with the given key in the receiver's map.
<T> T
getValueIfInstanceOf(String key, Class<T> cls)
          Returns the value associated with the given key in the receiver's map, provided one is set and is either null or an object of the given class.
 Object getValueIfNonNull(String key)
          Returns the value associated with the given key in the receiver's map, provided one is set and is not null.
<T> T
getValueIfNonNullInstanceOf(String key, Class<T> cls)
          Returns the value associated with the given key in the receiver's map, provided one is set and is non-null and an object of the given class.
 Object getValueIfSet(String key)
          Returns the value associated with the given key in the receiver's map, provided one (which may be null) is set.
 void removeValue(String key)
          Removes the value associated with the given key in the receiver's map.
 void removeValueIfSet(String key)
          Removes the value associated with the given key in the receiver's map.
 void setValue(String key, Object value)
          Sets the value associated with the given key to the given value in the receiver's map.
 void setValueIfUnset(String key, Object value)
          Sets the value associated with the given key to the given value in the receiver's map.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.marketcetera.ors.info.ReadWriteInfo
removeValue, removeValueIfSet, setValue, setValueIfUnset
 
Methods inherited from interface org.marketcetera.ors.info.ReadInfo
contains, getName, getPath, getValue, getValueIfInstanceOf, getValueIfNonNull, getValueIfNonNullInstanceOf, getValueIfSet
 

Constructor Detail

RequestInfoImpl

public RequestInfoImpl(SessionInfo sessionInfo)
Creates a new store with an automatically assigned name and encompassed by the given session store.

Parameters:
sessionInfo - The session store.

RequestInfoImpl

public RequestInfoImpl(String name,
                       SessionInfo sessionInfo)
Creates a new store with the given name and encompassed by the given session store.

Parameters:
name - The store name.
sessionInfo - The session store.
Method Detail

getSessionInfo

public SessionInfo getSessionInfo()
Description copied from interface: RequestInfo
Returns the receiver's session store.

Specified by:
getSessionInfo in interface RequestInfo
Returns:
The session store.

getPath

public String getPath()
Description copied from interface: ReadInfo
Returns the receiver's path name.

Specified by:
getPath in interface ReadInfo
Returns:
The path name.

setValue

public void setValue(String key,
                     Object value)
Description copied from interface: ReadWriteInfo
Sets the value associated with the given key to the given value in the receiver's map.

Specified by:
setValue in interface ReadWriteInfo
Parameters:
key - The key.
value - The value. It may be null.

setValueIfUnset

public void setValueIfUnset(String key,
                            Object value)
                     throws InfoException
Description copied from interface: ReadWriteInfo
Sets the value associated with the given key to the given value in the receiver's map.

Specified by:
setValueIfUnset in interface ReadWriteInfo
Parameters:
key - The key.
value - The value. It may be null.
Throws:
InfoException - Thrown if a value is already associated with the given key.

removeValue

public void removeValue(String key)
Description copied from interface: ReadWriteInfo
Removes the value associated with the given key in the receiver's map. It is a no-op if there is no value associated with the given key.

Specified by:
removeValue in interface ReadWriteInfo
Parameters:
key - The key.

removeValueIfSet

public void removeValueIfSet(String key)
                      throws InfoException
Description copied from interface: ReadWriteInfo
Removes the value associated with the given key in the receiver's map.

Specified by:
removeValueIfSet in interface ReadWriteInfo
Parameters:
key - The key.
Throws:
InfoException - Thrown if no value is associated with the given key.

getName

public String getName()
Description copied from interface: ReadInfo
Returns the receiver's name.

Specified by:
getName in interface ReadInfo
Returns:
The name.

contains

public boolean contains(String key)
Description copied from interface: ReadInfo
Checks whether the given key is associated with a value (which may or may not be null) in the receiver's map.

Specified by:
contains in interface ReadInfo
Parameters:
key - The key.
Returns:
Returns true if it is.

getValue

public Object getValue(String key)
Description copied from interface: ReadInfo
Returns the value associated with the given key in the receiver's map.

Specified by:
getValue in interface ReadInfo
Parameters:
key - The key.
Returns:
The value. It may be null, indicating either that the given key is absent or that the null value is associated with that key; use ReadInfo.contains(String) to distinguish these two cases.

getValueIfSet

public Object getValueIfSet(String key)
                     throws InfoException
Description copied from interface: ReadInfo
Returns the value associated with the given key in the receiver's map, provided one (which may be null) is set.

Specified by:
getValueIfSet in interface ReadInfo
Parameters:
key - The key.
Returns:
The value. It may be null.
Throws:
InfoException - Thrown if no value is associated with the given key.

getValueIfNonNull

public Object getValueIfNonNull(String key)
                         throws InfoException
Description copied from interface: ReadInfo
Returns the value associated with the given key in the receiver's map, provided one is set and is not null.

Specified by:
getValueIfNonNull in interface ReadInfo
Parameters:
key - The key.
Returns:
The value.
Throws:
InfoException - Thrown if no or a null value is associated with the given key.

getValueIfInstanceOf

public <T> T getValueIfInstanceOf(String key,
                                  Class<T> cls)
                       throws InfoException
Description copied from interface: ReadInfo
Returns the value associated with the given key in the receiver's map, provided one is set and is either null or an object of the given class.

Specified by:
getValueIfInstanceOf in interface ReadInfo
Parameters:
key - The key.
cls - The class.
Returns:
The value. It may be null.
Throws:
InfoException - Thrown if a no value is associated with the given key, or if the value is non-null and of a class other than the given one.

getValueIfNonNullInstanceOf

public <T> T getValueIfNonNullInstanceOf(String key,
                                         Class<T> cls)
                              throws InfoException
Description copied from interface: ReadInfo
Returns the value associated with the given key in the receiver's map, provided one is set and is non-null and an object of the given class.

Specified by:
getValueIfNonNullInstanceOf in interface ReadInfo
Parameters:
key - The key.
cls - The class.
Returns:
The value.
Throws:
InfoException - Thrown if a no value is associated with the given key, or if the value is null or of a class other than the given one.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.