org.geotoolkit.factory
Class Hints.Key

Object
  extended by RenderingHints.Key
      extended by Hints.Key
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Hints.ClassKey, Hints.FileKey, Hints.IntegerKey, Hints.OptionKey
Enclosing class:
Hints

@Immutable
public static class Hints.Key
extends RenderingHints.Key
implements Serializable

The type for keys used to control various aspects of the factory creation. Factory creation impacts rendering (which is why extending rendering key is not a complete non-sense), but may impact other aspects of an application as well.


Serialization
Keys are serializable if the instance to serialize is declared as a public static final constant in the enclosing class. Otherwise, an NotSerializableException will be thrown.

Since:
2.1
Version:
3.05
Author:
Martin Desruisseaux (IRD, Geomatys)
See Also:
Serialized Form
Module:
utility/geotk-utility (download)    View source code for this class

Constructor Summary
Hints.Key(Class<?> classe)
          Constructs a new key for values of the given class.
Hints.Key(String className)
          Constructs a new key for values of the given class.
 
Method Summary
 Class<?> getValueClass()
          Returns the expected class for values stored under this key.
 boolean isCompatibleValue(Object value)
          Returns true if the specified object is a valid value for this key.
 String toString()
          Returns a string representation of this key.
protected  Object writeReplace()
          Invoked on serialization for writing a proxy instead than this Key instance.
 
Methods inherited from class RenderingHints.Key
equals, hashCode, intKey
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Hints.Key

public Hints.Key(Class<?> classe)
Constructs a new key for values of the given class.

Parameters:
classe - The base class for all valid values.

Hints.Key

public Hints.Key(String className)
Constructs a new key for values of the given class. The class is specified by name instead of a Class object. This allows to defer class loading until needed.

Parameters:
className - Name of base class for all valid values.
Since:
3.00
Method Detail

getValueClass

public Class<?> getValueClass()
Returns the expected class for values stored under this key.

Returns:
The class of values stored under this key.

isCompatibleValue

public boolean isCompatibleValue(Object value)
Returns true if the specified object is a valid value for this key. The default implementation checks if the specified value is an instance of the value class.

Note that many hint keys defined in the Hints class relax this rule and accept Class object assignable to the expected value class as well.

Specified by:
isCompatibleValue in class RenderingHints.Key
Parameters:
value - The object to test for validity.
Returns:
true if the value is valid; false otherwise.
See Also:
Hints.ClassKey.isCompatibleValue(Object), Hints.FileKey.isCompatibleValue(Object), Hints.IntegerKey.isCompatibleValue(Object), Hints.OptionKey.isCompatibleValue(Object)

toString

public String toString()
Returns a string representation of this key. This is mostly for debugging purpose. The default implementation tries to infer the key name using reflection.

Overrides:
toString in class Object

writeReplace

protected final Object writeReplace()
                             throws ObjectStreamException
Invoked on serialization for writing a proxy instead than this Key instance. The proxy will use reflection in order to restore the key as one of the static constants defined in the enclosing class on deserialization.

Returns:
The proxy to be serialized instead than this Key.
Throws:
ObjectStreamException - If this key can not be serialized because it is not a known constant.
Since:
3.05


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.