org.tranche
Class FileEncoding

java.lang.Object
  extended by org.tranche.FileEncoding

public class FileEncoding
extends java.lang.Object

Represents an encoding of a chunk. A meta data will have collection of FileEncoding so that, when downloading the chunk, the tool will know how to process it to get the original bytes.

Note that order is significant. E.g., say a chunk has the following encodings: NONE, GZIP, and AES. This means that AES decryption was last applied (so much be handled first when downloading). Each FileEncoding has a hash associated with it to verify integrity.

Author:
Jayson Falkner - jfalkner@umich.edu, Bryan Smith - bryanesmith@gmail.com, James "Augie" Hill - augman85@gmail.com

Field Summary
static java.lang.String AES
          Representing a chunk's state after AES encryption applied.
static java.lang.String GZIP
          Representing a chunk's state after GZIP compression applied.
static java.lang.String LZMA
          Representing a chunk's state after LZMA compression applied.
static java.lang.String NONE
          Representing a chunk's state without any encodings.
static java.lang.String PROP_HASH
          Property key: used to get the hash value.
static java.lang.String PROP_PASSPHRASE
          Property key: used to get the passphrase value (if set).
static java.lang.String PROP_TIMESTAMP_PUBLISHED
          Property key: used to set when the passphrase was published.
static java.lang.String TARBALL
          Deprecated. Not in use.
 
Constructor Summary
FileEncoding(java.lang.String name, BigHash mh)
           
FileEncoding(java.lang.String name, java.util.Properties props)
           
 
Method Summary
static FileEncoding createFromString(java.lang.String string)
          Create a FileEncoding object from a string.
 boolean equals(java.lang.Object o)
           
 BigHash getHash()
          Get the BigHash associated with this FileEncoding.
 java.lang.String getName()
          Get the name of the FileEncoding.
 java.util.Properties getProperties()
          Properties object associated with FileEncoding.
 java.lang.String getProperty(java.lang.String name)
          Get a property (value) using a key.
 void setName(java.lang.String name)
          Set the name of the FileEncoding.
 void setProperties(java.util.Properties properties)
          Properties object associated with FileEncoding.
 void setProperty(java.lang.String name, java.lang.String value)
          Set a property.
 java.lang.String toString()
          Create a string representation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final java.lang.String NONE

Representing a chunk's state without any encodings.

See Also:
Constant Field Values

LZMA

public static final java.lang.String LZMA

Representing a chunk's state after LZMA compression applied.

See Also:
Constant Field Values

GZIP

public static final java.lang.String GZIP

Representing a chunk's state after GZIP compression applied.

See Also:
Constant Field Values

AES

public static final java.lang.String AES

Representing a chunk's state after AES encryption applied.

See Also:
Constant Field Values

TARBALL

public static final java.lang.String TARBALL
Deprecated. Not in use.

Representing a chunk (or collection of chunks) state after tarballed.

See Also:
Constant Field Values

PROP_HASH

public static final java.lang.String PROP_HASH

Property key: used to get the hash value.

See Also:
Constant Field Values

PROP_PASSPHRASE

public static final java.lang.String PROP_PASSPHRASE

Property key: used to get the passphrase value (if set).

See Also:
Constant Field Values

PROP_TIMESTAMP_PUBLISHED

public static final java.lang.String PROP_TIMESTAMP_PUBLISHED

Property key: used to set when the passphrase was published.

See Also:
Constant Field Values
Constructor Detail

FileEncoding

public FileEncoding(java.lang.String name,
                    java.util.Properties props)
Parameters:
name -
props -

FileEncoding

public FileEncoding(java.lang.String name,
                    BigHash mh)
Parameters:
name -
mh -
Method Detail

getHash

public BigHash getHash()

Get the BigHash associated with this FileEncoding.

Returns:

getProperty

public java.lang.String getProperty(java.lang.String name)

Get a property (value) using a key.

Parameters:
name - Property key used to return the particular property value.
Returns:
See Also:
PROP_HASH, PROP_PASSPHRASE

setProperty

public void setProperty(java.lang.String name,
                        java.lang.String value)

Set a property. This property can be later retrieved using the name (key).

Parameters:
name -
value -
See Also:
PROP_HASH, PROP_PASSPHRASE

getName

public java.lang.String getName()

Get the name of the FileEncoding. Used to identify the type of encoding.

Returns:
See Also:
NONE, AES, GZIP, LZMA, TARBALL

setName

public void setName(java.lang.String name)

Set the name of the FileEncoding. Used to identify the type of encoding.

Parameters:
name -
See Also:
NONE, AES, GZIP, LZMA, TARBALL

getProperties

public java.util.Properties getProperties()

Properties object associated with FileEncoding.

Returns:
See Also:
PROP_HASH, PROP_PASSPHRASE

setProperties

public void setProperties(java.util.Properties properties)

Properties object associated with FileEncoding.

Parameters:
properties -
See Also:
PROP_HASH, PROP_PASSPHRASE, PROP_TIMESTAMP_PUBLISHED

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()

Create a string representation. This can be saved and later restored.

Overrides:
toString in class java.lang.Object
Returns:
See Also:
createFromString(java.lang.String)

createFromString

public static FileEncoding createFromString(java.lang.String string)

Create a FileEncoding object from a string.

Parameters:
string -
Returns:
See Also:
toString()


This code is free for use both commercially and non-commercially as stated in the project's license