org.iids.aos.negotiation
Class Request

java.lang.Object
  extended by org.iids.aos.negotiation.Request
All Implemented Interfaces:
java.io.Serializable

public class Request
extends java.lang.Object
implements java.io.Serializable

The Request class represents a service negotiation request. A request is usually based on a Template and is generally sent to the publisher of the template.

The request can contain any combination of services as defined in the template. The properties of each service can be set through the setValue method.

Author:
rjtimmer
See Also:
Serialized Form

Constructor Summary
Request(Template template)
          Generate a new Request, based on a template.
 
Method Summary
 AgreementOffer getAgreementOffer()
          Generate an AgreementOffer, this may still be used internally in AgentScape for the negotiation.
 Service getService(java.lang.String serviceName)
          Get a Service from the request.
 AgentScapeID getTarget()
          Get the target this request is to be sent to.
 void setInitiator(java.lang.Object initiator)
          Set the initiator (ie.
 void setValue(java.lang.String serviceName, java.lang.String fieldName, java.lang.Object value)
          Add a value to a field in a Service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Request

public Request(Template template)
Generate a new Request, based on a template. Initially, no services described in the template are set in the request. Properties of a service can be set using setValue. All service properties are optional for now.

Parameters:
template - The template which this request is based on.
Method Detail

setValue

public void setValue(java.lang.String serviceName,
                     java.lang.String fieldName,
                     java.lang.Object value)
              throws TemplateException,
                     ServiceException,
                     RestrictionException
Add a value to a field in a Service. This also does the checking to see if the service name is defined in the template, and whether the restrictions are respected.

Parameters:
serviceName - The service name to set a value in. Same as Service.set(String,Object) with parameters fieldName and value). If a Service with name serviceName was not yet set in this Request, it will be added to the Request.
fieldName - The property name of the service to set the value for.
value - The value to set the service property to. If possible, and if there are restrictions to the values of the service property, these will be checked before actually setting the value of the property.
Throws:
TemplateException - If the template does not support the service serviceName.
ServiceException - If the property field cannot be set. This can happen if the field does not exist in the service, or if the Service is readonly.
RestrictionException - If value is not in the allowed range for field.

getService

public Service getService(java.lang.String serviceName)
                   throws TemplateException
Get a Service from the request. This is only possible if a Service with the same serviceName is also in the Template that this service is based on.

If no exceptions are thrown during the execution of this method, then the returned service is part of the request. This means that when a service was not part of the Request, it is added to the request.

Parameters:
serviceName - The name of the service to obtain from the Request.
Returns:
The service associated with serviceName, that is part of this Request. The Service will be included in the Request.
Throws:
TemplateException - If serviceName is not specified in the template.

getAgreementOffer

public AgreementOffer getAgreementOffer()
Generate an AgreementOffer, this may still be used internally in AgentScape for the negotiation. Agents should not need to bother with this, except maybe for testing and debugging.

Returns:
The AgreementOffer generated from this Request.

getTarget

public AgentScapeID getTarget()
Get the target this request is to be sent to. This is the same party that published the template initially.


setInitiator

public void setInitiator(java.lang.Object initiator)
Set the initiator (ie. the Subject) that this request is based on. The initiator can be used to identify who has made the request.

Parameters:
initiator - Any Object can be used to identify the initiator. The String representation (as obtained by initiator.toString()) of this object is used in the marshalled document.


Copyright © 2003, 2004 IIDS Group. All Rights Reserved.