org.hd.d.pg2k.clApp.uploader
Class SelectedFileDetails

java.lang.Object
  extended by org.hd.d.pg2k.clApp.uploader.SelectedFileDetails

final class SelectedFileDetails
extends java.lang.Object

Immutable class to hold details of one file selected. This is used during the selection/naming and upload phase.

All package-visible for access from the GUI classes.

Thread-safe.

The get/set status methods are dynamic and do not operate on the instance; the class holds a weak-ref map from selected file details to an optional String status/error, which "shadows" any computed error.


Field Summary
static int COLNUM_BYTESLEN
          Column for the (immutable) length in bytes.
static int COLNUM_DESCRIPTION
          Column for the (immutable) length in bytes.
static int COLNUM_EXHIBIT_NAME
          Column for the (potentially mutable) proposed exhibit name.
static int COLNUM_LOCAL_FILE_NAME
          Column for the (immutable) local filename.
static int COLNUM_STATUS
          Column for the (dynamic) status string.
private  java.lang.String description
          Description; never null though may be "".
private  ExhibitStaticAttr esa
          Proposed upload name/details (valid unique new exhibit name); never null.
private  javax.jnlp.FileContents fc
          File on user side (should already be checked for validity); never null.
private static java.lang.String[] fileLoadTableColNames
          Column names for table, in order.
private  int hash
          The cached instance hash value; the hash may be expensive to compute.
private  ROByteArray hashMD5
          MD5 hash of exhibit content; never null.
private  java.lang.String localFilename
          Local filename; never null (nor "").
private static java.util.Map<SelectedFileDetails,java.lang.String> notes
          Global "error/status note" on instances of this class.
 
Constructor Summary
SelectedFileDetails(javax.jnlp.FileContents userFile, java.lang.String putativeExhibitName, java.lang.String description, ROByteArray hashMD5)
          Construct a new instance.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Equality is based on the (monocased) local filename and exhibit name.
(package private) static int getColumnCount()
          Return the number of columns; fixed for this model.
(package private) static java.lang.String getColumnName(int col)
          Return a column name, indexed from 0.
(package private)  java.lang.String getDescription()
          Get the description; never null but may be "".
(package private)  ExhibitStaticAttr getEsa()
          Get the static exhibit details; never null.
(package private)  javax.jnlp.FileContents getFc()
          Get the FileContents; never null.
(package private)  ROByteArray getHashMD5()
          Get the MD5 hash; never null.
(package private)  java.lang.String getLocalFilename()
          Get the local filename; never null (nor "").
(package private)  java.lang.String getStatus(UploaderLogic l)
          Get status/error: if this returns null all is OK, else the error is described.
(package private)  java.lang.Object getValueAt(UploaderLogic l, int col)
          Get the value at the given column; null if none.
 int hashCode()
          The hash code is based on the (monocased) local filename and exhibit name.
(package private)  void setStatus(java.lang.String n)
          Set a status note for this item; use "" or null to clear.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLNUM_EXHIBIT_NAME

public static final int COLNUM_EXHIBIT_NAME
Column for the (potentially mutable) proposed exhibit name.

See Also:
Constant Field Values

COLNUM_LOCAL_FILE_NAME

public static final int COLNUM_LOCAL_FILE_NAME
Column for the (immutable) local filename.

See Also:
Constant Field Values

COLNUM_DESCRIPTION

public static final int COLNUM_DESCRIPTION
Column for the (immutable) length in bytes.

See Also:
Constant Field Values

COLNUM_BYTESLEN

public static final int COLNUM_BYTESLEN
Column for the (immutable) length in bytes.

See Also:
Constant Field Values

COLNUM_STATUS

public static final int COLNUM_STATUS
Column for the (dynamic) status string.

See Also:
Constant Field Values

fileLoadTableColNames

private static final java.lang.String[] fileLoadTableColNames
Column names for table, in order.


localFilename

private final java.lang.String localFilename
Local filename; never null (nor "").


fc

private final javax.jnlp.FileContents fc
File on user side (should already be checked for validity); never null.


esa

private final ExhibitStaticAttr esa
Proposed upload name/details (valid unique new exhibit name); never null. Volatile for thread-safety without locks.


description

private final java.lang.String description
Description; never null though may be "".


hashMD5

private final ROByteArray hashMD5
MD5 hash of exhibit content; never null.


hash

private transient int hash
The cached instance hash value; the hash may be expensive to compute.


notes

private static final java.util.Map<SelectedFileDetails,java.lang.String> notes
Global "error/status note" on instances of this class. Uses a WeakHashMap so as not to retain a note unnecessarily once the associated file has been dealt with and instance GCed.

Thread-safe.

Constructor Detail

SelectedFileDetails

SelectedFileDetails(javax.jnlp.FileContents userFile,
                    java.lang.String putativeExhibitName,
                    java.lang.String description,
                    ROByteArray hashMD5)
              throws java.io.IOException
Construct a new instance.

Parameters:
userFile - underlying (validated) user file; never null
putativeExhibitName - syntatically-valid proposed exhibit name; never null
description - description text; may be "" but not null
hashMD5 - MD5 hash of exhibit content; if null then it is computed here
Throws:
java.io.IOException
Method Detail

getColumnCount

static int getColumnCount()
Return the number of columns; fixed for this model.


getColumnName

static java.lang.String getColumnName(int col)
Return a column name, indexed from 0.


getValueAt

java.lang.Object getValueAt(UploaderLogic l,
                            int col)
Get the value at the given column; null if none.


getFc

javax.jnlp.FileContents getFc()
Get the FileContents; never null.


getLocalFilename

java.lang.String getLocalFilename()
Get the local filename; never null (nor "").


getEsa

ExhibitStaticAttr getEsa()
Get the static exhibit details; never null.


getDescription

java.lang.String getDescription()
Get the description; never null but may be "".


getHashMD5

ROByteArray getHashMD5()
Get the MD5 hash; never null.


setStatus

void setStatus(java.lang.String n)
Set a status note for this item; use "" or null to clear. Does not change the instance itself, but stores any note in a private global map.


getStatus

java.lang.String getStatus(UploaderLogic l)
Get status/error: if this returns null all is OK, else the error is described. The routine must be quick to run, eg it cannot recompute a file hash.

If a note has been set it takes precedence over any computed value.

Returns:
null if all seems OK, non-null error message otherwise

equals

public boolean equals(java.lang.Object obj)
Equality is based on the (monocased) local filename and exhibit name. Both names are used to help avoid surprising ambiguities.

The MD5 hash is considered a feature of the content rather than of this object, and is not used in the object hash or equality.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
The hash code is based on the (monocased) local filename and exhibit name. Both names are used to help avoid surprising ambiguities.

The MD5 hash is considered a feature of the content rather than of this object, and is not used in the object hash or equality.

Overrides:
hashCode in class java.lang.Object

DHD Multimedia Gallery V1.57.21

Copyright (c) 1996-2011, Damon Hart-Davis. All rights reserved.