org.licas

## Class ServiceLevel

- java.lang.Object
- - org.licas.ServiceLevel

-     public class ServiceLevel
      extends java.lang.Object

  This is an implementation of the default service level agreement description. This default class always returns a true result to any contract negotiation.
  Author:
    Kieran Greer

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Contract` | `contract` This service level's contract
    `protected ContractManager` | `contractHandler` The parent contract handler
    `protected java.lang.String` | `serviceLevel` The name of the service level
    `protected java.util.HashMap<java.lang.String,ServiceLevel>` | `serviceNegotiations` A list of the current service negotiations
    `protected long` | `timeStamp` The time that the current contract was proposed or created

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServiceLevel(java.lang.String theServiceLevel, ContractManager theContractHandler, Contract theContract)` Create a new instance of ServiceLevel.
    `ServiceLevel(java.lang.String theServiceLevel, ContractManager theContractHandler, Contract theContract, long thisTimeInterval)` Create a new instance of ServiceLevel.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `contractIsOK(Contract theContract)` Return true if the contract suggested by the client is OK.
    `Contract` | `contractReply(java.lang.String clientID, Contract theContract)` Process the negotiation contract suggested by the client.
    `java.lang.String` | `getServiceLevel()` Get the name of the service level.
    `long` | `getTimeStamp()` Get the time the message was logged at.
    `protected static Contract` | `processThisContract(ServiceLevel currentContract, Contract proposedContract)` This can be used as a sort of generic processor of contract.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### timeStamp

          protected long timeStamp

      The time that the current contract was proposed or created

    - #### serviceLevel

          protected java.lang.String serviceLevel

      The name of the service level

    - #### serviceNegotiations

          protected java.util.HashMap<java.lang.String,ServiceLevel> serviceNegotiations

      A list of the current service negotiations

    - #### contractHandler

          protected ContractManager contractHandler

      The parent contract handler

    - #### contract

          protected Contract contract

      This service level's contract

  - ### Constructor Detail

    - #### ServiceLevel

          public ServiceLevel(java.lang.String theServiceLevel,
                              ContractManager theContractHandler,
                              Contract theContract)

      Create a new instance of ServiceLevel.
      Parameters:
        `theServiceLevel` - the service level name.
        `theContractHandler` - the parent contract handler.
        `theContract` - this service level contract.

    - #### ServiceLevel

          public ServiceLevel(java.lang.String theServiceLevel,
                              ContractManager theContractHandler,
                              Contract theContract,
                              long thisTimeInterval)

      Create a new instance of ServiceLevel.
      Parameters:
        `theServiceLevel` - the service level name.
        `theContractHandler` - the parent contract handler.
        `theContract` - this service level contract.
        `thisTimeInterval` - the time interval for when a contract becomes out of date.

  - ### Method Detail

    - #### contractIsOK

          public boolean contractIsOK(Contract theContract)

      Return true if the contract suggested by the client is OK. This implementation only checks if the contract is a default 'yes' contract.
      Parameters:
        `theContract` - the contract to process.
      Returns:
        a true if a 'yes' contract, false otherwise.

    - #### getTimeStamp

          public long getTimeStamp()

      Get the time the message was logged at. This should be in the form of milliseconds from `Date.getTime()`.
      Returns:
        the time stamp value.

    - #### getServiceLevel

          public java.lang.String getServiceLevel()

      Get the name of the service level.
      Returns:
        the value of serviceLevel.

    - #### contractReply

          public Contract contractReply(java.lang.String clientID,
                                        Contract theContract)
                                 throws java.lang.Exception

      Process the negotiation contract suggested by the client.
      Parameters:
        `clientID` - the client id.
        `theContract` - the contract to process. This is a wrapper for an XML-based contract description that is arbitrary with some standard elements.
      Returns:
        a reply for the contract proposal.
      Throws:
        `java.lang.Exception` - any error.

    - #### processThisContract

          protected static Contract processThisContract(ServiceLevel currentContract,
                                                        Contract proposedContract)
                                                 throws java.lang.Exception

      This can be used as a sort of generic processor of contract. Still to be completed and returns the true contract as default.
      Parameters:
        `currentContract` - the result of the current negotiations.
        `proposedContract` - the new client contract proposal.
      Returns:
        the true or OK contract reply as the default for this class.
      Throws:
        `java.lang.Exception` - any error.