org.optaplanner.persistence.xstream.impl.domain.solution

## Class XStreamSolutionFileIO<Solution_>

- java.lang.Object
- - org.optaplanner.persistence.xstream.impl.domain.solution.XStreamSolutionFileIO<Solution_>

- Type Parameters:
    `Solution_` - the solution type, the class with the `PlanningSolution` annotation
  All Implemented Interfaces:
    SolutionFileIO<Solution_>

      public class XStreamSolutionFileIO<Solution_>
      extends Object
      implements SolutionFileIO<Solution_>

  Security warning: only use this class with XML files from a trusted source, because `XStream` is configured to allow all permissions, which can be exploited if the XML comes from an untrusted source.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected com.thoughtworks.xstream.XStream` | `xStream`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XStreamSolutionFileIO(Class... xStreamAnnotatedClasses)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getInputFileExtension()` Every `PlanningSolution` type potentially has its own file extension.
    `com.thoughtworks.xstream.XStream` | `getXStream()`
    `Solution_` | `read(File inputSolutionFile)` This method is thread-safe.
    `Solution_` | `read(InputStream inputSolutionStream)`
    `void` | `write(Solution_ solution, File outputSolutionFile)` This method is thread-safe.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.optaplanner.persistence.common.api.domain.solution.SolutionFileIO

      `getOutputFileExtension`

- - ### Field Detail

    - #### xStream

          protected com.thoughtworks.xstream.XStream xStream

  - ### Constructor Detail

    - #### XStreamSolutionFileIO

          public XStreamSolutionFileIO(Class... xStreamAnnotatedClasses)

  - ### Method Detail

    - #### getXStream

          public com.thoughtworks.xstream.XStream getXStream()

    - #### getInputFileExtension

          public String getInputFileExtension()

      Description copied from interface: `SolutionFileIO`
      Every `PlanningSolution` type potentially has its own file extension. If no specific file extension is defined by the use case, the following are recommended:
      - If this `SolutionFileIO` implementation serializes to XML, use file extension "xml".
      - If this `SolutionFileIO` implementation serializes to text, use file extension "txt".
      - If this `SolutionFileIO` implementation serializes to binary, use file extension "dat".

      It's good practice that both the input and the output file have the same file extension, because a good output file is able to function as an input file. Therefore `SolutionFileIO.getOutputFileExtension()` defaults to returning the same as this method.

      The file extension does not include the dot that separates it from the base name.

      This method is thread-safe.

      Specified by:
        `getInputFileExtension` in interface `SolutionFileIO<Solution_>`
      Returns:
        never null, for example "xml"

    - #### read

          public Solution_ read(File inputSolutionFile)

      Description copied from interface: `SolutionFileIO`
      This method is thread-safe.
      Specified by:
        `read` in interface `SolutionFileIO<Solution_>`
      Parameters:
        `inputSolutionFile` - never null
      Returns:
        never null

    - #### read

          public Solution_ read(InputStream inputSolutionStream)

    - #### write

          public void write(Solution_ solution,
                            File outputSolutionFile)

      Description copied from interface: `SolutionFileIO`
      This method is thread-safe.
      Specified by:
        `write` in interface `SolutionFileIO<Solution_>`
      Parameters:
        `solution` - never null
        `outputSolutionFile` - never null, parent directory already exists

Copyright © 2006–2021 JBoss by Red Hat. All rights reserved.