Gridarta Editor
net.sf.gridarta.gui.spells.SpellsUtils Class Reference
+ Collaboration diagram for net.sf.gridarta.gui.spells.SpellsUtils:

Public Member Functions

void importSpells (@NotNull final File dir, @NotNull final Component parent)
 Opens a file chooser to select the spell list file, then import spells. More...
 
 SpellsUtils (@NotNull final String spellFile)
 Creates a new instance. More...
 

Private Member Functions

int importSpells (@NotNull final File spellFile, @NotNull final File dir)
 Reads all spells from a Crossfire or Daimonin spell list file and write an alphabetical list into "spells.def". More...
 

Static Private Member Functions

static String readUntil (@NotNull final Reader stream, @NotNull final CharSequence tag) throws IOException
 Reads characters from the BufferedReader stream till 'tag' is found. More...
 
static void readUntil (@NotNull final Reader stream, @NotNull final CharSequence tag, @Nullable final CharSequence abort) throws IOException
 Reads characters from the BufferedReader stream till 'tag' is found. More...
 

Private Attributes

final String spellFile
 The spell file name. More...
 

Static Private Attributes

static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta")
 Action Builder. More...
 
static final Category LOG = Logger.getLogger(SpellsUtils.class)
 The Logger for printing log messages. More...
 
static final long READ_MAX = 10000L
 Maximum number of characters to read in readUntil. More...
 
static final FileFilter SPELL_LIST_H_FILE_FILTER = new FilenameFileFilter(true, "spellist.h", "spellist.h")
 File filter for filtering spellist.h files. More...
 

Detailed Description

Author
Christian Hujer

Definition at line 54 of file SpellsUtils.java.

Constructor & Destructor Documentation

◆ SpellsUtils()

net.sf.gridarta.gui.spells.SpellsUtils.SpellsUtils ( @NotNull final String  spellFile)

Creates a new instance.

Parameters
spellFilethe spell file name

Definition at line 89 of file SpellsUtils.java.

References net.sf.gridarta.gui.spells.SpellsUtils.spellFile.

Member Function Documentation

◆ importSpells() [1/2]

void net.sf.gridarta.gui.spells.SpellsUtils.importSpells ( @NotNull final File  dir,
@NotNull final Component  parent 
)

Opens a file chooser to select the spell list file, then import spells.

Parameters
dirthe directory to use
parentthe parent component for dialog boxes

Definition at line 98 of file SpellsUtils.java.

References net.sf.gridarta.gui.spells.SpellsUtils.ACTION_BUILDER, net.sf.gridarta.utils.FileChooserUtils.setCurrentDirectory(), and net.sf.gridarta.gui.spells.SpellsUtils.SPELL_LIST_H_FILE_FILTER.

Referenced by net.sf.gridarta.action.CollectSpellsAction.collectSpells().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importSpells() [2/2]

int net.sf.gridarta.gui.spells.SpellsUtils.importSpells ( @NotNull final File  spellFile,
@NotNull final File  dir 
)
private

Reads all spells from a Crossfire or Daimonin spell list file and write an alphabetical list into "spells.def".

Parameters
spellFilespell file to read
dirthe base directory to load the spells file from
Returns
number of successfully collected spells

Definition at line 132 of file SpellsUtils.java.

References net.sf.gridarta.gui.spells.SpellsUtils.LOG, name, net.sf.gridarta.gui.spells.SpellsUtils.readUntil(), spaces, and net.sf.gridarta.gui.spells.SpellsUtils.spellFile.

+ Here is the call graph for this function:

◆ readUntil() [1/2]

static String net.sf.gridarta.gui.spells.SpellsUtils.readUntil ( @NotNull final Reader  stream,
@NotNull final CharSequence  tag 
) throws IOException
staticprivate

Reads characters from the BufferedReader stream till 'tag' is found.

Similar to readUntil(), except that the read String is returned. 'tag' is not included in the returned String.

Parameters
streamascii input stream to read from
tagstop reading at the string 'tag'
Returns
the string between the starting position of 'stream' (inclusive) and the first character of 'tag' (exclusive)
Exceptions
IOExceptionan I/O-error occurred while reading the file
EOFExceptionthe end of file was reached

Definition at line 275 of file SpellsUtils.java.

References net.sf.gridarta.gui.spells.SpellsUtils.READ_MAX.

◆ readUntil() [2/2]

static void net.sf.gridarta.gui.spells.SpellsUtils.readUntil ( @NotNull final Reader  stream,
@NotNull final CharSequence  tag,
@Nullable final CharSequence  abort 
) throws IOException
staticprivate

Reads characters from the BufferedReader stream till 'tag' is found.

If found, the method returns with stream pointing right after the appearance of 'tag'.

Parameters
streamascii input stream to read from
tagstop reading at the string 'tag'
abortthrow
EOFException
at string 'abort' (this can be null)
Exceptions
IOExceptionan I/O-error occurred while reading the file
EOFExceptionthe end of file was reached, or the 'abort' string has been encountered
Todo:
Should the encounter of the abort string before the tag really be an EOFException? That's semantically wrong, but current usage code relies on this :(

Definition at line 221 of file SpellsUtils.java.

Referenced by net.sf.gridarta.gui.spells.SpellsUtils.importSpells().

+ Here is the caller graph for this function:

Member Data Documentation

◆ ACTION_BUILDER

final ActionBuilder net.sf.gridarta.gui.spells.SpellsUtils.ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta")
staticprivate

Action Builder.

Definition at line 71 of file SpellsUtils.java.

Referenced by net.sf.gridarta.gui.spells.SpellsUtils.importSpells().

◆ LOG

final Category net.sf.gridarta.gui.spells.SpellsUtils.LOG = Logger.getLogger(SpellsUtils.class)
staticprivate

The Logger for printing log messages.

Definition at line 65 of file SpellsUtils.java.

Referenced by net.sf.gridarta.gui.spells.SpellsUtils.importSpells().

◆ READ_MAX

final long net.sf.gridarta.gui.spells.SpellsUtils.READ_MAX = 10000L
staticprivate

Maximum number of characters to read in readUntil.

Definition at line 59 of file SpellsUtils.java.

Referenced by net.sf.gridarta.gui.spells.SpellsUtils.readUntil().

◆ SPELL_LIST_H_FILE_FILTER

final FileFilter net.sf.gridarta.gui.spells.SpellsUtils.SPELL_LIST_H_FILE_FILTER = new FilenameFileFilter(true, "spellist.h", "spellist.h")
staticprivate

File filter for filtering spellist.h files.

Definition at line 77 of file SpellsUtils.java.

Referenced by net.sf.gridarta.gui.spells.SpellsUtils.importSpells().

◆ spellFile

final String net.sf.gridarta.gui.spells.SpellsUtils.spellFile
private

The documentation for this class was generated from the following file: