|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectBuilder<SpatialMetadataFormat>
SpatialMetadataFormatBuilder
public class SpatialMetadataFormatBuilder
Creates new spatial metadata format instances. This class
infers the tree structure from metadata objects defined by some metadata standard, typically ISO 19115-2. New metadata elements are declared by calls to the
generic addTree method, or one of its specialized variants like
addTreeForImage(String).
This builder is used for creating the default trees documented here. Users can leverage this builder for creating trees based on interfaces from other standards.
| coverage/geotk-coverageio (download) | View source code for this class |
| Constructor Summary | |
|---|---|
SpatialMetadataFormatBuilder(Class<? extends SpatialMetadataFormat> type)
Creates a builder for a metadata format of the given type. |
|
SpatialMetadataFormatBuilder(String rootName)
Creates a builder for a metadata format of the given name. |
|
| Method Summary | |
|---|---|
void |
addTree(MetadataStandard standard,
Class<?> type)
Adds a new optional element or attribute of the given type as a child of the root. |
void |
addTree(MetadataStandard standard,
Class<?> type,
String elementName,
String parentName,
boolean mandatory)
Adds a new element or attribute of the given type and name as a child of the given node. |
protected void |
addTreeForCRS(String addToElement)
Adds the tree structure for a Coordinate Reference System object. |
void |
addTreeForImage(String addToElement)
Adds the tree structure for image metadata. |
protected void |
addTreeForISO19115(String addToElement)
Adds the tree structure for an ISO-19115 metadata object. |
void |
addTreeForStream(String addToElement)
Adds the tree structure for stream metadata. |
SpatialMetadataFormat |
build()
Returns the metadata format instance which has been build. |
Map<Class<?>,Class<?>> |
substitutions()
The map of children types to substitute by other types. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SpatialMetadataFormatBuilder(String rootName)
SpatialMetadataFormat.
rootName - the name of the root element.
public SpatialMetadataFormatBuilder(Class<? extends SpatialMetadataFormat> type)
throws InstantiationException,
IllegalAccessException
Note:
We do not provide a constructor accepting directly an instance, because it would
provide a way to alter an already published SpatialMetadataFormat instance.
type - The type of the metadata format to instantiate.
IllegalAccessException - If the class or its no-argument constructor is not accessible.
InstantiationException - If the instantiation fails.| Method Detail |
|---|
public Map<Class<?>,Class<?>> substitutions()
addTree method.
If this map is non empty, then every occurrence of a class in the set of keys is replaced by the associated class in the collection of values. The purpose of this map is to:
Replace a base class by some specialized subclass. Since IIOMetadata is
about grided data (not generic Features), the exact subtype is often known at
compile time, and we want the additional attributes to be declared unconditionally.
Example:
substitutions().put(RangeDimension.class, Band.class);
Exclude a particular class by setting the replacement to null. This is used
for excluding large tree of metadata which may not be applicable. Example:
substitutions().put(Objective.class, null);
Replace an element class (including the whole tree behind it) by a single attribute.
This simplification is especially useful for Citation because they typically appear
in many different places with the same name ("citation"), while Image I/O does
not allow many elements to have the same name (actually this is not strictly forbidden, but
the getter methods return information only about the first occurrence of a given name).
Converting an element to an attribute allow it to appear with the same name under different
nodes, and can make the tree considerably simpler (at the cost of losing all the sub-tree
below the converted element). Example:
substitutions().put(Citation.class, String.class);
Replace a collection by a singleton, by setting the source type to an array and the target type to the element of that array. This is useful when a collection seems an overkill for the specific case of stream or image metadata. Example:
substitutions().put(Identification[].class, Identification.class);
null).
public void addTree(MetadataStandard standard,
Class<?> type)
addTree(MetadataStandard, Class, String, String, boolean),
except that the element is added at the root and the name is inferred from the given type
for convenience.
standard - The metadata standard of the element or attribute to be added.type - The type of the element or attribute to be added.
public void addTree(MetadataStandard standard,
Class<?> type,
String elementName,
String parentName,
boolean mandatory)
Element type
This method expects a type argument, which can be a CodeList subclass,
one of the interfaces member of the given metadata standard, or a simple JSE
type (boolean, number of String). Do not specify collection
types, since the type of collection elements can not be inferred easily. To specify
a multi-occurrence, use the array type instead (e.g. CoordinateSystemAxis[].class).
Substitution map
The substitution map applies only to children (if any),
not to the type given directly to this method.
standard - The metadata standard of the element or attribute to be added.type - The type of the element or attribute to be added (see javadoc).elementName - The name of the element or attribute node to be added.parentName - The name of the parent node to where to add the child.mandatory - true if the element should be mandatory, or false
if optional.protected void addTreeForISO19115(String addToElement)
NetcdfImageReader.
addToElement - The name of the element where to add the tree,
or null for adding the tree at the root.SpatialMetadataFormat.ISO_FORMAT_NAMEpublic void addTreeForStream(String addToElement)
SpatialMetadataFormat
javadoc.
addToElement - The name of the element where to add the tree,
or null for adding the tree at the root.SpatialMetadataFormat.getStreamInstance(String)public void addTreeForImage(String addToElement)
The Coordinate Reference System branch is not included by this method.
For including CRS information, the addTreeForCRS(String) method shall be
invoked explicitly.
addToElement - The name of the element where to add the tree,
or null for adding the tree at the root.SpatialMetadataFormat.getImageInstance(String)protected void addTreeForCRS(String addToElement)
addToElement - The name of the element where to add the tree,
or null for adding the tree at the root.public SpatialMetadataFormat build()
build in class Builder<SpatialMetadataFormat>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||