Class OrderWriter

    • Field Detail

      • CONFIRMED

        public static final java.lang.String CONFIRMED
        Marker for confirmed units
        See Also:
        Constant Field Values
      • CONFIRMEDTEMP

        public static final java.lang.String CONFIRMEDTEMP
        Marker for confirmed TEMP units
        See Also:
        Constant Field Values
      • commentStart

        protected java.lang.String commentStart
    • Constructor Detail

      • OrderWriter

        public OrderWriter​(GameData g,
                           Faction f)
        Creates a new OrderWriter object extracting the orders of faction f's units and writing them to the stream w.
        Parameters:
        g - GameData object ot get orders from.
        f - the faction the orders are written for.
      • OrderWriter

        public OrderWriter​(GameData g,
                           Faction f,
                           java.lang.String echeckOpts)
        Creates a new OrderWriter object extracting the orders of faction f's units and writing them to the stream w with the specified options for E-Check.
        Parameters:
        g - GameData object ot get orders from.
        f - the faction the orders are written for.
        echeckOpts - options for E-Check, default is " -s -l -w4"
      • OrderWriter

        public OrderWriter()
        Creates a new OrderWriter.
    • Method Detail

      • write

        public int write​(java.io.BufferedWriter stream)
                  throws java.io.IOException
        Writes the faction's orders to the stream. World and faction must be set, possibly using setGameData(GameData) and setFaction(Faction).
        Specified by:
        write in interface GameSpecificOrderWriter
        Parameters:
        stream -
        Returns:
        The number of written units
        Throws:
        java.io.IOException - If an I/O error occurs
      • setRemoveComments

        public void setRemoveComments​(boolean semicolon,
                                      boolean slashslash)
        Remove transient (semicolon type) and permanent (// type) comments.
        Specified by:
        setRemoveComments in interface GameSpecificOrderWriter
      • setForceUnixLineBreaks

        public void setForceUnixLineBreaks​(boolean bool)
        Enforce that only Unix-style linebreaks are used. This is necessary when writing to the clipboard under Windows.
        Specified by:
        setForceUnixLineBreaks in interface GameSpecificOrderWriter
      • writeHeader

        protected void writeHeader​(java.io.BufferedWriter stream)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • writeOrderfileStartingString

        protected void writeOrderfileStartingString​(java.io.BufferedWriter stream)
                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • writeLocale

        protected void writeLocale​(java.io.BufferedWriter stream)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • getLocale

        protected java.util.Locale getLocale()
      • getOrderTranslation

        protected java.lang.String getOrderTranslation​(StringID orderId)
      • writeRegions

        protected int writeRegions​(java.util.Collection<? extends Region> writtenRegions,
                                   java.io.BufferedWriter stream)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • writeRegion

        protected int writeRegion​(Region r,
                                  java.util.Collection<Unit> units,
                                  java.io.BufferedWriter stream)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • writeRegionLine

        protected void writeRegionLine​(java.io.BufferedWriter stream,
                                       Region r)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • writeUnit

        protected boolean writeUnit​(Unit unit,
                                    java.io.BufferedWriter stream)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • writeUnitLine

        protected void writeUnitLine​(java.io.BufferedWriter stream,
                                     Unit unit)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • writeOrders

        protected void writeOrders​(java.util.Collection<Order> cmds,
                                   java.io.BufferedWriter stream)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • writeFooter

        protected void writeFooter​(java.io.BufferedWriter stream)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • filterUnits

        protected java.util.Collection<Unit> filterUnits​(java.util.Collection<Unit> units)
      • filterUnit

        protected boolean filterUnit​(Unit u)
      • getTimeStamp

        protected java.lang.String getTimeStamp()
      • rotate

        protected java.lang.String rotate​(java.lang.String str,
                                          int amount)
      • writeln

        protected void writeln​(java.io.BufferedWriter stream,
                               java.lang.String text)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeCommentLine

        protected void writeCommentLine​(java.io.BufferedWriter stream,
                                        java.lang.String line)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • getConfirmedOnly

        public boolean getConfirmedOnly()
        Returns true if only confirmed units written.
      • isWriteTimeStamp

        public boolean isWriteTimeStamp()
        Returns:
        the writeTimeStamp
      • setWriteTimeStamp

        public void setWriteTimeStamp​(boolean writeTimeStamp)
        Parameters:
        writeTimeStamp - the writeTimeStamp to set
      • getSyntaxCheckOptions

        protected java.lang.String getSyntaxCheckOptions()
        Returns the value of syntaxCheckOptions.
        Returns:
        Returns syntaxCheckOptions.