es.iac.ing.codeso.status.client
Class StatusItemProxyInfo<D extends StatusItemDescriptor,V extends StatusItemValue>

java.lang.Object
  extended by es.iac.ing.codeso.status.client.StatusItemProxyInfo<D,V>

@Immutable
public class StatusItemProxyInfo<D extends StatusItemDescriptor,V extends StatusItemValue>
extends java.lang.Object

The root of a hierarchy of immutable objects that holds the descriptor information associated with a StatusItem subtype.

This class is thread-safe.


Nested Class Summary
static class StatusItemProxyInfo.NotConnectedException
          A checked exception which is thrown if an attempt is made to extract value or descriptor information from the parent class if it was constructed when its associated proxy was in the not-connected state.
 
Field Summary
private  int errorCode
           
private  java.lang.String extraErrorInformation
           
private  boolean isSuccessive
           
private  StatusItemInfo<D,V> statusItemInfo
           
 
Constructor Summary
StatusItemProxyInfo(int errorCode, java.lang.String extraErrorInformation)
          Constructs a new instance based on the supplied prxy connection failur einformation.
StatusItemProxyInfo(StatusItemInfo<D,V> statusItemInfo, boolean isSuccessive)
          Constructs a new instance based on the information contained in the supplied StatusItemInfo object.
 
Method Summary
 D getDescriptor()
          Returns the status item proxy's descriptor information, if available, or throws an exception if otherwise.
 int getErrorCode()
          Returns an integer providing information relating to any connection failure which the status item proxy may have been experiencing when this class instance was constructed.
 java.lang.String getExtraErrorInformation()
          Returns a string providing additional information relating to any connection failure which the status item proxy may have been experiencing when this class instance was constructed.
 long getSequenceNumber()
          Returns the sequence number associated with this class instance.
 D getUncheckedDescriptor()
          Returns the status item proxy's descriptor information, if available, or null if otherwise.
 V getUncheckedValue()
          Returns the status item proxy's value information, if available, or null if otherwise.
 V getValue()
          Returns the status item proxy's value information, if available, or throws an exception if otherwise.
 boolean isConnected()
          Returns a boolean indicating whether the associated status item proxy was connected at the moment when this class instance was constructed.
 boolean isSuccessive()
          Returns a boolean indicating whether the value on the proxy described by this class instance was successive to (that's to say it's sequence number was one greater than) the proxy's previous value.
 java.lang.String toString()
          Returns a string representation of this class instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

statusItemInfo

private StatusItemInfo<D extends StatusItemDescriptor,V extends StatusItemValue> statusItemInfo

isSuccessive

private boolean isSuccessive

errorCode

private int errorCode

extraErrorInformation

private java.lang.String extraErrorInformation
Constructor Detail

StatusItemProxyInfo

public StatusItemProxyInfo(StatusItemInfo<D,V> statusItemInfo,
                           boolean isSuccessive)
Constructs a new instance based on the information contained in the supplied StatusItemInfo object.

Parameters:
statusItemInfo - reference to an object which encapsulates the current state of the remote status item.
isSuccessive - flag which indicates whether the sequence number asscoiated with the current value is one greater than the sequence number associated with the last value.
Throws:
java.lang.NullPointerException - if the supplied parameter was null.

StatusItemProxyInfo

public StatusItemProxyInfo(int errorCode,
                           java.lang.String extraErrorInformation)
Constructs a new instance based on the supplied prxy connection failur einformation.

Parameters:
errorCode - an integer specifying the error code
extraErrorInformation - a String providing additional information regarding the cause of the problem.
Throws:
java.lang.NullPointerException - if the extraErrorInformation parameter was null.
Method Detail

toString

public java.lang.String toString()
Returns a string representation of this class instance.

Overrides:
toString in class java.lang.Object
Returns:
the returned string

isConnected

public boolean isConnected()
Returns a boolean indicating whether the associated status item proxy was connected at the moment when this class instance was constructed.

Returns:
boolean set true if the status item proxy was connected.

getErrorCode

public int getErrorCode()
Returns an integer providing information relating to any connection failure which the status item proxy may have been experiencing when this class instance was constructed.

If there wasn't a connection failure a value of zero will be returned.

To retrieve further information about the cause of failure the returned value may be looked up in the CODESO Error Catalog using the ErrorCatalog.getSummary and ErrorCatalog.getMessage methods.

Returns:
integer containing the error code.

getExtraErrorInformation

public java.lang.String getExtraErrorInformation()
Returns a string providing additional information relating to any connection failure which the status item proxy may have been experiencing when this class instance was constructed.

If there wasn't a connection failure an empty string will be returned.

Returns:
string containing the extra error information.

getUncheckedValue

public V getUncheckedValue()
Returns the status item proxy's value information, if available, or null if otherwise.

The value information will be available if the proxy was connected to its remote status item when the class instance was constructed. This may be tested using the isConnected method.

Under other circumstances this method will return null.

Returns:
the proxy's value information at the moment when this class instance was constructed, or null.
See Also:
isConnected(), getValue()

getValue

public V getValue()
                                   throws StatusItemProxyInfo.NotConnectedException
Returns the status item proxy's value information, if available, or throws an exception if otherwise.

The value information will be available if the proxy was connected to its remote status item when the class instance was constructed. This may be tested using the isConnected method.

Under other circumstances this method will throw the checked NotConnectedException providing details of the cause of connection failure.

Returns:
the proxy's value information at the moment when this class instance was constructed.
Throws:
StatusItemProxyInfo.NotConnectedException - if the proxy was not connected when this method was invoked.
See Also:
isConnected(), getUncheckedValue()

getUncheckedDescriptor

public D getUncheckedDescriptor()
Returns the status item proxy's descriptor information, if available, or null if otherwise.

The descriptor information will be available if the proxy was connected to its remote status item when the class instance was constructed. This may be tested using the isConnected method.

Under other circumstances this method will return a null.

Returns:
the proxy's descriptor information at the moment when this class instance was constructed, or null.
See Also:
isConnected(), getDescriptor()

getDescriptor

public D getDescriptor()
                                             throws StatusItemProxyInfo.NotConnectedException
Returns the status item proxy's descriptor information, if available, or throws an exception if otherwise.

The descriptor information will be available if the proxy was connected to its remote status item when the class instance was constructed. This may be tested using the isConnected method.

Under other circumstances this method will throw the checked NotConnectedException providing details of the cause of connection failure.

Returns:
the proxy's descriptor information at the moment when this class instance was constructed.
Throws:
StatusItemProxyInfo.NotConnectedException - if the proxy was not connected when this method was invoked.
See Also:
isConnected(), getUncheckedDescriptor()

getSequenceNumber

public long getSequenceNumber()
Returns the sequence number associated with this class instance.

If the information is not available due to a connection failure then this method will return a value of zero.

Returns:
long containing the sequence number.

isSuccessive

public boolean isSuccessive()
Returns a boolean indicating whether the value on the proxy described by this class instance was successive to (that's to say it's sequence number was one greater than) the proxy's previous value.

This facility may be useful for detecting temporary outages of communication.

Returns:
boolean containing the result