jimm.twice.ice
Class DeliveryRule

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

public class DeliveryRule
extends java.lang.Object

A delivery rule describes how a subscription gets delivered.

Implementation note: the transport and packaging lists must be ordered so that the subscription GUI can work. It needs to be able to display them to the user and let the user select from among them. In order to do this, we have to guarantee that we can specify the n'th element of thoses lists. 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
See Also:
Subscription, Offer, Transport, Packaging

Field Summary
protected  java.lang.String mode
           
static java.lang.String MODE_PULL
           
static java.lang.String MODE_PUSH
           
protected  java.util.List packagings
           
protected  java.util.List transports
           
 
Constructor Summary
DeliveryRule(java.lang.String mode)
           
 
Method Summary
 void addPackaging(Packaging p)
           
 void addTransport(Transport t)
           
 DeliveryRule asXML()
           
 DeliveryRule deepClone()
           
 java.lang.String findURLForModeAndProtocol(java.lang.String m, java.lang.String p)
          Returns the first URL (delivery endpoint) for the specified mode (push/pull) and protocol (get, soap, ftp, etc.).
 java.lang.String getGetURL()
          Returns the first get URL found in any transport, or null if none is found.
 java.lang.String getMode()
           
 Packaging getPackaging(int i)
           
 java.lang.String getPullURL()
          Returns the first pull URL found in any transport, or null if none is found.
 java.lang.String getPushURL()
          Returns the first push URL found in any transport, or null if none is found.
 Transport getTransport(int i)
           
 boolean hasTransportWithProtocol(java.lang.String protocol)
           
 boolean isPull()
           
 boolean isPush()
           
 int numPackagings()
           
 int numTransports()
           
 java.util.Iterator packagings()
           
 void removePackaging(int i)
           
 void removeTransport(int i)
           
 boolean requiresAcceptance()
          Returns true if this rule requires a subscribe response back to the syndicator.
 void setTransportWithProtocolEndpoint(java.lang.String protocol, java.lang.String endpoint)
           
 java.util.Iterator transports()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_PUSH

public static final java.lang.String MODE_PUSH
See Also:
Constant Field Values

MODE_PULL

public static final java.lang.String MODE_PULL
See Also:
Constant Field Values

mode

protected java.lang.String mode

transports

protected java.util.List transports

packagings

protected java.util.List packagings
Constructor Detail

DeliveryRule

public DeliveryRule(java.lang.String mode)
Method Detail

deepClone

public DeliveryRule deepClone()

getMode

public java.lang.String getMode()

isPush

public boolean isPush()

isPull

public boolean isPull()

addTransport

public void addTransport(Transport t)

transports

public java.util.Iterator transports()

numTransports

public int numTransports()

getTransport

public Transport getTransport(int i)

removeTransport

public void removeTransport(int i)

hasTransportWithProtocol

public boolean hasTransportWithProtocol(java.lang.String protocol)

setTransportWithProtocolEndpoint

public void setTransportWithProtocolEndpoint(java.lang.String protocol,
                                             java.lang.String endpoint)

requiresAcceptance

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

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

addPackaging

public void addPackaging(Packaging p)

packagings

public java.util.Iterator packagings()

numPackagings

public int numPackagings()

getPackaging

public Packaging getPackaging(int i)

removePackaging

public void removePackaging(int i)

getPushURL

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

Returns:
a URL string; null if none found

getPullURL

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

Returns:
a URL string; null if none found

getGetURL

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

Returns:
a URL string; null if none found

findURLForModeAndProtocol

public java.lang.String findURLForModeAndProtocol(java.lang.String m,
                                                  java.lang.String p)
Returns the first URL (delivery endpoint) for the specified mode (push/pull) and protocol (get, soap, ftp, etc.). Returns null if nothing matches.

Returns:
a URL string or null if not found

asXML

public DeliveryRule asXML()