| java.lang.Object org.geotools.metadata.AbstractMetadata org.geotools.metadata.ModifiableMetadata
All known Subclasses: org.geotools.metadata.iso.MetadataEntity,
ModifiableMetadata | abstract public class ModifiableMetadata extends AbstractMetadata implements Cloneable(Code) | | Base class for metadata that may (or may not) be modifiable. Implementations will typically
provide
set*(...) methods for each corresponding
get*() method. An initially
modifiable metadata may become unmodifiable at a later stage (typically after its construction
is completed) by the call to the
ModifiableMetadata.freeze method.
Subclasses should follow the pattern below for every
get and
set methods,
with a special processing for
:
private Foo property;
public Foo getProperty() {
return property;
}
public synchronized void setProperty(Foo newValue) {
;
property = newValue;
}
For collections (note that the call to
ModifiableMetadata.checkWritePermission() is implicit):
private Collection<Foo> properties;
public synchronized Collection<Foo> getProperties() {
return properties =
(properties, Foo.class);
}
public synchronized void setProperties(Collection<Foo> newValues) {
properties =
(newValues, properties, Foo.class);
}
since: 2.4 version: $Id: ModifiableMetadata.java 27848 2007-11-12 13:10:32Z desruisseaux $ author: Martin Desruisseaux |
Constructor Summary | |
protected | ModifiableMetadata() Constructs an initially empty metadata. | protected | ModifiableMetadata(Object source) Constructs a metadata entity initialized with the values from the specified metadata. |
Method Summary | |
protected void | checkWritePermission() Checks if changes in the metadata are allowed. | protected Object | clone() Returns a shallow copy of this metadata.
While
, this class do not provides the
clone() operation as part of the public API. | final protected Collection | copyCollection(Collection source, Collection target, Class elementType) Copies the content of one collection (
source ) into an other (
target ).
If the target collection is
null , or if its type (
List vs
Set )
doesn't matches the type of the source collection, a new target collection is expected.
A call to
ModifiableMetadata.checkWritePermission is implicit before the copy is performed.
Parameters: source - The source collection. | public synchronized void | freeze() Declares this metadata and all its attributes as unmodifiable. | final void | invalidate() Invoked when the metadata changed. | final public boolean | isModifiable() Returns
true if this metadata is modifiable. | final protected Collection | nonNullCollection(Collection c, Class elementType) Returns the specified collection, or a new one if
c is null.
This is a convenience method for implementation of
getFoo() methods.
Parameters: c - The collection to checks. Parameters: elementType - The element type (used only if c is null). | final protected List | nonNullList(List c, Class elementType) Returns the specified list, or a new one if
c is null.
This is a convenience method for implementation of
getFoo() methods.
Parameters: c - The list to checks. Parameters: elementType - The element type (used only if c is null). | public synchronized AbstractMetadata | unmodifiable() Returns an unmodifiable copy of this metadata. | static Object | unmodifiable(Object object) Returns an unmodifiable copy of the specified object. |
ModifiableMetadata | protected ModifiableMetadata()(Code) | | Constructs an initially empty metadata.
|
ModifiableMetadata | protected ModifiableMetadata(Object source) throws ClassCastException, UnmodifiableMetadataException(Code) | | Constructs a metadata entity initialized with the values from the specified metadata.
This constructor behavior is as in
.
Parameters: source - The metadata to copy values from. throws: ClassCastException - if the specified metadata don't implements the expectedmetadata interface. throws: UnmodifiableMetadataException - if this class don't define set methodscorresponding to the get methods found in the implemented interface,or if this instance is not modifiable for some other reason. |
checkWritePermission | protected void checkWritePermission() throws UnmodifiableMetadataException(Code) | | Checks if changes in the metadata are allowed. All
setFoo(...) methods in
subclasses should invoke this method (directly or indirectly) before to apply any
change.
throws: UnmodifiableMetadataException - if this metadata is unmodifiable. |
copyCollection | final protected Collection copyCollection(Collection source, Collection target, Class elementType) throws UnmodifiableMetadataException(Code) | | Copies the content of one collection (
source ) into an other (
target ).
If the target collection is
null , or if its type (
List vs
Set )
doesn't matches the type of the source collection, a new target collection is expected.
A call to
ModifiableMetadata.checkWritePermission is implicit before the copy is performed.
Parameters: source - The source collection. null is synonymous to empty. Parameters: target - The target collection, or null if not yet created. Parameters: elementType - The base type of elements to put in the collection. target , or a newly created collection. throws: UnmodifiableMetadataException - if this metadata is unmodifiable. |
freeze | public synchronized void freeze()(Code) | | Declares this metadata and all its attributes as unmodifiable. This method is invoked
automatically by the
ModifiableMetadata.unmodifiable() method. Subclasses usually don't need to
override it since the default implementation performs its work using Java reflection.
|
invalidate | final void invalidate()(Code) | | Invoked when the metadata changed. Some cached informations will need
to be recomputed.
|
isModifiable | final public boolean isModifiable()(Code) | | Returns
true if this metadata is modifiable. This method returns
false if
ModifiableMetadata.freeze() has been invoked on this object.
|
nonNullCollection | final protected Collection nonNullCollection(Collection c, Class elementType)(Code) | | Returns the specified collection, or a new one if
c is null.
This is a convenience method for implementation of
getFoo() methods.
Parameters: c - The collection to checks. Parameters: elementType - The element type (used only if c is null). c , or a new collection if c is null. |
nonNullList | final protected List nonNullList(List c, Class elementType)(Code) | | Returns the specified list, or a new one if
c is null.
This is a convenience method for implementation of
getFoo() methods.
Parameters: c - The list to checks. Parameters: elementType - The element type (used only if c is null). c , or a new list if c is null. |
unmodifiable | public synchronized AbstractMetadata unmodifiable()(Code) | | Returns an unmodifiable copy of this metadata. Any attempt to modify an attribute of the
returned object will throw an
UnmodifiableMetadataException . If this metadata is
already unmodifiable, then this method returns
this .
The default implementation
this metadata and
the clone before to return it.
An unmodifiable copy of this metadata. |
unmodifiable | static Object unmodifiable(Object object)(Code) | | Returns an unmodifiable copy of the specified object. This method performs the
following heuristic tests:
- If the specified object is an instance of
ModifiableMetadata ,
then
ModifiableMetadata.unmodifiable() is invoked on this object.
- Otherwise, if the object is a
, then the
content is copied into a new collection of similar type, with values replaced
by their unmodifiable variant.
- Otherwise, if the object implements the
org.opengis.util.Cloneable interface, then a clone is returned.
- Otherwise, the object is assumed immutable and returned unchanged.
Parameters: object - The object to convert in an immutable one. A presumed immutable view of the specified object. |
Fields inherited from org.geotools.metadata.AbstractMetadata | final protected static Logger LOGGER(Code)(Java Doc)
|
|
|