Class CsvFilteredResultsProcessor<R>

java.lang.Object
net.solarnetwork.central.support.AbstractFilteredResultsProcessor<R>
net.solarnetwork.central.support.CsvFilteredResultsProcessor<R>
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable, FilteredResultsProcessor<R>

public class CsvFilteredResultsProcessor<R> extends AbstractFilteredResultsProcessor<R>
Basic FilteredResultsProcessor that serializes to CSV.
  • Field Details

    • TEXT_CSV_MIME_TYPE

      public static final org.springframework.util.MimeType TEXT_CSV_MIME_TYPE
      The text/csv MIME type.
    • DEFAULT_JAVA_BEAN_IGNORE_PROPERTIES

      public static final Set<String> DEFAULT_JAVA_BEAN_IGNORE_PROPERTIES
      The default value for the javaBeanIgnoreProperties property.
    • DEFAULT_JAVA_BEAN_STRING_VALUES

      public static final Set<Class<?>> DEFAULT_JAVA_BEAN_STRING_VALUES
      The default value for the javaBeanTreatAsStringValues property.
  • Constructor Details

    • CsvFilteredResultsProcessor

      public CsvFilteredResultsProcessor(Writer out)
      Default constructor.

      The media type will be set to text/csv; the includeHeader property will be set to true.

      Parameters:
      out - the output stream to write to
    • CsvFilteredResultsProcessor

      public CsvFilteredResultsProcessor(Writer out, boolean includeHeader)
      Constructor.

      The media type will be set to text/csv.

      Parameters:
      out - the output stream to write to
      includeHeader - true to include a header rowNum in the output
    • CsvFilteredResultsProcessor

      public CsvFilteredResultsProcessor(Writer out, org.springframework.util.MimeType mimeType, boolean includeHeader, net.solarnetwork.codec.PropertySerializerRegistrar propertySerializerRegistrar)
      Constructor.

      The media type will be set to text/csv.

      Parameters:
      out - the output stream to write to
      mimeType - the MIME type to use
      includeHeader - true to include a header rowNum in the output
      propertySerializerRegistrar - a registrar to serialize properties with
    • CsvFilteredResultsProcessor

      public CsvFilteredResultsProcessor(Writer out, org.springframework.util.MimeType mimeType, boolean includeHeader, net.solarnetwork.codec.PropertySerializerRegistrar propertySerializerRegistrar, Set<String> javaBeanIgnoreProperties, Set<Class<?>> javaBeanTreatAsStringValues)
      Constructor.
      Parameters:
      out - the output stream to write to
      mimeType - the MIME type to use
      includeHeader - true to include a header rowNum in the output
      propertySerializerRegistrar - a registrar to serialize properties with
      javaBeanIgnoreProperties - a set of JavaBean property names to ignore
      javaBeanTreatAsStringValues - a set of JavaBean property names to treat as strings
  • Method Details

    • flush

      public void flush() throws IOException
      Specified by:
      flush in interface Flushable
      Overrides:
      flush in class AbstractFilteredResultsProcessor<R>
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class AbstractFilteredResultsProcessor<R>
      Throws:
      IOException
    • getMimeType

      public org.springframework.util.MimeType getMimeType()
      Description copied from interface: FilteredResultsProcessor
      Get the MIME type generated by this processor.
      Specified by:
      getMimeType in interface FilteredResultsProcessor<R>
      Overrides:
      getMimeType in class AbstractFilteredResultsProcessor<R>
      Returns:
      the media type
    • handleResultItem

      public void handleResultItem(R item) throws IOException
      Description copied from interface: FilteredResultsProcessor
      Process a result item.

      This method should only be called after

      invalid reference
      #start(Long, Integer, Integer)
      has been called.

      Parameters:
      item - the result item to process
      Throws:
      IOException - if an IO error occurs
    • getPropertySerializerRegistrar

      public net.solarnetwork.codec.PropertySerializerRegistrar getPropertySerializerRegistrar()
      Get the property serializer registrar.
      Returns:
      the registrar
    • getJavaBeanIgnoreProperties

      public Set<String> getJavaBeanIgnoreProperties()
      Get the JavaBean properties to ignore.
      Returns:
      the properties
    • getJavaBeanTreatAsStringValues

      public Set<Class<?>> getJavaBeanTreatAsStringValues()
      Get the JavaBean classes to treat as strings.
      Returns:
      the class set
    • isIncludeHeader

      public boolean isIncludeHeader()
      Get the "include header" option.
      Returns:
      true to include a header rowNum in the output; defaults to true