Class CRWriter

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

    public class CRWriter
    extends java.io.BufferedWriter
    A class for writing game data, or parts of it, to a stream in the computer report format.

    The generated output has platform dependent line breaks.

    Implementation notes:

    The basic mechanism of this class is to overload the write() method for most of the Eressea base classes. Since many blocks and tags come in bunches there are helper functions for each such sequence handling the collections in which the data objects are stored in.

    • Field Summary

      • Fields inherited from class java.io.Writer

        lock
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      protected void doWrite()
      Write the complete game data from world in the cr format.
      boolean getExportHotspots()
      Returns whether doWrite() writes Hotspots contained in the game data to the underlying stream.
      boolean getIncludeBuildings()
      Returns whether doWrite() writes information about the buildings in data to the underlying stream.
      boolean getIncludeIslands()
      Returns whether doWrite() writes information about islands to the underlying stream.
      boolean getIncludeItems()
      Returns true if items will be written.
      boolean getIncludeMessages()
      Returns whether doWrite() writes messages contained in the game data to the underlying stream.
      boolean getIncludeOrders()
      Returns true if the unit's orders will be included in writing.
      boolean getIncludeRegionDetails()
      Returns whether doWrite() writes detailed information about the regions in data to the underlying stream.
      boolean getIncludeRegions()
      Returns whether doWrite() writes information about the regions in data to the underlying stream.
      boolean getIncludeShips()
      Returns whether doWrite() writes information about the ships in data to the underlying stream.
      boolean getIncludeSkills()
      Returns true if units' skills will be written.
      boolean getIncludeSpellsAndPotions()
      Returns whether doWrite() writes messages contained in the game data to the underlying stream.
      boolean getIncludeUnitDetails()
      Returns true if details of unit's will be included in the written report.
      boolean getIncludeUnits()
      Returns whether doWrite() writes information about the units in data to the underlying stream.
      java.util.Collection<Region> getRegions()
      Returns the regions this object writes to the underlying stream.
      boolean getServerConformance()
      Returns whether doWrite() writes a cr that is compatible with cr's generated by the Eressea server, i.e. not including JavaClient specific data.
      java.util.Collection<Unit> getUnits()
      Returns the units this object writes to the underlying stream.
      boolean savingInProgress()
      Returns true if writing has begun, but not finished
      void setExportHotspots​(boolean exportHotspots)
      Toggles whether doWrite() writes Hotspots contained in the game data to the underlying stream.
      void setIncludeBuildings​(boolean includeBuildings)
      Toggles whether doWrite() writes information about the buildings in data to the underlying stream.
      void setIncludeIslands​(boolean includeIslands)
      Toggles whether doWrite() writes information about islands to the underlying stream.
      void setIncludeItems​(boolean newValue)
      Toggles whether doWrite() writes information about the unit skills in data to the underlying stream.
      void setIncludeMessages​(boolean includeMessages)
      Toggles whether doWrite() writes messages contained in the game data to the underlying stream.
      void setIncludeOrders​(boolean newValue)
      Toggles whether doWrite() writes the units' orders in data to the underlying stream.
      void setIncludeRegionDetails​(boolean includeRegionDetails)
      Toggles whether doWrite() writes detailed information about the regions in data to the underlying stream.
      void setIncludeRegions​(boolean includeRegions)
      Toggles whether doWrite() writes information about the regions in data to the underlying stream.
      void setIncludeShips​(boolean includeShips)
      Toggles whether doWrite() writes information about the ships in data to the underlying stream.
      void setIncludeSkills​(boolean newValue)
      Toggles whether doWrite() writes information about the unit skills in data to the underlying stream.
      void setIncludeSpellsAndPotions​(boolean includeSpellsAndPotions)
      Toggles whether doWrite() writes messages contained in the game data to the underlying stream.
      void setIncludeUnitDetails​(boolean newValue)
      Toggles whether doWrite() writes information about the unit skills in data to the underlying stream.
      void setIncludeUnits​(boolean includeUnits)
      Toggles whether doWrite() writes information about the units in data to the underlying stream.
      void setRegions​(java.util.Collection<Region> regions)
      Supply the writer with a collection of regions it should write to the underlying stream instead of all regions contained in the game data.
      void setServerConformance​(boolean serverConformance)
      Toggles whether doWrite() writes a cr that is compatible with cr's generated by the Eressea server, i.e. not including JavaClient specific data.
      void setTildeEscapes​(boolean bool)
      Change the quote escape behaviour of this CRWriter.
      void setUnits​(java.util.Collection<Unit> units)
      Supply the writer with a collection of units it should write to the underlying stream instead of all units contained in the game data.
      void write​(Alliance alliance)
      Write the cr representation of an Alliance object to the underlying stream.
      void write​(Battle battle)
      Write the cr representation of a Battle object to the underlying stream.
      void write​(CombatSpell cs)
      Write the cr representation of a CombatSpell object to the underlying stream.
      void write​(Island island)
      Write the cr representation of an Island object to the underlying stream.
      void write​(Item item)
      Write the cr representation of a Item object to the underlying stream.
      void write​(LuxuryPrice price)
      Write the cr representation of a LuxuryPrice object to the underlying stream.
      void write​(Potion potion)
      Write the cr representation of a Potion object to the underlying stream.
      void write​(Options options)
      Write the cr representation of a Option object to the underlying stream.
      void write​(Spell spell)
      Write the cr representation of a Spell object to the underlying stream.
      void writeAlliances​(java.util.Map<EntityID,​Alliance> map)
      Write a sequence of alliance (ALLIANZ) blocks to the underlying stream.
      java.lang.Thread writeAsynchronously()
      Write the complete game data from world in the cr format.
      void writeAttributes​(Addeable addeable)
      Writes all attributes to the stream
      void writeBattles​(java.util.List<Battle> list)
      Write a sequence of battle (BATTLE) blocks to the underlying stream.
      protected void writeBookmark​(Selectable selection)  
      void writeBorder​(Border border)
      Write the cr representation of a Border object to the underlying stream.
      void writeBorders​(java.util.Collection<Border> c)
      Write a sequence of region border (GRENZE) blocks to the underlying stream.
      void writeBuilding​(Building building)
      Write the cr representation of a Building object to the underlying stream.
      void writeBuildings​(java.util.Collection<Building> buildings)
      Write a sequence of building (BURG) blocks to the underlying stream.
      void writeFaction​(Faction faction, boolean noDetails)
      Write the cr representation of a Faction object to the underlying stream.
      void writeFactions​(java.util.Collection<Faction> factions, boolean noDetails)
      Write a sequence of faction (PARTEI) blocks to the underlying stream.
      void writeGroup​(Group group)
      Write the cr representation of a Group object to the underlying stream.
      void writeGroups​(java.util.Map<? extends ID,​Group> map)
      Write a sequence of group (GRUPPE) blocks to the underlying stream.
      void writeIslands​(java.util.Collection<Island> islands)
      Write a sequence of island blocks to the underlying stream.
      void writeItems​(java.util.Iterator<Item> items)
      Write a unit's items (GEGENSTAENDE) block to the underlying stream.
      void writeMessage​(Message msg)
      Write the cr representation of a Message object to the underlying stream.
      void writeMessageBlock​(java.lang.String blockName, java.util.Collection<Message> data)
      Write the data as one block named blockName to the underlying stream.
      void writeMessages​(java.util.List<Message> list)
      Write a sequence of message blocks to the underlying stream.
      void writeMessageSequence​(java.util.Collection<Message> data)
      Write the data as one sequence of simple cr strings.
      void writeMessageType​(MessageType msgType)
      Write the cr representation of a MessageType object to the underlying stream.
      void writeMsgTypes​(java.util.Map<? extends ID,​MessageType> map)
      Write message type blocks to the underlying stream.
      void writeOldPrices​(java.util.Map<? extends ID,​LuxuryPrice> map)
      Write region block containing the luxury prices of the last turn (LETZTEPREISE) to the underlying stream.
      void writeOldUnits​(java.util.Map<Region,​java.util.List<Unit>> oldUnitMap2, Region region)
      Write a sequence of old unit (ALTEINHEIT) blocks for the given region to the underlying stream.
      void writeOrders​(java.util.List<Order> list)
      Write a COMMANDS block to the underlying stream.
      void writePotionIngredients​(java.util.Collection<Item> ingredients)
      Writes the ingredients of a potion as a ZUTATEN block to the underlying stream.
      void writePotions​(java.util.Collection<Potion> potions)
      Write a sequence of potion (TRANK) blocks to the underlying stream.
      void writePrices​(java.util.Map<? extends ID,​LuxuryPrice> map)
      Write a region prices (PREISE) block to the underlying stream.
      void writeRegion​(Region region)
      Write the cr representation of a Region object to the underlying stream.
      void writeRegionResource​(RegionResource res)
      Writes the cr representation of a region resource object to the underlying stream.
      void writeRegionResources​(java.util.Collection<RegionResource> resources)
      Write a collection of region resources to the underlying stream
      void writeRegions​(java.util.Collection<Region> regions)
      Write a sequence of region (REGION) blocks to the underlying stream.
      void writeScheme​(Scheme scheme)
      Writes the cr representation of a Scheme object to the underlying stream.
      void writeSchemes​(java.util.Collection<Scheme> schemes)
      Write a collection of schemes to the underlying stream
      void writeShip​(Ship ship)
      Write the cr representation of a Ship object to the underlying stream.
      void writeShips​(java.util.Collection<Ship> ships)
      Write a sequence of ship (SCHIFF) blocks to the underlying stream.
      void writeSkill​(Skill skill, int persons)
      Write the cr representation of a Skill object to the underlying stream.
      void writeSkills​(java.util.Iterator<Skill> skills, int persons)
      Write a skills (TALENTE) block to the underlying stream.
      void writeSpellComponents​(java.util.Map<java.lang.String,​java.lang.String> comps)
      Write a spell components (KOMPONENTEN) block to the underyling.
      void writeSpells​(java.util.Collection<Spell> spells)
      Write a spells (ZAUBER) block to the underlying stream.
      void writeStringBlock​(java.lang.String blockName, java.util.Collection<java.lang.String> data)
      Write the data as one block named blockName to the underlying stream.
      void writeStringSequence​(java.util.Collection<java.lang.String> data)
      Write a the data as one sequence of simple cr strings.
      void writeSynchronously()
      Writes the GameData in the current thread.
      void writeTranslations​(Translations m)
      Write the translation table to underlying stream.
      void writeUnit​(Unit unit)
      Write the cr representation of a Unit object to the underyling
      void writeUnit​(Unit unit, boolean old)
      Write the cr representation of a Unit object to the underyling
      void writeUnitCombatSpells​(java.util.Map<? extends ID,​CombatSpell> map)
      Write a unit's combat spell (KAMPFZAUBER) blocks to the underlying stream.
      void writeUnits​(java.util.Collection<Unit> units)
      Write a sequence of unit (EINHEIT) blocks to the underlying stream.
      void writeUnitSpells​(java.util.Map<? extends ID,​Spell> spells)
      Write a unit's spell (SPRUECHE) block to the underlying stream.
      void writeVersion​(GameData world)
      Write the VERSION block for the specified game data to the underyling
      • Methods inherited from class java.io.BufferedWriter

        flush, newLine, write, write, write
      • Methods inherited from class java.io.Writer

        append, append, append, nullWriter, write, write
      • Methods inherited from class java.lang.Object

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

      • CRWriter

        public CRWriter​(GameData data,
                        UserInterface ui,
                        java.io.Writer out)
        Creates a CR writer which uses the specified writer.
        Parameters:
        out - the writer used for output to.
        Throws:
        java.lang.NullPointerException - if data is null.
      • CRWriter

        public CRWriter​(GameData data,
                        UserInterface ui,
                        FileType fileType,
                        java.lang.String encoding)
                 throws java.io.IOException
        Creates a CR writer that writes to the specified file.
        Parameters:
        ui - Interface for feedback. May be null.
        fileType - the filetype to write to
        encoding - The name of a supported charset
        Throws:
        java.io.IOException - If the file cannot be opened for writing.
      • CRWriter

        public CRWriter​(GameData data,
                        UserInterface ui,
                        FileType fileType,
                        java.lang.String encoding,
                        int numberOfBackups)
                 throws java.io.IOException
        Creates a CR writer that writes to the specified file.
        Parameters:
        ui - Interface for feedback. May be null.
        fileType - the filetype to write to
        encoding - The name of a supported charset
        numberOfBackups -
        Throws:
        java.io.IOException - If the file cannot be opened for writing.
    • Method Detail

      • writeMessages

        public void writeMessages​(java.util.List<Message> list)
                           throws java.io.IOException
        Write a sequence of message blocks to the underlying stream.
        Parameters:
        list - a list containing the Message objects to be written.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeMessage

        public void writeMessage​(Message msg)
                          throws java.io.IOException
        Write the cr representation of a Message object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeMessageBlock

        public void writeMessageBlock​(java.lang.String blockName,
                                      java.util.Collection<Message> data)
                               throws java.io.IOException
        Write the data as one block named blockName to the underlying stream. The data is written as simple cr strings. The block name is only written if there is data to follow.
        Parameters:
        blockName - the name of the block to be written (can not be a block with an id).
        data - a collection containing Message objects.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeMessageSequence

        public void writeMessageSequence​(java.util.Collection<Message> data)
                                  throws java.io.IOException
        Write the data as one sequence of simple cr strings.
        Parameters:
        data - a collection containing Message objects.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeStringSequence

        public void writeStringSequence​(java.util.Collection<java.lang.String> data)
                                 throws java.io.IOException
        Write a the data as one sequence of simple cr strings.
        Parameters:
        data - a collection containing String objects.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeStringBlock

        public void writeStringBlock​(java.lang.String blockName,
                                     java.util.Collection<java.lang.String> data)
                              throws java.io.IOException
        Write the data as one block named blockName to the underlying stream. The data is written as simple cr strings. The block name is only written if there is data to follow.
        Parameters:
        blockName - the name of the block to be written (can not be a block with an id).
        data - a colleciton containing String objects.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeVersion

        public void writeVersion​(GameData world)
                          throws java.io.IOException
        Write the VERSION block for the specified game data to the underyling
        Parameters:
        world -
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeSpells

        public void writeSpells​(java.util.Collection<Spell> spells)
                         throws java.io.IOException
        Write a spells (ZAUBER) block to the underlying stream.
        Parameters:
        spells - a collection containing the spells to write.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • write

        public void write​(Spell spell)
                   throws java.io.IOException
        Write the cr representation of a Spell object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writePotions

        public void writePotions​(java.util.Collection<Potion> potions)
                          throws java.io.IOException
        Write a sequence of potion (TRANK) blocks to the underlying stream.
        Parameters:
        potions - a collections containing the potions to write.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • write

        public void write​(Potion potion)
                   throws java.io.IOException
        Write the cr representation of a Potion object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writePotionIngredients

        public void writePotionIngredients​(java.util.Collection<Item> ingredients)
                                    throws java.io.IOException
        Writes the ingredients of a potion as a ZUTATEN block to the underlying stream.
        Parameters:
        ingredients - a collection containing Item objects.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeSpellComponents

        public void writeSpellComponents​(java.util.Map<java.lang.String,​java.lang.String> comps)
                                  throws java.io.IOException
        Write a spell components (KOMPONENTEN) block to the underyling. The block name is only written, if there are components in comps.
        Parameters:
        comps - a map containing the components to be written. The map is expected to contain the names of the components as keys and the component data as values (both as String objects). Such a map can be found in the Spell class.
        Throws:
        java.io.IOException - If an I/O error occurs.
        See Also:
        Spell
      • write

        public void write​(Options options)
                   throws java.io.IOException
        Write the cr representation of a Option object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeGroups

        public void writeGroups​(java.util.Map<? extends ID,​Group> map)
                         throws java.io.IOException
        Write a sequence of group (GRUPPE) blocks to the underlying stream.
        Parameters:
        map - a map containing the groups to write. The keys are expected to be Integer objects containing the ids of the alliances. The values are expected to be instances of class Group. May be null.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeGroup

        public void writeGroup​(Group group)
                        throws java.io.IOException
        Write the cr representation of a Group object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeAlliances

        public void writeAlliances​(java.util.Map<EntityID,​Alliance> map)
                            throws java.io.IOException
        Write a sequence of alliance (ALLIANZ) blocks to the underlying stream.
        Parameters:
        map - a map containing the alliances to write. The keys are expected to be Integer objects containing the ids of the alliances. The values are expected to be instances of class Alliance. May be null.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • write

        public void write​(Alliance alliance)
                   throws java.io.IOException
        Write the cr representation of an Alliance object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeBattles

        public void writeBattles​(java.util.List<Battle> list)
                          throws java.io.IOException
        Write a sequence of battle (BATTLE) blocks to the underlying stream.
        Parameters:
        list - a list containing the Battle objects to be written. My be null.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • write

        public void write​(Battle battle)
                   throws java.io.IOException
        Write the cr representation of a Battle object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeBookmark

        protected void writeBookmark​(Selectable selection)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • writeFactions

        public void writeFactions​(java.util.Collection<Faction> factions,
                                  boolean noDetails)
                           throws java.io.IOException
        Write a sequence of faction (PARTEI) blocks to the underlying stream.
        Parameters:
        factions - The Collection of factions to be written.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeFaction

        public void writeFaction​(Faction faction,
                                 boolean noDetails)
                          throws java.io.IOException
        Write the cr representation of a Faction object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeShips

        public void writeShips​(java.util.Collection<Ship> ships)
                        throws java.io.IOException
        Write a sequence of ship (SCHIFF) blocks to the underlying stream.
        Parameters:
        ships - an iterator containing theShip objects to be written.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeShip

        public void writeShip​(Ship ship)
                       throws java.io.IOException
        Write the cr representation of a Ship object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeBuildings

        public void writeBuildings​(java.util.Collection<Building> buildings)
                            throws java.io.IOException
        Write a sequence of building (BURG) blocks to the underlying stream.
        Parameters:
        buildings - an iterator containing theBuilding objects to be written.
        Throws:
        java.io.IOException
      • writeBuilding

        public void writeBuilding​(Building building)
                           throws java.io.IOException
        Write the cr representation of a Building object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeSkills

        public void writeSkills​(java.util.Iterator<Skill> skills,
                                int persons)
                         throws java.io.IOException
        Write a skills (TALENTE) block to the underlying stream. The block is only written, if skills contains at least one Skill object.
        Parameters:
        skills - an iterator over the Skill objects to write.
        persons - the number of persons in the unit this skill belongs to.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeSkill

        public void writeSkill​(Skill skill,
                               int persons)
                        throws java.io.IOException
        Write the cr representation of a Skill object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeOrders

        public void writeOrders​(java.util.List<Order> list)
                         throws java.io.IOException
        Write a COMMANDS block to the underlying stream. The block is only written, if list contains at least one String object representing an order.
        Parameters:
        list - a list with the String objects to be written.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeUnitSpells

        public void writeUnitSpells​(java.util.Map<? extends ID,​Spell> spells)
                             throws java.io.IOException
        Write a unit's spell (SPRUECHE) block to the underlying stream. The block is only written, if list contains at least one Spell object.
        Parameters:
        spells - a list with theSpell object names to be written.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeUnitCombatSpells

        public void writeUnitCombatSpells​(java.util.Map<? extends ID,​CombatSpell> map)
                                   throws java.io.IOException
        Write a unit's combat spell (KAMPFZAUBER) blocks to the underlying stream.
        Parameters:
        map - a Map with the CombatSpell objects to be written.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • write

        public void write​(CombatSpell cs)
                   throws java.io.IOException
        Write the cr representation of a CombatSpell object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeItems

        public void writeItems​(java.util.Iterator<Item> items)
                        throws java.io.IOException
        Write a unit's items (GEGENSTAENDE) block to the underlying stream. The block is only written, if items contains at least one Item object.
        Parameters:
        items - an iterator over the Item objects to be written.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • write

        public void write​(Item item)
                   throws java.io.IOException
        Write the cr representation of a Item object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeUnits

        public void writeUnits​(java.util.Collection<Unit> units)
                        throws java.io.IOException
        Write a sequence of unit (EINHEIT) blocks to the underlying stream.
        Parameters:
        units - an iterator for theUnit objects to be written.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeOldUnits

        public void writeOldUnits​(java.util.Map<Region,​java.util.List<Unit>> oldUnitMap2,
                                  Region region)
                           throws java.io.IOException
        Write a sequence of old unit (ALTEINHEIT) blocks for the given region to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeUnit

        public void writeUnit​(Unit unit)
                       throws java.io.IOException
        Write the cr representation of a Unit object to the underyling
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeUnit

        public void writeUnit​(Unit unit,
                              boolean old)
                       throws java.io.IOException
        Write the cr representation of a Unit object to the underyling
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writePrices

        public void writePrices​(java.util.Map<? extends ID,​LuxuryPrice> map)
                         throws java.io.IOException
        Write a region prices (PREISE) block to the underlying stream.
        Parameters:
        map - list containing theLuxuryPrice objects to be written.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeOldPrices

        public void writeOldPrices​(java.util.Map<? extends ID,​LuxuryPrice> map)
                            throws java.io.IOException
        Write region block containing the luxury prices of the last turn (LETZTEPREISE) to the underlying stream.
        Parameters:
        map - a map containing the LuxuryPrice objects to be written.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • write

        public void write​(LuxuryPrice price)
                   throws java.io.IOException
        Write the cr representation of a LuxuryPrice object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeBorders

        public void writeBorders​(java.util.Collection<Border> c)
                          throws java.io.IOException
        Write a sequence of region border (GRENZE) blocks to the underlying stream.
        Parameters:
        c - collection containing the Border objects to be written.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeBorder

        public void writeBorder​(Border border)
                         throws java.io.IOException
        Write the cr representation of a Border object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeRegions

        public void writeRegions​(java.util.Collection<Region> regions)
                          throws java.io.IOException
        Write a sequence of region (REGION) blocks to the underlying stream.
        Parameters:
        regions - a collection containing the regions to write.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeRegion

        public void writeRegion​(Region region)
                         throws java.io.IOException
        Write the cr representation of a Region object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeSchemes

        public void writeSchemes​(java.util.Collection<Scheme> schemes)
                          throws java.io.IOException
        Write a collection of schemes to the underlying stream
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeScheme

        public void writeScheme​(Scheme scheme)
                         throws java.io.IOException
        Writes the cr representation of a Scheme object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeRegionResources

        public void writeRegionResources​(java.util.Collection<RegionResource> resources)
                                  throws java.io.IOException
        Write a collection of region resources to the underlying stream
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeRegionResource

        public void writeRegionResource​(RegionResource res)
                                 throws java.io.IOException
        Writes the cr representation of a region resource object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeMsgTypes

        public void writeMsgTypes​(java.util.Map<? extends ID,​MessageType> map)
                           throws java.io.IOException
        Write message type blocks to the underlying stream.
        Parameters:
        map - a map containing the MessageType objects to be written as values.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeMessageType

        public void writeMessageType​(MessageType msgType)
                              throws java.io.IOException
        Write the cr representation of a MessageType object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeSynchronously

        public void writeSynchronously()
                                throws java.io.IOException
        Writes the GameData in the current thread.
        Throws:
        java.io.IOException - If an I/O error occurs
      • writeAsynchronously

        public java.lang.Thread writeAsynchronously()
                                             throws java.io.IOException,
                                                    java.lang.NullPointerException
        Write the complete game data from world in the cr format.
        Throws:
        java.io.IOException
        java.lang.NullPointerException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.BufferedWriter
        Throws:
        java.io.IOException
        See Also:
        BufferedWriter.close()
      • doWrite

        protected void doWrite()
                        throws java.io.IOException
        Write the complete game data from world in the cr format. This method is called by the public method write(). This method can be run in a thread.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • savingInProgress

        public boolean savingInProgress()
        Returns true if writing has begun, but not finished
      • setTildeEscapes

        public void setTildeEscapes​(boolean bool)
        Change the quote escape behaviour of this CRWriter. Tilde escapes look like: 'a "b c"' -> 'a b~c', whereas a backslash escape works like this: 'a "b c"' -> 'a \"b c\"'
        Parameters:
        bool - if true, escape quoted parts of any string written to the underlying stream with tildes. If false, use backslash character to escape the quotation marks themselves.
      • getIncludeRegions

        public boolean getIncludeRegions()
        Returns whether doWrite() writes information about the regions in data to the underlying stream.
      • setIncludeRegions

        public void setIncludeRegions​(boolean includeRegions)
        Toggles whether doWrite() writes information about the regions in data to the underlying stream.
      • getIncludeBuildings

        public boolean getIncludeBuildings()
        Returns whether doWrite() writes information about the buildings in data to the underlying stream.
      • setIncludeBuildings

        public void setIncludeBuildings​(boolean includeBuildings)
        Toggles whether doWrite() writes information about the buildings in data to the underlying stream.
      • getIncludeShips

        public boolean getIncludeShips()
        Returns whether doWrite() writes information about the ships in data to the underlying stream.
      • setIncludeShips

        public void setIncludeShips​(boolean includeShips)
        Toggles whether doWrite() writes information about the ships in data to the underlying stream.
      • getIncludeUnits

        public boolean getIncludeUnits()
        Returns whether doWrite() writes information about the units in data to the underlying stream.
      • setIncludeUnits

        public void setIncludeUnits​(boolean includeUnits)
        Toggles whether doWrite() writes information about the units in data to the underlying stream.
      • setIncludeUnitDetails

        public void setIncludeUnitDetails​(boolean newValue)
        Toggles whether doWrite() writes information about the unit skills in data to the underlying stream.
        Parameters:
        newValue -
      • getIncludeUnitDetails

        public boolean getIncludeUnitDetails()
        Returns true if details of unit's will be included in the written report.
      • setIncludeSkills

        public void setIncludeSkills​(boolean newValue)
        Toggles whether doWrite() writes information about the unit skills in data to the underlying stream.
        Parameters:
        newValue -
      • getIncludeSkills

        public boolean getIncludeSkills()
        Returns true if units' skills will be written.
      • setIncludeOrders

        public void setIncludeOrders​(boolean newValue)
        Toggles whether doWrite() writes the units' orders in data to the underlying stream.
        Parameters:
        newValue -
      • getIncludeOrders

        public boolean getIncludeOrders()
        Returns true if the unit's orders will be included in writing.
      • setIncludeItems

        public void setIncludeItems​(boolean newValue)
        Toggles whether doWrite() writes information about the unit skills in data to the underlying stream.
        Parameters:
        newValue -
      • getIncludeItems

        public boolean getIncludeItems()
        Returns true if items will be written.
      • getIncludeRegionDetails

        public boolean getIncludeRegionDetails()
        Returns whether doWrite() writes detailed information about the regions in data to the underlying stream.
      • setIncludeRegionDetails

        public void setIncludeRegionDetails​(boolean includeRegionDetails)
        Toggles whether doWrite() writes detailed information about the regions in data to the underlying stream.
      • getIncludeIslands

        public boolean getIncludeIslands()
        Returns whether doWrite() writes information about islands to the underlying stream.
      • setIncludeIslands

        public void setIncludeIslands​(boolean includeIslands)
        Toggles whether doWrite() writes information about islands to the underlying stream.
      • getIncludeMessages

        public boolean getIncludeMessages()
        Returns whether doWrite() writes messages contained in the game data to the underlying stream.
      • setIncludeMessages

        public void setIncludeMessages​(boolean includeMessages)
        Toggles whether doWrite() writes messages contained in the game data to the underlying stream.
      • getExportHotspots

        public boolean getExportHotspots()
        Returns whether doWrite() writes Hotspots contained in the game data to the underlying stream.
      • setExportHotspots

        public void setExportHotspots​(boolean exportHotspots)
        Toggles whether doWrite() writes Hotspots contained in the game data to the underlying stream.
      • getIncludeSpellsAndPotions

        public boolean getIncludeSpellsAndPotions()
        Returns whether doWrite() writes messages contained in the game data to the underlying stream.
      • setIncludeSpellsAndPotions

        public void setIncludeSpellsAndPotions​(boolean includeSpellsAndPotions)
        Toggles whether doWrite() writes messages contained in the game data to the underlying stream.
      • getServerConformance

        public boolean getServerConformance()
        Returns whether doWrite() writes a cr that is compatible with cr's generated by the Eressea server, i.e. not including JavaClient specific data.
      • setServerConformance

        public void setServerConformance​(boolean serverConformance)
        Toggles whether doWrite() writes a cr that is compatible with cr's generated by the Eressea server, i.e. not including JavaClient specific data.
      • writeIslands

        public void writeIslands​(java.util.Collection<Island> islands)
                          throws java.io.IOException
        Write a sequence of island blocks to the underlying stream.
        Parameters:
        islands - a collection containing the islands to write.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • write

        public void write​(Island island)
                   throws java.io.IOException
        Write the cr representation of an Island object to the underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • getRegions

        public java.util.Collection<Region> getRegions()
        Returns the regions this object writes to the underlying stream.
      • setRegions

        public void setRegions​(java.util.Collection<Region> regions)
        Supply the writer with a collection of regions it should write to the underlying stream instead of all regions contained in the game data. If regions is null or if there is no element in the supplied collection, the writer returns to writing all regions defined in the game data.
      • getUnits

        public java.util.Collection<Unit> getUnits()
        Returns the units this object writes to the underlying stream.
      • setUnits

        public void setUnits​(java.util.Collection<Unit> units)
        Supply the writer with a collection of units it should write to the underlying stream instead of all units contained in the game data. If units is null or if there is no element in the supplied collection, the writer returns to writing all units defined in the game data.
      • writeTranslations

        public void writeTranslations​(Translations m)
                               throws java.io.IOException
        Write the translation table to underlying stream.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • writeAttributes

        public void writeAttributes​(Addeable addeable)
                             throws java.io.IOException
        Writes all attributes to the stream
        Throws:
        java.io.IOException