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

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

final class UploaderProps
extends java.lang.Object

Holder for uploader mutable persistent properties, preferences, etc. Holds a small amount of structured information that can be persisted from one uploader run to the next.

Is thread-safe, though using multiple threads at once, especially mutators, may be confusing.

Not designed to be Serialisable, but instead can be stored in the plain-text Java properties format.

Is designed to be GUI-free.

Package visible since need be seen only by the main GUI class.

TODO: ADD locale

TODO: ADD upload category / main words / number-in-series / type / description


Field Summary
private  boolean changed
          Internal flag to note if any flags have changed.
private  java.io.File fileChooserPathHint
          File chooser directory hint, or null.
static int MAX_PERS_BYTES
          Maximum length (in bytes) expected necessary to persist this data; strictly positive.
private  java.lang.String userID
          User ID (author initials), initially null; null or valid author initials.
 
Constructor Summary
UploaderProps()
           
 
Method Summary
 java.io.File getFileChooserPathHint()
          Get the file chooser directory hint, or null.
 byte[] getPersistentData()
          Get data in properties-file format byte[]; never null.
 byte[] getPersistentDataIfChanged()
          Get data in properties file if properties have changes, else null.
 java.lang.String getUserID()
          Get the user ID (author initials), initially null; null or valid author initials.
 void loadFromPersistentData(java.io.InputStream is)
          Load from previously-generated persistent data format.
 void setFileChooserPathHint(java.io.File pathHint)
          Set the file chooser directory hint, or null.
 void setUserID(java.lang.String authInitials)
          Set the user ID (author initials), null or valid author initials.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_PERS_BYTES

public static final int MAX_PERS_BYTES
Maximum length (in bytes) expected necessary to persist this data; strictly positive.

See Also:
Constant Field Values

changed

private volatile boolean changed
Internal flag to note if any flags have changed. Volatile for thread-safe access without a lock.

Because of possible races this cannot be guaranteed to catch all changes, so a final "save-on-exit" and/or periodic save would be valuable.


userID

private volatile java.lang.String userID
User ID (author initials), initially null; null or valid author initials. Would usually be the last set of initials (ie user ID) used.

Volatile for thread-safe access without a lock.


fileChooserPathHint

private volatile java.io.File fileChooserPathHint
File chooser directory hint, or null. The last directory that a user looked in for files, eg to upload.

Volatile for thread-safe access without a lock.

Constructor Detail

UploaderProps

UploaderProps()
Method Detail

getUserID

public java.lang.String getUserID()
Get the user ID (author initials), initially null; null or valid author initials. Usually be the last set of initials (ie user ID) used to attempt a server connection.


setUserID

public void setUserID(java.lang.String authInitials)
Set the user ID (author initials), null or valid author initials. An attempt to set with an invalid value is treated as if null.


getFileChooserPathHint

public java.io.File getFileChooserPathHint()
Get the file chooser directory hint, or null. The last directory that a user looked in for files, eg to upload.


setFileChooserPathHint

public void setFileChooserPathHint(java.io.File pathHint)
Set the file chooser directory hint, or null.


getPersistentData

public byte[] getPersistentData()
Get data in properties-file format byte[]; never null.


getPersistentDataIfChanged

public byte[] getPersistentDataIfChanged()
Get data in properties file if properties have changes, else null. The changed flag is cleared if this routine returns a non-null value, thus it can be used to save incremental updates asynchronously.


loadFromPersistentData

public void loadFromPersistentData(java.io.InputStream is)
                            throws java.io.IOException
Load from previously-generated persistent data format. Any invalid data is simply ignored.

All updates are done as if through the setXXX() members to validate/coerce them, concurrently with other use of this instance.

Throws:
java.io.IOException

DHD Multimedia Gallery V1.60.69

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