au.com.prunge.jgenfile
Class OperationHints

java.lang.Object
  |
  +--au.com.prunge.jgenfile.OperationHints
All Implemented Interfaces:
Map

public class OperationHints
extends Object
implements Map

A set of hints to give operations that may affect their execution.

Operation hints are only hints, in that one, some or all of the hints given to an operation may be ignored.

Version:
1.0
Author:
Peter Runge

Nested Class Summary
static interface OperationHints.Key
          An operation hints key.
static interface OperationHints.Value
          An operation hints value.
 
Field Summary
static OperationHints.Key KEY_PROGRESS_OBSERVING
          Key for specifying whether progress observing is desired for operation execution.
static OperationHints.Value PROGRESS_OBSERVING_DESIRED
          Specifies that progress observation is desired, but should not be used if performance will suffer greatly.
static OperationHints.Value PROGRESS_OBSERVING_HIGHLY_DESIRED
          Specifies that progress observation is important and that every effort should be made to allow the monitoring of progress of operations.
static OperationHints.Value PROGRESS_OBSERVING_UNNEEDED
          Specifies that progress observing need not be supported by operations.
 
Constructor Summary
OperationHints()
          Constructs an OperationHints object with initially no keys and values.
OperationHints(Map hintsMap)
          Constructs an OperationHints with the keys and values in hintsMap
OperationHints(OperationHints.Key key, OperationHints.Value value)
          Constructs an OperationHints with the specified key and value.
 
Method Summary
 void clear()
           
 Object clone()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
protected  Map createHintsMap()
          Creates the internal map used for storing hints in.
 Set entrySet()
           
 boolean equals(Object obj)
           
 Object get(Object key)
           
 int hashCode()
           
 boolean isEmpty()
           
 Set keySet()
           
 Object put(Object key, Object value)
           
 void putAll(Map m)
           
 Object remove(Object key)
           
 int size()
           
 String toString()
           
 Collection values()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

KEY_PROGRESS_OBSERVING

public static final OperationHints.Key KEY_PROGRESS_OBSERVING
Key for specifying whether progress observing is desired for operation execution.

Some operations may need to use additional memory if progress needs to be observed, or might have to sacrifice efficiency.

The default value is PROGRESS_OBSERVING_UNNEEDED.

See Also:
PROGRESS_OBSERVING_HIGHLY_DESIRED, PROGRESS_OBSERVING_DESIRED, PROGRESS_OBSERVING_UNNEEDED

PROGRESS_OBSERVING_HIGHLY_DESIRED

public static final OperationHints.Value PROGRESS_OBSERVING_HIGHLY_DESIRED
Specifies that progress observation is important and that every effort should be made to allow the monitoring of progress of operations.

Use this value instead of PROGRESS_OBSERVING_DESIRED if you are willing to sacrifice performance and memory in order for the operation to be observable.

For example, a file copy operation might need to use slower code to be able to monitor progress instead of faster native code. It might be desirable, however, to monitor progress if the file is large, since the user might not want to wait not knowing what is going on. It might be useful to give the user an option (perhaps in a configuration dialog) as to whether performance should be sacrificed in exchange for the progress bar.


PROGRESS_OBSERVING_DESIRED

public static final OperationHints.Value PROGRESS_OBSERVING_DESIRED
Specifies that progress observation is desired, but should not be used if performance will suffer greatly.


PROGRESS_OBSERVING_UNNEEDED

public static final OperationHints.Value PROGRESS_OBSERVING_UNNEEDED
Specifies that progress observing need not be supported by operations. This is the default value.

Operations might need to use additional memory and have worse perforamance if progress observing is required. If progress will never be observed by the creator of the operation anyway, this allows the operation to not consume resources that would not be needed anyway.

Constructor Detail

OperationHints

public OperationHints(Map hintsMap)
Constructs an OperationHints with the keys and values in hintsMap

Parameters:
hintsMap - a map with OperationHints.Key keys and OperationHints.Value values.

OperationHints

public OperationHints()
Constructs an OperationHints object with initially no keys and values.


OperationHints

public OperationHints(OperationHints.Key key,
                      OperationHints.Value value)
Constructs an OperationHints with the specified key and value.

Parameters:
key - the key to use.
value - the value to use.
Throws:
NullPointerException - if
Method Detail

createHintsMap

protected Map createHintsMap()
Creates the internal map used for storing hints in.

Subclasses may override this method to use a different map implementation. HashMap is used by default.

Returns:
an empty map.

clear

public void clear()
Specified by:
clear in interface Map
See Also:
Map.clear()

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map
See Also:
Map.containsKey(java.lang.Object)

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map
See Also:
Map.containsValue(java.lang.Object)

entrySet

public Set entrySet()
Specified by:
entrySet in interface Map
See Also:
Map.entrySet()

get

public Object get(Object key)
Specified by:
get in interface Map
See Also:
Map.get(java.lang.Object)

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map
See Also:
Map.isEmpty()

keySet

public Set keySet()
Specified by:
keySet in interface Map
See Also:
Map.keySet()

put

public Object put(Object key,
                  Object value)
Specified by:
put in interface Map
See Also:
Map.put(java.lang.Object, java.lang.Object)

putAll

public void putAll(Map m)
Specified by:
putAll in interface Map
See Also:
Map.putAll(java.util.Map)

remove

public Object remove(Object key)
Specified by:
remove in interface Map
See Also:
Map.remove(java.lang.Object)

size

public int size()
Specified by:
size in interface Map
See Also:
Map.size()

values

public Collection values()
Specified by:
values in interface Map
See Also:
Map.values()

clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class Object
CloneNotSupportedException
See Also:
Object.clone()

equals

public boolean equals(Object obj)
Specified by:
equals in interface Map
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Specified by:
hashCode in interface Map
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()