org.psepr.jClient
Class PayloadLease

java.lang.Object
  extended by org.psepr.jClient.Payload
      extended by org.psepr.jClient.PayloadLease
All Implemented Interfaces:
PayloadParser

public class PayloadLease
extends Payload
implements PayloadParser

Author:
Robert.Adams@intel.com

Field Summary
static java.lang.String leaseNamespace
           
static java.lang.String leaseOpLease
           
static java.lang.String leaseOpRegister
           
static java.lang.String leaseOpUnregister
           
 
Constructor Summary
PayloadLease()
           
PayloadLease(java.lang.String ns)
           
PayloadLease(java.lang.String li, java.lang.String lt, java.lang.String lo, long ld)
          Create an initialized lease payload.
 
Method Summary
 long getLeaseDuration()
           
 java.lang.String getLeaseIdentifier()
           
 java.lang.String getLeaseOp()
           
 java.lang.String getLeaseType()
           
 Payload parsePayload(java.lang.String ns, org.xmlpull.v1.XmlPullParser parser)
          Parse the lease payload.
 void setLeaseDuration(long ld)
           
 void setLeaseIdentifier(java.lang.String li)
           
 void setLeaseOp(java.lang.String lo)
           
 void setLeaseType(java.lang.String lt)
           
 java.lang.String toXML()
          return the XML that represents the payload.
 
Methods inherited from class org.psepr.jClient.Payload
getNamespace, setNamespace, toXML
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.psepr.jClient.PayloadParser
getNamespace, setNamespace
 

Field Detail

leaseNamespace

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

leaseOpRegister

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

leaseOpUnregister

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

leaseOpLease

public static final java.lang.String leaseOpLease
See Also:
Constant Field Values
Constructor Detail

PayloadLease

public PayloadLease()

PayloadLease

public PayloadLease(java.lang.String ns)
Parameters:
ns -

PayloadLease

public PayloadLease(java.lang.String li,
                    java.lang.String lt,
                    java.lang.String lo,
                    long ld)
Create an initialized lease payload.

Parameters:
li - lease identifier (arbritrary alpha/numeric string
lt - type of messages we want to receive with this lease
lo - operation: one of 'register', 'unregister'
ld - duration of the requested lease in seconds
Method Detail

getLeaseIdentifier

public java.lang.String getLeaseIdentifier()

setLeaseIdentifier

public void setLeaseIdentifier(java.lang.String li)

getLeaseType

public java.lang.String getLeaseType()

setLeaseType

public void setLeaseType(java.lang.String lt)

getLeaseOp

public java.lang.String getLeaseOp()

setLeaseOp

public void setLeaseOp(java.lang.String lo)

getLeaseDuration

public long getLeaseDuration()

setLeaseDuration

public void setLeaseDuration(long ld)

parsePayload

public Payload parsePayload(java.lang.String ns,
                            org.xmlpull.v1.XmlPullParser parser)
Parse the lease payload. We come in here with the parser positioned on the element and we will exit with the parser positioned on the element.

The routine will check to see if this is a namespace that it knows how to parse. If not, null is returned. If it is, the payload will be parsed the the proper payload object returned. Because of the way the parser works, if anything goes wrong with the parsing, the event becomes unparsable. This is signaled by this routine throwing a PsEPRException.

Specified by:
parsePayload in interface PayloadParser
Parameters:
ns - the namespace of the payload
parser - the XML parser positioned at the payload element
Returns:
the parsed payload or null if no payload was parsed. If null is returned, the parser's position will not have been moved.
Throws:
PsEPRException - if parsing fails. Event is unusable after this.
See Also:
PayloadParser.parsePayload(java.lang.String, org.xmlpull.v1.XmlPullParser)

toXML

public java.lang.String toXML()
Description copied from class: Payload
return the XML that represents the payload. This is the complete payload element beginning and ending with ....

Overrides:
toXML in class Payload
Returns:
XML of the complete payload