java.lang.Object
java.lang.Enum<OutputType>
org.apache.sis.internal.storage.xml.stream.OutputType
All Implemented Interfaces:
Serializable, Comparable<OutputType>, java.lang.constant.Constable

enum OutputType extends Enum<OutputType>
Creates XMLStreamWriter from a given output. This enumeration allows to analyze the output type only once before to create as many instances of XMLStreamWriter as needed for that output. The enumeration order is the preference order (i.e. we will test if the object already implements the XMLStreamWriter interface before to test for OutputStream, Writer, etc.).
Since:
0.8
Version:
0.8
  • Enum Constant Details

  • Field Details

    • outputType

      private final Class<?> outputType
      The kind of output that this enumeration can handle.
    • inputType

      final InputType inputType
      The input type from the same framework (StAX, DOM, etc) than this output type.
  • Constructor Details

    • OutputType

      private OutputType(Class<?> outputType, InputType inputType)
      Creates a new enumeration for the given type of output.
  • Method Details

    • values

      public static OutputType[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static OutputType valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • create

      abstract XMLStreamWriter create(StaxDataStore ds, Object s) throws XMLStreamException
      Creates a XML writer for the given output.
      Parameters:
      ds - the data store for which to create writer instances.
      s - the output stream or the storage object (URL, etc).
      Returns:
      the XML writer.
      Throws:
      XMLStreamException - if the XML writer creation failed.
    • snapshot

      Closeable snapshot(Object s)
      Returns a reader for the data written by the given writer, or null if we cannot read the data. If non-null, the value returned by this method is a snapshot of the given stream content, i.e. changes in the output stream will not affect the returned input stream or reader. In particular, contrarily to IOUtilities.toInputStream(AutoCloseable) this method does not invalidate the output stream.

      The returned input can be used by inputType.

      Parameters:
      s - the output from which to get the data that we wrote.
      Returns:
      the input for the data written by the given stream, or null if none.
    • forType

      static OutputType forType(Class<?> type)
      Returns a WriterFactory for the given output type. The type argument given to this method shall be the class of the s argument to be given in create(StaxDataStore, Object) calls.
      Parameters:
      type - the type of the output stream or storage object (URL, etc).
      Returns:
      a factory for the given stream or storage type, or null if the given type is not recognized.