de.hagenah.diplomacy.diptool
Class DipGameGroup

java.lang.Object
  extended by de.hagenah.diplomacy.game.GameGroup
      extended by de.hagenah.diplomacy.diptool.DipGameGroup
All Implemented Interfaces:
GameHandler, java.io.Serializable, java.lang.Comparable

public class DipGameGroup
extends GameGroup
implements java.lang.Comparable

A group of games. Note: This class is not thread-safe. So even if some methods may be called by other threads than the event dispatching thread it's still so that in this case the event-dispatching thread must not modify this object in parallel.

See Also:
Serialized Form

Method Summary
 int compareTo(java.lang.Object obj)
          Compares two groups by Name
 Game createGame(java.lang.String name, java.lang.String judge, java.lang.String map)
          Retrieves the specified game.
protected  MapData createMap(java.lang.String name)
          Retrieves the specified map.
 boolean equals(java.lang.Object obj)
          Compares two groups by Name
 int hashCode()
          Returns a hashcode for this group.
protected  Game internCreateGame(java.lang.String name, java.lang.String judge, MapData map)
          Creates a Game object
 java.util.Collection parse(java.io.Reader reader)
          Parses a text.
 java.util.Collection read(java.util.Collection files, boolean always, de.hagenah.util.ModalProgressMonitor progressmonitor)
          Reads files and directories (recursive).
 void readAllAgain()
          All files are read again if ScanDirectories is processed the next time.
 void removeGame(java.lang.String name, java.lang.String judge)
          Removes the game
 void renameGame(java.lang.String oldname, java.lang.String oldjudge, java.lang.String newname, java.lang.String newjudge)
          Renames a game
 java.util.Collection scan(de.hagenah.util.ModalProgressMonitor progressmonitor)
          Scans all directories (recursive) and files.
 java.util.Collection scan(java.util.SortedSet paths)
          Scans only the directories (recursive) and files that are in paths and ScanDirectories.
 java.lang.String toString()
          Returns the name of the group, e.g.
 
Methods inherited from class de.hagenah.diplomacy.game.GameGroup
getGame, getGameIndex, getGames, getMapPath, getMapURL, processGames, setMapPath
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

internCreateGame

protected Game internCreateGame(java.lang.String name,
                                java.lang.String judge,
                                MapData map)
Creates a Game object

Overrides:
internCreateGame in class GameGroup

createGame

public Game createGame(java.lang.String name,
                       java.lang.String judge,
                       java.lang.String map)
                throws java.lang.Exception
Retrieves the specified game. If it does not exist it is created.

Specified by:
createGame in interface GameHandler
Overrides:
createGame in class GameGroup
Parameters:
name - The name of the game (!=null).
judge - The name of the judge (!=null).
map - The name of the map.
Returns:
The game (!=null).
Throws:
java.lang.Exception

createMap

protected MapData createMap(java.lang.String name)
                     throws java.lang.Exception
Retrieves the specified map. If it does not exist it is loaded.

Overrides:
createMap in class GameGroup
Throws:
java.lang.Exception

removeGame

public void removeGame(java.lang.String name,
                       java.lang.String judge)
Removes the game

Overrides:
removeGame in class GameGroup

renameGame

public void renameGame(java.lang.String oldname,
                       java.lang.String oldjudge,
                       java.lang.String newname,
                       java.lang.String newjudge)
Renames a game

Overrides:
renameGame in class GameGroup

readAllAgain

public void readAllAgain()
All files are read again if ScanDirectories is processed the next time.


equals

public boolean equals(java.lang.Object obj)
Compares two groups by Name

Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(java.lang.Object obj)
Compares two groups by Name

Specified by:
compareTo in interface java.lang.Comparable

hashCode

public int hashCode()
Returns a hashcode for this group.

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Returns the name of the group, e.g. "Observed games".

Overrides:
toString in class java.lang.Object

read

public java.util.Collection read(java.util.Collection files,
                                 boolean always,
                                 de.hagenah.util.ModalProgressMonitor progressmonitor)
Reads files and directories (recursive). It returns a list with the errors. This method is multi-threading safe.

Parameters:
files - The files and directories to read (File objects)
always - false if already read files shall be skipped, true if a file shall be read even if it was already read
progressmonitor - A progress monitor (can be null)
Returns:
A list with the errors (String objects)

scan

public java.util.Collection scan(de.hagenah.util.ModalProgressMonitor progressmonitor)
Scans all directories (recursive) and files. It returns a list with the errors. This method is multi-threading safe.

Parameters:
progressmonitor - A progress monitor (can be null)

scan

public java.util.Collection scan(java.util.SortedSet paths)
Scans only the directories (recursive) and files that are in paths and ScanDirectories. It returns a list with the errors. This method is multi-threading safe.

Parameters:
paths - The set with the directories and files (String) to scan. The paths must be canonical and the set must use the natural order.

parse

public java.util.Collection parse(java.io.Reader reader)
Parses a text. It returns a list with the errors (at most one). This method is multi-threading safe. Note: For files the read method should be used.

Parameters:
reader - The reader with the text