Class JECheck

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.Readable

    public class JECheck
    extends java.io.Reader
    A class for executing ECheck and reading the output returned.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  JECheck.ECheckMessage
      A class representing a message as it produced by ECheck.
    • Field Summary

      • Fields inherited from class java.io.Reader

        lock
    • Constructor Summary

      Constructors 
      Constructor Description
      JECheck​(java.io.File eCheckExe, java.io.File orders, java.lang.String options, java.util.Properties settings)
      Creates a new JECheck object by executing ECheck with the specified parameters and making its output accessible through the Reader interface.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean checkVersion​(java.io.File eCheckExe, java.util.Properties settings)
      Checks whether the version of the specified ECheck executable is valid and its output can be processed.
      void close()
      Closes the reader on the output of ECheck.
      static java.util.Collection<JECheck.ECheckMessage> determineAffectedObjects​(GameData data, java.io.File orderFile, java.util.List<JECheck.ECheckMessage> messages)
      Determines the Unit or Region referenced in an ECheck message by looking at the orders the ECheck messages were generated from.
      static JECheck.ECheckMessage getHelp​(java.io.File eCheckExe, java.util.Properties settings)
      Returns what ECheck returns when called with the -h option.
      static java.util.Collection<JECheck.ECheckMessage> getMessages​(java.io.File eCheckExe, java.io.File orders, java.lang.String options, java.util.Properties settings)
      Runs ECheck with the specified parameters and returns the error and warning messages it reported.
      static java.util.Collection<JECheck.ECheckMessage> getMessages​(java.io.Reader echeckOutput)
      Returns a collection containing JECheck.ECheckMessage objects by reading from the specified reader.
      static Version getRequiredVersion()
      Returns the oldest version of ECheck that is required by this class to process the orders correctly.
      static Version getVersion​(java.io.File eCheckExe, java.util.Properties settings)
      Returns the version of the specified ECheck executable file.
      void mark​(int readAheadLimit)
      Mark the present position in the stream.
      boolean markSupported()
      Tell whether this stream supports the mark() operation.
      int read​(char[] cbuf, int off, int len)
      Reads from the output of ECheck.
      boolean ready()
      Tell whether this stream is ready to be read.
      void reset()
      Reset the stream.
      long skip​(long n)
      Skip characters.
      • Methods inherited from class java.io.Reader

        nullReader, read, read, read, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JECheck

        public JECheck​(java.io.File eCheckExe,
                       java.io.File orders,
                       java.lang.String options,
                       java.util.Properties settings)
                throws java.io.IOException
        Creates a new JECheck object by executing ECheck with the specified parameters and making its output accessible through the Reader interface.
        Parameters:
        eCheckExe - a file specifying the ECheck executable. It is assumed that the files items.txt and zauber.txt are located in same directory as the executable itself.
        orders - the file containing the orders to be parsed by ECheck. If orders is null ECheck is executed without a specified orders file.
        options - additional options to be passed to ECheck to control its operation and output.
        settings - the settings of the client, needed to find out about forced ISO encod
        Throws:
        java.io.IOException - DOCUMENT-ME
    • Method Detail

      • read

        public int read​(char[] cbuf,
                        int off,
                        int len)
                 throws java.io.IOException
        Reads from the output of ECheck.
        Specified by:
        read in class java.io.Reader
        Throws:
        java.io.IOException - DOCUMENT-ME
      • close

        public void close()
                   throws java.io.IOException
        Closes the reader on the output of ECheck.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in class java.io.Reader
        Throws:
        java.io.IOException - DOCUMENT-ME
      • mark

        public void mark​(int readAheadLimit)
                  throws java.io.IOException
        Mark the present position in the stream. Subsequent calls to reset() will attempt to reposition the stream to this point. Not all character-input streams support the mark() operation.
        Overrides:
        mark in class java.io.Reader
        Parameters:
        readAheadLimit - Limit on the number of characters that may be read while still preserving the mark. After reading this many characters, attempting to reset the stream may fail.
        Throws:
        java.io.IOException - If the stream does not support mark(), or if some other I/O error occurs.
      • markSupported

        public boolean markSupported()
        Tell whether this stream supports the mark() operation.
        Overrides:
        markSupported in class java.io.Reader
      • ready

        public boolean ready()
                      throws java.io.IOException
        Tell whether this stream is ready to be read.
        Overrides:
        ready in class java.io.Reader
        Returns:
        True if the next read() is guaranteed not to block for input, false otherwise. Note that returning false does not guarantee that the next read will block.
        Throws:
        java.io.IOException - If an I/O error occurs
      • reset

        public void reset()
                   throws java.io.IOException
        Reset the stream. If the stream has been marked, then attempt to reposition it at the mark. If the stream has not been marked, then attempt to reset it in some way appropriate to the particular stream, for example by repositioning it to its starting point. Not all character-input streams support the reset() operation, and some support reset() without supporting mark().
        Overrides:
        reset in class java.io.Reader
        Throws:
        java.io.IOException - If the stream has not been marked, or if the mark has been invalidated, or if the stream does not support reset(), or if some other I/O error occurs
      • skip

        public long skip​(long n)
                  throws java.io.IOException
        Skip characters. This method will block until some characters are available, an I/O error occurs, or the end of the stream is reached.
        Overrides:
        skip in class java.io.Reader
        Parameters:
        n - The number of characters to skip
        Returns:
        The number of characters actually skipped
        Throws:
        java.io.IOException - If an I/O error occurs
      • getMessages

        public static java.util.Collection<JECheck.ECheckMessage> getMessages​(java.io.File eCheckExe,
                                                                              java.io.File orders,
                                                                              java.lang.String options,
                                                                              java.util.Properties settings)
                                                                       throws java.io.IOException,
                                                                              java.text.ParseException
        Runs ECheck with the specified parameters and returns the error and warning messages it reported. For reference for the parameters see the constructor. This method requires that the specified echeck executable not older than the version returned by getRequiredVersion().
        Returns:
        a collection containing JECheck.ECheckMessage objects.
        Throws:
        java.io.IOException - DOCUMENT-ME
        java.text.ParseException - DOCUMENT-ME
      • getMessages

        public static java.util.Collection<JECheck.ECheckMessage> getMessages​(java.io.Reader echeckOutput)
                                                                       throws java.io.IOException,
                                                                              java.text.ParseException
        Returns a collection containing JECheck.ECheckMessage objects by reading from the specified reader. This method requires that the specified echeck executable not older than the version returned by getRequiredVersion().
        Returns:
        a collection containing JECheck.ECheckMessage objects.
        Throws:
        java.io.IOException - DOCUMENT-ME
        java.text.ParseException - DOCUMENT-ME
      • determineAffectedObjects

        public static java.util.Collection<JECheck.ECheckMessage> determineAffectedObjects​(GameData data,
                                                                                           java.io.File orderFile,
                                                                                           java.util.List<JECheck.ECheckMessage> messages)
                                                                                    throws java.io.IOException
        Determines the Unit or Region referenced in an ECheck message by looking at the orders the ECheck messages were generated from.
        Parameters:
        data - the game data the orders belong to and from which the Unit or Region can be retrieved.
        orderFile - a file containing the orders that ECheck was run on when it produced the specified message.
        messages - the messages to be processed.
        Returns:
        the collection of input messages with their affected objects fields set if possible.
        Throws:
        java.io.IOException - DOCUMENT-ME
        java.lang.IllegalArgumentException - DOCUMENT-ME
      • getHelp

        public static JECheck.ECheckMessage getHelp​(java.io.File eCheckExe,
                                                    java.util.Properties settings)
                                             throws java.io.IOException
        Returns what ECheck returns when called with the -h option.
        Parameters:
        eCheckExe -
        settings -
        Throws:
        java.io.IOException
      • getVersion

        public static Version getVersion​(java.io.File eCheckExe,
                                         java.util.Properties settings)
                                  throws java.io.IOException
        Returns the version of the specified ECheck executable file.
        Throws:
        java.io.IOException - DOCUMENT-ME
      • checkVersion

        public static boolean checkVersion​(java.io.File eCheckExe,
                                           java.util.Properties settings)
                                    throws java.io.IOException
        Checks whether the version of the specified ECheck executable is valid and its output can be processed.
        Throws:
        java.io.IOException - DOCUMENT-ME
      • getRequiredVersion

        public static Version getRequiredVersion()
        Returns the oldest version of ECheck that is required by this class to process the orders correctly.