jimm.twice.ice
Class Offer

java.lang.Object
  extended byjimm.twice.ice.Offer

public class Offer
extends java.lang.Object

An offer from a syndicator. These offers are created when a catalog is parsed by a subscriber. The subscriber can then set the pushWanted, pullWanted, and getWanted flags. An offer knows how to generate itself as a message, either for a catalog or for a subscribe request

Implementation note: the rule list must be ordered so that the subscription GUI can work. It needs to be able to display the rules to the user. Wwe have to guarantee that we can specify the n'th element of that list. This requirement of ordering has nothing to do with the ICE spec, but it does no harm to enforce it here.

Author:
Jim Menard, jimm@io.com

Field Summary
protected  java.util.List deliveryRules
           
protected  java.lang.String description
           
protected  java.lang.String identifier
           
protected  java.lang.String name
           
 
Constructor Summary
Offer(java.lang.String offerId, java.lang.String name)
          Constructor
 
Method Summary
 void addDeliveryRule(DeliveryRule rule)
           
 Offer asXML()
          Returns this subscription as an XML offer message suitable for sending as part of a catalog or a subscribe message.
 Offer deepClone()
          Performs a deep copy.
 java.util.Iterator deliveryRules()
           
 java.lang.String generateIdentifier(java.lang.String syndicatorDomain, java.lang.String subscriberId)
          Creates, saves, and returns a new identifier.
 DeliveryRule getDeliveryRule(int i)
           
 java.lang.String getDescription()
           
 java.lang.String getGetURL()
          Returns the first get URL found in any delivery rule, or null if none is found.
 java.lang.String getIdentifier()
           
 java.lang.String getName()
           
 java.lang.String getPullURL()
          Returns the first pull URL found in any delivery rule, or null if none is found.
 java.lang.String getPushURL()
          Returns the first push URL found in any delivery rule, or null if none is found.
 boolean isGet()
           
 boolean isPull()
           
 boolean isPush()
           
 int numDeliveryRules()
           
 boolean requiresAcceptance()
          Returns true if this offer requires a subscribe response back to the syndicator.
 void setDescription(java.lang.String val)
           
 void setIdentifier(java.lang.String id)
           
 void setName(java.lang.String val)
           
 void setPushURL(java.lang.String url)
          Sets the delivery endpoint URL of the first push SOAP transport.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

identifier

protected java.lang.String identifier

name

protected java.lang.String name

description

protected java.lang.String description

deliveryRules

protected java.util.List deliveryRules
Constructor Detail

Offer

public Offer(java.lang.String offerId,
             java.lang.String name)
Constructor

Parameters:
name - an optional string useful for subscription id generation; may be null
Method Detail

deepClone

public Offer deepClone()
Performs a deep copy.


getIdentifier

public java.lang.String getIdentifier()

setIdentifier

public void setIdentifier(java.lang.String id)

generateIdentifier

public java.lang.String generateIdentifier(java.lang.String syndicatorDomain,
                                           java.lang.String subscriberId)
Creates, saves, and returns a new identifier.

Parameters:
syndicatorDomain - the syndicator's domain string
subscriberId - the subscriber's UUID; used to generate a numeric key
Returns:
this subscription's new identifier

getName

public java.lang.String getName()

setName

public void setName(java.lang.String val)

getDescription

public java.lang.String getDescription()

setDescription

public void setDescription(java.lang.String val)

addDeliveryRule

public void addDeliveryRule(DeliveryRule rule)

deliveryRules

public java.util.Iterator deliveryRules()

numDeliveryRules

public int numDeliveryRules()

getDeliveryRule

public DeliveryRule getDeliveryRule(int i)

getPushURL

public java.lang.String getPushURL()
Returns the first push URL found in any delivery rule, or null if none is found.

Returns:
a URL string; null if none found

isPush

public boolean isPush()

setPushURL

public void setPushURL(java.lang.String url)
Sets the delivery endpoint URL of the first push SOAP transport.


getPullURL

public java.lang.String getPullURL()
Returns the first pull URL found in any delivery rule, or null if none is found.

Returns:
a URL string; null if none found

isPull

public boolean isPull()

getGetURL

public java.lang.String getGetURL()
Returns the first get URL found in any delivery rule, or null if none is found.

Returns:
a URL string; null if none found

isGet

public boolean isGet()

requiresAcceptance

public boolean requiresAcceptance()
Returns true if this offer requires a subscribe response back to the syndicator. This will return false, for example, if this offer is only a GET offer.

Returns:
true if this offer requires a subscribe response back to the syndicator

asXML

public Offer asXML()
Returns this subscription as an XML offer message suitable for sending as part of a catalog or a subscribe message.

Returns:
this offer as a catalog message