Class AbstractProvider

Direct Known Subclasses:
StaxDataStoreProvider, StoreProvider

public abstract class AbstractProvider extends DocumentedStoreProvider
Base class for providers of DataStore implementations for XML files. This base class does not assume that the data store will use any particular framework (JAXB, StAX, etc).
Since:
0.8
Version:
1.2
  • Field Details

    • MIME_TYPE

      public static final String MIME_TYPE
      The "application/xml" MIME type, used only if probeContent(StorageConnector) cannot determine a more accurate type.
      See Also:
    • READ_AHEAD_LIMIT

      private static final int READ_AHEAD_LIMIT
      The read-ahead limit when reading the XML document from a Reader.
      See Also:
    • mimeForNameSpaces

      protected final Map<String,String> mimeForNameSpaces
      The mapping from XML namespaces to MIME types. This map shall be populated by subclasses at construction time, then never modified anymore since we do not synchronize it.
      Example public MyDataStore() { mimeForNameSpaces.put("http://www.opengis.net/gml/3.2", "application/gml+xml"); mimeForNameSpaces.put("http://www.isotc211.org/2005/gmd", "application/vnd.iso.19139+xml"); mimeForNameSpaces.put("http://www.opengis.net/cat/csw/2.0.2", "application/vnd.ogc.csw_xml"); }
    • mimeForRootElements

      protected final Map<String,String> mimeForRootElements
      The mapping from root elements to MIME types. Used only if the root element is in the default namespace and contains no xmlns attributes for that namespace.
      Example public MyDataStore() { mimeForRootElements.put("MD_Metadata", "application/vnd.iso.19139+xml"); }
  • Constructor Details

    • AbstractProvider

      protected AbstractProvider(String name)
      Creates a new provider. Subclasses shall populate the mimeForNameSpaces map with a mapping from their namespace to the MIME type to declare.
      Parameters:
      name - the primary key to use for searching in the MD_Format table, or null if none.
  • Method Details

    • probeContent

      public ProbeResult probeContent(StorageConnector connector) throws DataStoreException
      Returns the MIME type if the given storage appears to be supported by the data store. A supported status does not guarantee that reading or writing will succeed, only that there appears to be a reasonable chance of success based on a brief inspection of the file header.
      Specified by:
      probeContent in class DataStoreProvider
      Parameters:
      connector - information about the storage (URL, stream, JDBC connection, etc).
      Returns:
      a supported status with the MIME type if the given storage seems to be readable as a XML file.
      Throws:
      DataStoreException - if an I/O error occurred.