Class SchemaInformation
- Object
-
- SchemaInformation
-
public class SchemaInformation extends Object
Information about types and properties declared in OGC/ISO schemas. This class requires a connection to http://standards.iso.org/iso/19115/-3/ or a local copy of those files.Limitations:
Current implementation ignores the XML prefix (e.g."cit:"
in"cit:CI_Citation"
). We assume that there is no name collision, especially given that"CI_"
prefix in front of most OGC/ISO class names have the effect of a namespace. If a collision nevertheless happen, then an exception will be thrown.Current implementation assumes that XML element name, type name, property name and property type name follow some naming convention. For example type names are suffixed with
"_Type"
in OGC schemas, while property type names are suffixed with"_PropertyType"
. This class throws an exception if a type does not follow the expected naming convention. This requirement makes implementation easier, by reducing the amount ofMap
s that we need to manage.- Since:
- 3.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SchemaInformation.Element
The type and namespace of a property or type.
-
Field Summary
Fields Modifier and Type Field Description static String
ROOT_NAMESPACE
The root of ISO schemas and namespaces, which is "http://standards.iso.org/iso/".
-
Constructor Summary
Constructors Constructor Description SchemaInformation(Path schemaRootDirectory, Departures departures, DocumentationStyle style)
Creates a new verifier.
-
Method Summary
Modifier and Type Method Description Map<String,SchemaInformation.Element>
getTypeDefinition(Class<?> type)
Returns the type definitions for the given class.Map<String,SchemaInformation.Element>
getTypeDefinition(String typeName)
Returns the type definitions for a class of the given name.void
loadDefaultSchemas()
Loads the default set of XSD files.void
loadSchema(String location)
Loads the XSD file at the given URL.
-
-
-
Field Detail
-
ROOT_NAMESPACE
public static final String ROOT_NAMESPACE
The root of ISO schemas and namespaces, which is "http://standards.iso.org/iso/".- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SchemaInformation
public SchemaInformation(Path schemaRootDirectory, Departures departures, DocumentationStyle style)
Creates a new verifier. If the computer contains a local copy of ISO schemas, then theschemaRootDirectory
argument can be set to that directory for faster schema loadings. If non-null, that directory should contain the same files than http://standards.iso.org/iso/ (not necessarily with all sub-directories). In particular, that directory should contain an19115
sub-directory.The
Departures.mergedTypes
entries will be removed as they are found. This allows the caller to verify if the map contains any unnecessary departure declarations.- Parameters:
schemaRootDirectory
- path to local copy of ISO schemas, ornull
if none.departures
- expected departures between XML schemas and GeoAPI annotations.style
- style of the documentation to store (none, verbatim or sentences).
-
-
Method Detail
-
loadDefaultSchemas
public void loadDefaultSchemas() throws ParserConfigurationException, IOException, SAXException, SchemaException
Loads the default set of XSD files. This method invokesloadSchema(String)
for a pre-defined set of metadata schemas, in approximate dependency order.- Throws:
ParserConfigurationException
- if the XML parser can not be created.IOException
- if an I/O error occurred while reading a file.SAXException
- if a file can not be parsed as a XML document.SchemaException
- if a XML document can not be interpreted as an OGC/ISO schema.
-
loadSchema
public void loadSchema(String location) throws ParserConfigurationException, IOException, SAXException, SchemaException
Loads the XSD file at the given URL. Only information of interest are stored, and we assume that the XSD follows OGC/ISO conventions. This method may be invoked recursively if the XSD contains<xs:include>
elements.- Parameters:
location
- complete URL to the XSD file to load.- Throws:
ParserConfigurationException
- if the XML parser can not be created.IOException
- if an I/O error occurred while reading the specified file.SAXException
- if the specified file can not be parsed as a XML document.SchemaException
- if the XML document can not be interpreted as an OGC/ISO schema.
-
getTypeDefinition
public Map<String,SchemaInformation.Element> getTypeDefinition(String typeName)
Returns the type definitions for a class of the given name. Keys are property names and values are their types, with"_PropertyType"
suffix omitted. The map contains an entry associated to thenull
key for the class containing those properties.The given
typeName
shall be the XML name, not the OGC/ISO name. They differ for abstract classes. For example theParty
type is named"CI_Party"
is OGC/ISO models but"AbstractCI_Party"
in XML schemas.- Parameters:
typeName
- XML name of a type (e.g."MD_Metadata"
), ornull
.- Returns:
- all properties for the given class in declaration order, or
null
if unknown.
-
getTypeDefinition
public Map<String,SchemaInformation.Element> getTypeDefinition(Class<?> type)
Returns the type definitions for the given class. This convenience method computes a XML name from the annotations attached to the given type, then delegates togetTypeDefinition(String)
.- Parameters:
type
- the GeoAPI interface (e.g.Metadata
), ornull
.- Returns:
- all properties for the given class in declaration order, or
null
if unknown.
-
-