webfunds.sox
Class Id

java.lang.Object
  |
  +--webfunds.sox.Encodable
        |
        +--webfunds.sox.Id
Direct Known Subclasses:
AccountId, ItemId, MailId

public class Id
extends Encodable

This class represents an identifer, which can refer to an object by means of a hash or similar. This is a pseudo abstract class for other identifier classes.

See Also:
Serialized Form

Field Summary
protected  byte[] id
          The item identifier.
protected static int LEN_MD5
           
protected static int LEN_NAH
           
protected static int LEN_SHA1
           
protected static int MD_MD5
          SOX2 format for these hashes is the OpenPGP format with leading byte.
protected static int MD_NAH
          SOX2 format for these hashes is the OpenPGP format with leading byte.
protected static int MD_SHA1
          SOX2 format for these hashes is the OpenPGP format with leading byte.
 
Constructor Summary
protected Id()
           
protected Id(byte[] data)
           
protected Id(java.io.InputStream is)
           
 
Method Summary
 void decode(java.io.InputStream is)
           
 void encode(java.io.OutputStream os)
           
protected  boolean eq(Id other)
           
protected static Id ex()
          Make and return an example Id for testing (other classes).
protected static Id ex(int len)
           
 java.lang.String fp()
          fingerprint - a quick function for diags, long enough to avoid collisions, but short enough to print out.
 byte[] getByteArray()
          Get the underlying byte[].
static byte[] getBytesFromIdString(java.lang.String s)
          Convert this string representation into the bytes.
 int getOpenPGPId()
          Assumes length of the hash array will determine.
 int hashCode()
           
static void main(java.lang.String[] args)
           
 void setByteArray(byte[] byteArray)
          Set the underlying byte[].
 void setOpenPGPId(int i)
           
 java.lang.String toString()
          Convert this object to a string.
 
Methods inherited from class webfunds.sox.Encodable
decode, encode, readByteArray, readCertificate, readProperties, readString, writeByteArray, writeCertificate, writeProperties, writeString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected byte[] id
The item identifier.

MD_MD5

protected static final int MD_MD5
SOX2 format for these hashes is the OpenPGP format with leading byte. Normally, hashes are stored just as a byte array. For some parts (notably, the receipt) they are stored as OpenPGP format, with these leading bytes prepended. For completeness, the OpenPGP spec also defines these: 3 "RIP", 4 "2SHA", 5 "MD2", 6 "TIG", 7 "HAV", Ref: OpenPGP Message Formats RFC 2440 Section 9.4 These should probably be in a different file, but are only used by Ids, so here for now.

MD_SHA1

protected static final int MD_SHA1
SOX2 format for these hashes is the OpenPGP format with leading byte. Normally, hashes are stored just as a byte array. For some parts (notably, the receipt) they are stored as OpenPGP format, with these leading bytes prepended. For completeness, the OpenPGP spec also defines these: 3 "RIP", 4 "2SHA", 5 "MD2", 6 "TIG", 7 "HAV", Ref: OpenPGP Message Formats RFC 2440 Section 9.4 These should probably be in a different file, but are only used by Ids, so here for now.

MD_NAH

protected static final int MD_NAH
SOX2 format for these hashes is the OpenPGP format with leading byte. Normally, hashes are stored just as a byte array. For some parts (notably, the receipt) they are stored as OpenPGP format, with these leading bytes prepended. For completeness, the OpenPGP spec also defines these: 3 "RIP", 4 "2SHA", 5 "MD2", 6 "TIG", 7 "HAV", Ref: OpenPGP Message Formats RFC 2440 Section 9.4 These should probably be in a different file, but are only used by Ids, so here for now.

LEN_MD5

protected static final int LEN_MD5

LEN_SHA1

protected static final int LEN_SHA1

LEN_NAH

protected static final int LEN_NAH
Constructor Detail

Id

protected Id()

Id

protected Id(byte[] data)
      throws SOXPacketException

Id

protected Id(java.io.InputStream is)
      throws java.io.IOException,
             SOXPacketException
Method Detail

getByteArray

public byte[] getByteArray()
Get the underlying byte[]. You should probably not be using this but pass the whole Id object around instead. (This call was getId)

setByteArray

public void setByteArray(byte[] byteArray)
Set the underlying byte[]. (This call was setId) XXX: Id should probably become immutable.

setOpenPGPId

public void setOpenPGPId(int i)

getOpenPGPId

public int getOpenPGPId()
Assumes length of the hash array will determine.
Returns:
the OpenPGP hash id for this hash, else 0 for bearer, else -1 for unknown hash array?

encode

public void encode(java.io.OutputStream os)
            throws java.io.IOException
Overrides:
encode in class Encodable

decode

public void decode(java.io.InputStream is)
            throws java.io.IOException,
                   SOXPacketException
Overrides:
decode in class Encodable

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getBytesFromIdString

public static byte[] getBytesFromIdString(java.lang.String s)
Convert this string representation into the bytes. Strips any hint strings that might be present in debug outputs, etc.

toString

public java.lang.String toString()
Convert this object to a string. Note that is equivalent to as encode/decode always mangles one to the other.
Overrides:
toString in class java.lang.Object

fp

public java.lang.String fp()
fingerprint - a quick function for diags, long enough to avoid collisions, but short enough to print out.

eq

protected boolean eq(Id other)

ex

protected static Id ex()
Make and return an example Id for testing (other classes). This hash can be standard length, or empty.

ex

protected static Id ex(int len)

main

public static void main(java.lang.String[] args)