webfunds.token
Class AbstractParams

java.lang.Object
  |
  +--webfunds.sox.Encodable
        |
        +--webfunds.token.AbstractParams
Direct Known Subclasses:
AbstractPrivateParams, AbstractPublicParams

public abstract class AbstractParams
extends Encodable

Represents a Private (signing) key for a token {item, series, expiry, log} tuple. Refer to AbstractPublicParams for common methods.

See Also:
Serialized Form

Field Summary
protected  long expiry
          Tokens commonly come from a batch that is identified with a series label or an expiry date.
protected  byte[] item
           
protected  int log
          The quantity of the item that this token represents.
static int PARAMS_VERSION
          The version number for this structure: 0: current
protected  byte[] series
           
protected  int subversion
          The version of the subclass.
protected  int type
          The type of token of this class See Factory for current definitions.
protected  int version
           
 
Constructor Summary
AbstractParams(byte[] buf)
          Reconstruct the object from a previously encoded byte array.
AbstractParams(java.io.InputStream is)
          Reconstruct the object from data in an input stream.
 
Method Summary
 void decode(java.io.InputStream is)
          Update this params object with the values from a token encoded as a byte array (such as previously returned from the encode() method of a token object).
 void encode(java.io.OutputStream os)
          Encode a params as a byte array, suitable for sending to third parties for depositing.
protected  boolean equals(AbstractParams other)
           
 long getExpiry()
           
 byte[] getItem()
           
 int getLog()
           
 long getQty()
          Note (1) that this may be derived information, the real token value may be encoded in the signature key or some other way.
 byte[] getSeries()
           
 int getSubVersion()
           
 int getType()
           
 int getVersion()
           
 java.lang.String toString()
           
 java.lang.String vString()
           
 
Methods inherited from class webfunds.sox.Encodable
decode, encode, main, readByteArray, readCertificate, readProperties, readString, writeByteArray, writeCertificate, writeProperties, writeString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PARAMS_VERSION

public static final int PARAMS_VERSION
The version number for this structure: 0: current

version

protected int version

type

protected int type
The type of token of this class See Factory for current definitions.

subversion

protected int subversion
The version of the subclass.

log

protected int log
The quantity of the item that this token represents. Encoded in logarithm - base 2 of the quantity. Log Qty 0 0 1 1 2 2 3 4 4 8 and so forth. -1 could be used for "not stated", meaning it is encoded in the magic parts (by use of certain key, for example).

expiry

protected long expiry
Tokens commonly come from a batch that is identified with a series label or an expiry date. These are interpreted by the subclass, may be ignored.

series

protected byte[] series

item

protected byte[] item
Constructor Detail

AbstractParams

public AbstractParams(byte[] buf)
               throws TokenPacketException
Reconstruct the object from a previously encoded byte array.
Parameters:
buf - the previously encoded object

AbstractParams

public AbstractParams(java.io.InputStream is)
               throws TokenPacketException
Reconstruct the object from data in an input stream.
Parameters:
is - the input stream from which to read the data
Method Detail

getVersion

public final int getVersion()

getType

public int getType()

getSubVersion

public int getSubVersion()

getLog

public int getLog()

getQty

public long getQty()
Note (1) that this may be derived information, the real token value may be encoded in the signature key or some other way. Note (2) that the unit of account is not encoded within the token, the higher layer code should remember that. See Payments for the encoded Item (a.k.a. Ricardian Contract).
Returns:
quantity of the item that this token represents, being 0 - n representing which bit, or -1 if "not so encoded"

getExpiry

public long getExpiry()

getSeries

public byte[] getSeries()

getItem

public byte[] getItem()

decode

public void decode(java.io.InputStream is)
            throws java.io.IOException
Update this params object with the values from a token encoded as a byte array (such as previously returned from the encode() method of a token object).
Overrides:
decode in class Encodable
Parameters:
token - the previosly encoded token

encode

public void encode(java.io.OutputStream os)
            throws java.io.IOException
Encode a params as a byte array, suitable for sending to third parties for depositing. If the signature is not present, an unsigned token will be encoded.
Overrides:
encode in class Encodable
Returns:
byte[] the token in encoded form

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

vString

public java.lang.String vString()

equals

protected boolean equals(AbstractParams other)