org.jdesktop.wonderland.common.checksums
Class Checksum

java.lang.Object
  extended by org.jdesktop.wonderland.common.checksums.Checksum

public class Checksum
extends java.lang.Object

The Checksum class represents an individual checksum for a resource. A checksum consists of a hex-encoded checksum string, the date the file on disk was last modified (milliseconds since the epoch), and the relative path of the asset.

This class can also be encoded/decoded to/from XML via JAXB, suitable for storing on disk or serializing across a network.

Author:
paulby, Jordan Slott

Constructor Summary
Checksum()
          Default constructor
Checksum(java.lang.String checksum)
          Constructor, takes the string checksum
 
Method Summary
static Checksum decode(java.io.Reader r)
          Takes the input reader of the XML file and instantiates an instance of the Checksum class
 void encode(java.io.Writer w)
          Writes the Checksum class to an output writer.
 boolean equals(Checksum checksum)
          Returns true if the given checksum is equal to this checksum, false if not.
 java.lang.String getChecksum()
          Returns the hex-encoded checksum string.
 long getLastModified()
          Returns the time the resource was last modified, in milliseconds since the epoch.
 java.lang.String getPathName()
          Returns the resource path name, relative to the repository.
 void setChecksum(java.lang.String checksum)
          Sets the hex-encoded checksum string.
 void setLastModified(long lastModified)
          Sets the time the resource was last modified, in milliseconds since the epoch.
 void setPathName(java.lang.String pathName)
          Sets the resource path name, relative to the repository.
static java.lang.String toHexString(byte[] bytes)
          Converts the checksum given as an array of bytes into a hex-encoded string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Checksum

public Checksum()
Default constructor


Checksum

public Checksum(java.lang.String checksum)
Constructor, takes the string checksum

Method Detail

equals

public boolean equals(Checksum checksum)
Returns true if the given checksum is equal to this checksum, false if not.

Parameters:
checksum - Compare this checksum to the given checksum
Returns:
True if the two checkums are equal, false if not

setChecksum

public void setChecksum(java.lang.String checksum)
Sets the hex-encoded checksum string.

Parameters:
checksum - The hex-encoded checksum string

getChecksum

public java.lang.String getChecksum()
Returns the hex-encoded checksum string.

Returns:
The hex-encoded checksum string

setLastModified

public void setLastModified(long lastModified)
Sets the time the resource was last modified, in milliseconds since the epoch.

Parameters:
lastModified - The time the resource was last modified

getLastModified

public long getLastModified()
Returns the time the resource was last modified, in milliseconds since the epoch.

Returns:
The time the resource was last modified

setPathName

public void setPathName(java.lang.String pathName)
Sets the resource path name, relative to the repository.

Parameters:
pathName - The relative resource path name

getPathName

public java.lang.String getPathName()
Returns the resource path name, relative to the repository.

Returns:
The relative resource path name

decode

public static Checksum decode(java.io.Reader r)
                       throws javax.xml.bind.JAXBException
Takes the input reader of the XML file and instantiates an instance of the Checksum class

Parameters:
r - The input reader of the version XML file
Throws:
javax.xml.bind.JAXBException

encode

public void encode(java.io.Writer w)
            throws javax.xml.bind.JAXBException
Writes the Checksum class to an output writer.

Parameters:
os - The output writer to write to
Throws:
javax.xml.bind.JAXBException

toHexString

public static java.lang.String toHexString(byte[] bytes)
Converts the checksum given as an array of bytes into a hex-encoded string.

Parameters:
bytes - The checksum as an array of bytes
Returns:
The checksum as a hex-encoded string


Open Wonderland - http://openwonderland.org