SpartanUtil
Date: 2019-10-22

org.jmol.adapter.readers.spartan

## Class SpartanUtil

- java.lang.Object
- - org.jmol.adapter.readers.spartan.SpartanUtil

-     public class SpartanUtil
      extends java.lang.Object

  A class to isolate Spartan file reading methods from the rest of Jmol. Two public methods: getFileList and getData

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `FileManager` | `fm`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SpartanUtil()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `javajs.util.SB` | `getData(java.io.InputStream is, java.lang.String[] zipDirectory)` called by SmarterJmolAdapter via JmolUtil to open a Spartan directory and get all the needed data as a string.
    `java.lang.Object` | `getFileList(java.lang.String name, boolean isTypeCheckOnly)` get a complete critical file list for a spartan file Mac directory based on file extension ".spardir.zip" or ".spardir"
    `private java.lang.String[]` | `getSpartanDirs(java.lang.String outputFileData)` read the output file from the Spartan directory and decide from that what files need to be read and in what order - usually M0001 or a set of Profiles.
    `private java.lang.String[]` | `getSpartanFileList(java.lang.String name, java.lang.String[] dirNums)` returns the list of files to read for every Spartan spardir.
    `SpartanUtil` | `set(FileManager fm)`
    `private java.lang.String[]` | `spartanFileList(java.lang.String name, java.lang.String outputFileData)` Special loading for file directories.
    `private java.lang.String` | `spartanGetObjectAsSections(java.lang.String name, java.lang.String header, java.util.Map<java.lang.String,java.lang.String> fileData)` delivers file contents and directory listing for a ZIP/JAR file into sb

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

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

- - ### Field Detail

    - #### fm

          public FileManager fm

  - ### Constructor Detail

    - #### SpartanUtil

          public SpartanUtil()

  - ### Method Detail

    - #### set

          public SpartanUtil set(FileManager fm)

    - #### getFileList

          public java.lang.Object getFileList(java.lang.String name,
                                              boolean isTypeCheckOnly)

      get a complete critical file list for a spartan file Mac directory based on file extension ".spardir.zip" or ".spardir"
      Parameters:
        `name` -
        `isTypeCheckOnly` -
      Returns:
        critical files list if just checking type or a buffered reader for a String containing all data

    - #### getData

          public javajs.util.SB getData(java.io.InputStream is,
                                        java.lang.String[] zipDirectory)

      called by SmarterJmolAdapter via JmolUtil to open a Spartan directory and get all the needed data as a string.
      Parameters:
        `is` -
        `zipDirectory` -
      Returns:
        String data for processing

    - #### spartanFileList

          private java.lang.String[] spartanFileList(java.lang.String name,
                                                     java.lang.String outputFileData)

      Special loading for file directories. This method is called from the FileManager via SmarterJmolAdapter. It's here because Resolver is the place where all distinctions are made. In the case of spt files, no need to load them; here we are just checking for type. In the case of .spardir directories, we need to provide a list of the critical files that need loading and concatenation for the SpartanSmolReader. we return an array for which: [0] file type (class prefix) or null for SPT file [1] header to add for each BEGIN/END block (ignored) [2...] files to load and concatenate
      Parameters:
        `name` -
        `outputFileData` -
      Returns:
        array detailing action for this set of files

    - #### getSpartanDirs

          private java.lang.String[] getSpartanDirs(java.lang.String outputFileData)

      read the output file from the Spartan directory and decide from that what files need to be read and in what order - usually M0001 or a set of Profiles. But Spartan saves the Profiles in alphabetical order, not numerical. So we fix that here.
      Parameters:
        `outputFileData` -
      Returns:
        String[] list of files to read

    - #### getSpartanFileList

          private java.lang.String[] getSpartanFileList(java.lang.String name,
                                                        java.lang.String[] dirNums)

      returns the list of files to read for every Spartan spardir. Simple numbers are assumed to be Profiles; others are models.
      Parameters:
        `name` -
        `dirNums` -
      Returns:
        String[] list of files to read given a list of directory names

    - #### spartanGetObjectAsSections

          private java.lang.String spartanGetObjectAsSections(java.lang.String name,
                                                              java.lang.String header,
                                                              java.util.Map<java.lang.String,java.lang.String> fileData)

      delivers file contents and directory listing for a ZIP/JAR file into sb
      Parameters:
        `name` -
        `header` -
        `fileData` -
      Returns:
        name of entry