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

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

final class SelectedFilesDB
extends java.lang.Object

Database of selected files. Package-visible for direct manipulation by GUI classes.

Thread-safe.

A lock can be held on an instance to make compound atomic operations.


Field Summary
private  boolean changed
          Flag set true when the table is changed.
private  java.util.ArrayList<SelectedFileDetails> files
          Ordered random-access list of proposed exhibits to be uploaded; never null.
private  java.util.Set<ROByteArray> hashesMD5
          Set of all MD5 hashes; never null.
private  java.util.Set<java.lang.String> localFilenames
          Set of all local file names; never null.
private  java.util.Set<java.lang.String> shortNames
          Set of all putative short exhibit names; never null.
 
Constructor Summary
SelectedFilesDB()
           
 
Method Summary
(package private)  void add(SelectedFileDetails newFile)
          Add item, silently dropping duplicate file entries if possible.
(package private)  void clear()
          Clear the whole DB.
(package private)  SelectedFileDetails get(int index)
          Get given numbered entry by index; never null.
(package private)  boolean localFilenameInUse(java.lang.String localFilename)
          Returns true if this local name is already in this DB.
(package private)  void remove(int index)
          Remove the indicated item (shuffling any following elements down).
(package private)  boolean remove(SelectedFileDetails selectedFileDetails)
          Remove the indicated item (shuffling any following elements down).
(package private)  void setDescription(int index, java.lang.String newDescription)
          Change the putative exhibit description.
(package private)  void setExhibitName(int index, java.lang.String newFullName)
          Change the putative exhibit name to another new syntatically-valid one.
(package private)  boolean shortNameInUse(java.lang.String shortName)
          Returns true if an exhibit in this DB already has this short name.
(package private)  int size()
          Get number of entries in DB; non-negative.
(package private)  boolean testAndClearChangedFlag()
          Returns the "changed" flag value and clears it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

files

private final java.util.ArrayList<SelectedFileDetails> files
Ordered random-access list of proposed exhibits to be uploaded; never null.


localFilenames

private final java.util.Set<java.lang.String> localFilenames
Set of all local file names; never null.


shortNames

private final java.util.Set<java.lang.String> shortNames
Set of all putative short exhibit names; never null. FIXME: consider converting to Name.ExhibitFull (or ExhibitShort) for smaller memory footprint.


hashesMD5

private final java.util.Set<ROByteArray> hashesMD5
Set of all MD5 hashes; never null.


changed

private boolean changed
Flag set true when the table is changed.

Constructor Detail

SelectedFilesDB

SelectedFilesDB()
Method Detail

add

void add(SelectedFileDetails newFile)
Add item, silently dropping duplicate file entries if possible. Duplicate entries for a given local file or exhibit (short) name will be ignored.

Parameters:
newFile - new file to add; must be null

remove

void remove(int index)
Remove the indicated item (shuffling any following elements down). Silently ignores out-of-range requests.


remove

boolean remove(SelectedFileDetails selectedFileDetails)
Remove the indicated item (shuffling any following elements down). Silently ignores requests where the items is not present.


setExhibitName

void setExhibitName(int index,
                    java.lang.String newFullName)
Change the putative exhibit name to another new syntatically-valid one. Attempting to set it to an invalid or existing (in this DB) name (ignoring the directory component) will be rejected with an exception.

Parameters:
index - entry to be replaced
newFullName - new unique (in this DB) valid exhibit name

setDescription

void setDescription(int index,
                    java.lang.String newDescription)
Change the putative exhibit description.

Parameters:
index - entry to be replaced
newDescription - new description; never null

clear

void clear()
Clear the whole DB.


size

int size()
Get number of entries in DB; non-negative.


get

SelectedFileDetails get(int index)
Get given numbered entry by index; never null.


shortNameInUse

boolean shortNameInUse(java.lang.String shortName)
Returns true if an exhibit in this DB already has this short name.

Parameters:
shortName - never null

localFilenameInUse

boolean localFilenameInUse(java.lang.String localFilename)
Returns true if this local name is already in this DB.

Parameters:
localFilename - never null

testAndClearChangedFlag

boolean testAndClearChangedFlag()
Returns the "changed" flag value and clears it. Can be used to arrange redrawing of a view of this data after an update.


DHD Multimedia Gallery V1.60.69

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