Interface XMLDriver


public interface XMLDriver
Describes an XML conversion driver for Small.

In order to return Objects from Content-annotated, EntryPath-annotated methods, a class that implements this class needs to be in the component search.

Only one component needs to have this role. This is used for conversion if the output content MIME-type is application/xml (and its family types). Unspecified output types are passed to a JSONDriver.

Author:
Matthew Tropiano
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    fromXML(Reader reader, Class<T> type)
    Called when an object needs to be converted to an object from XML.
    default <T> T
    fromXMLString(String xml, Class<T> type)
    Converts an object to a XML string from an object.
    void
    toXML(Writer writer, Object object)
    Called when an object needs to be converted to XML from an object.
    default String
    Converts an object to a XML string from an object.
  • Method Details

    • toXML

      void toXML(Writer writer, Object object) throws IOException
      Called when an object needs to be converted to XML from an object.
      Parameters:
      writer - the writer to write to.
      object - the object to convert and write.
      Throws:
      IOException - if an error occurs during the write.
    • fromXML

      <T> T fromXML(Reader reader, Class<T> type) throws IOException
      Called when an object needs to be converted to an object from XML.
      Type Parameters:
      T - the return type.
      Parameters:
      reader - the provided reader to read XML from.
      type - the incoming type.
      Returns:
      the converted object.
      Throws:
      IOException - if an error occurs during the read.
    • toXMLString

      default String toXMLString(Object retval) throws IOException
      Converts an object to a XML string from an object.
      Parameters:
      retval - the object to convert and write.
      Returns:
      the resultant XML string.
      Throws:
      IOException - if an error occurs during the write.
    • fromXMLString

      default <T> T fromXMLString(String xml, Class<T> type) throws IOException
      Converts an object to a XML string from an object.
      Type Parameters:
      T - the return type.
      Parameters:
      xml - the input XML string.
      type - the incoming type.
      Returns:
      the resultant XML string.
      Throws:
      IOException - if an error occurs during the write.