org.licas.service.model

## Class Contract

- java.lang.Object
- - org.licas.service.model.Contract

- All Implemented Interfaces:
    ContractDef

      public class Contract
      extends java.lang.Object
      implements ContractDef

  Default contract class. This is essentially a wrapper for an arbitrary XML-based description that should also contain certain standard elements. A contract is a description of an agreement between services, typically to allow access to a service through passwords and/or to actually carry out the service in question. The process is service-specific, but this version also offers default 'yes', 'no' and 'true' contracts that can be used to tell the server, or a service, to automatically return its password, or to refuse and require the client to know what the correct password is.
  Author:
    Kieran Greer

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected org.licas_xml.abs.Element` | `contract` The service or negotiation contract

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Contract(org.licas_xml.abs.Element theContract)` Create a new instance of Contract.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `org.licas_xml.abs.Element` | `getContract()` Get the negotiation or service contract information.
    `static java.lang.String` | `getElementValue(java.lang.String elementName, Contract theContract)` Parse the contract to retrieve the value for the specified element.
    `static Contract` | `getNoContract()` Create and return a negotiation or service contract that always returns 'no'.
    `static Contract` | `getTrueContract(java.lang.String clientID, java.lang.String serviceLevel)` Create a default true contract.
    `static Contract` | `getYesContract()` Create and return a negotiation or service contract that always returns 'yes'.
    `static boolean` | `isNoContract(Contract theContract)` Return true if the contract is a default 'no' contract.
    `static boolean` | `isYesContract(Contract theContract)` Return true if the contract is a default 'yes' contract.
    `org.licas_xml.abs.Element` | `toXml()` Get the negotiation or service contract information.

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

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

- - ### Field Detail

    - #### contract

          protected org.licas_xml.abs.Element contract

      The service or negotiation contract

  - ### Constructor Detail

    - #### Contract

          public Contract(org.licas_xml.abs.Element theContract)

      Create a new instance of Contract.
      Parameters:
        `theContract` - the contract description. This can take any form and so is represented by an XML element only.

  - ### Method Detail

    - #### getContract

          public org.licas_xml.abs.Element getContract()

      Get the negotiation or service contract information.
      Specified by:
        `getContract` in interface `ContractDef`
      Returns:
        the value of contract.

    - #### toXml

          public org.licas_xml.abs.Element toXml()

      Get the negotiation or service contract information.
      Returns:
        the value of contract.

    - #### isYesContract

          public static boolean isYesContract(Contract theContract)

      Return true if the contract is a default 'yes' contract.
      Parameters:
        `theContract` - the contract to evaluate.
      Returns:
        true if a default yes contract.

    - #### isNoContract

          public static boolean isNoContract(Contract theContract)

      Return true if the contract is a default 'no' contract.
      Parameters:
        `theContract` - the contract to evaluate.
      Returns:
        true if a default no contract.

    - #### getYesContract

          public static Contract getYesContract()

      Create and return a negotiation or service contract that always returns 'yes'.
      Returns:
        a default constructed new contract.

    - #### getNoContract

          public static Contract getNoContract()

      Create and return a negotiation or service contract that always returns 'no'.
      Returns:
        a default constructed new contract.

    - #### getTrueContract

          public static Contract getTrueContract(java.lang.String clientID,
                                                 java.lang.String serviceLevel)

      Create a default true contract. This is different to a 'yes' contract in the sense that it is a 'reply' to a negotiation and not an automatic response.
      Parameters:
        `clientID` - the id of the calling client.
        `serviceLevel` - the service level.
      Returns:
        a default affirmative reply to a contract negotiation phase.

    - #### getElementValue

          public static java.lang.String getElementValue(java.lang.String elementName,
                                                         Contract theContract)

      Parse the contract to retrieve the value for the specified element. These are first-level elements with pre-defined names.
      Parameters:
        `elementName` - the name of the element. Can be for example `Const.POLICY`, `Const.CLIENT`, `Const.SERVICELEVEL`.
        `theContract` - the client contract.
      Returns:
        the element value, or null if none is available or if the contract is not properly structured.