Agent System POND 1.2 (28.2.2002)

FIM.payment
Class DataPayment

java.lang.Object
  |
  +--FIM.payment.PaymentBase
        |
        +--FIM.payment.DataPayment
All Implemented Interfaces:
Payment, Serializable, XMLEncodeable

public class DataPayment
extends PaymentBase

A class representing the payment by providing some valuable piece of data. This could be either some kind of E-Cash or replacing the purchase with an exchange (data-for-data). The data can be one of the following:

Version:
1.0
Author:
Michael Sonntag
See Also:
Invoice, Serialized Form

Field Summary
static int TYPE_BYTES
          The type of the content: Array of bytes
static int TYPE_EMPTY
          The type of the content: NONE
static int TYPE_SERIALIZABLE
          The type of the content: Serializable object
static int TYPE_STRING
          The type of the content: String
 
Constructor Summary
DataPayment()
          Create a new empty object.
DataPayment(Element elem)
          Create a new data payment from an XML element.
DataPayment(Invoice inv, String characteristic, byte[] byteData)
          Create a new data payment with the type array of bytes.
DataPayment(Invoice inv, String characteristic, Serializable serialData)
          Create a new data payment with the type serializable object.
DataPayment(Invoice inv, String characteristic, String stringData)
          Create a new data payment with the type string.
 
Method Summary
 void decodeXMLElement(Element elem)
          Parse back the payment from an XML element.
 Element getAsXMLElement(Document doc)
          Retrieve the payment as an XML element.
 byte[] getByteData()
          Retrieve the data in case of the bytes variant.
 byte[] getEncoded()
          Retrieve the payment in encoded form to be used for signing.
 Serializable getSerializableData()
          Retrieve the data in case of the serializable object variant.
 String getStringData()
          Retrieve the data in case of the string variant.
 int getType()
          Retrieve the type of this payment.
 String toString()
          Retrieve the payment as a string, suitable for presenting to the user in a very simple form.
 
Methods inherited from class FIM.payment.PaymentBase
characteristics, getAsSerializable, getCertificate, getInvoice, isSigned, sign, verifySignature, verifySignature
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_EMPTY

public static final int TYPE_EMPTY
The type of the content: NONE

TYPE_STRING

public static final int TYPE_STRING
The type of the content: String

TYPE_BYTES

public static final int TYPE_BYTES
The type of the content: Array of bytes

TYPE_SERIALIZABLE

public static final int TYPE_SERIALIZABLE
The type of the content: Serializable object
Constructor Detail

DataPayment

public DataPayment()
Create a new empty object. To be used for parsing in XML data later. Must be public so it can be created by factory methods.

DataPayment

public DataPayment(Invoice inv,
                   String characteristic,
                   String stringData)
Create a new data payment with the type string.
Parameters:
invoice - the invoice this payment is for
characteristic - the description of the content
stringData - the string data

DataPayment

public DataPayment(Invoice inv,
                   String characteristic,
                   byte[] byteData)
Create a new data payment with the type array of bytes.
Parameters:
invoice - the invoice this payment is for
characteristic - the description of the content
byteData - the byte data

DataPayment

public DataPayment(Invoice inv,
                   String characteristic,
                   Serializable serialData)
Create a new data payment with the type serializable object.
Parameters:
invoice - the invoice this payment is for
characteristic - the description of the content
serialData - the serializable object

DataPayment

public DataPayment(Element elem)
Create a new data payment from an XML element.
Parameters:
elem - the XML element containing the encoded form
Method Detail

getStringData

public String getStringData()
Retrieve the data in case of the string variant.
Returns:
the string data
Throws:
IllegalStateException - if this object ist not of the data subtype or not initialized

getByteData

public byte[] getByteData()
Retrieve the data in case of the bytes variant.
Returns:
the array of bytes
Throws:
IllegalStateException - if this object ist not of the byte-array subtype or not initialized

getSerializableData

public Serializable getSerializableData()
Retrieve the data in case of the serializable object variant.
Returns:
the the serializable object
Throws:
IllegalStateException - if this object ist not of the serializable object subtype or not initialized

getType

public int getType()
Retrieve the type of this payment.
Returns:
the payment type
See Also:
TYPE_EMPTY, TYPE_STRING, TYPE_BYTES, TYPE_SERIALIZABLE

toString

public String toString()
Retrieve the payment as a string, suitable for presenting to the user in a very simple form.
Overrides:
toString in class Object
Returns:
the payment encoded as a string

getEncoded

public byte[] getEncoded()
Retrieve the payment in encoded form to be used for signing. Does NOT include the signing information itself (which will be created based on the result!). Must be exactly the same on all calls and if the content is the same.
Overrides:
getEncoded in class PaymentBase
Returns:
the payment in encoded form

getAsXMLElement

public Element getAsXMLElement(Document doc)
Retrieve the payment as an XML element.
Overrides:
getAsXMLElement in class PaymentBase
Parameters:
doc - the document within which to create the element
Returns:
the currency as an element

decodeXMLElement

public void decodeXMLElement(Element elem)
                      throws IllegalArgumentException
Parse back the payment from an XML element.
Overrides:
decodeXMLElement in class PaymentBase
Parameters:
elem - the element containing the currency to parse back
Throws:
IllegalArgumentException - if the element is incorrect (e. g. wrong tag name)

Agent System POND 1.2 (28.2.2002)

Submit a bug

Copyright 2001,2002 Michael Sonntag & Institute for Information Processing and Microprocessor Technology (FIM), Johannes-Kepler-University Linz, Altenbergerstr. 69, A-4040 Linz, Austria.