Package VASSAL.tools.imports
Class Importer
java.lang.Object
VASSAL.tools.imports.Importer
- Direct Known Subclasses:
ADC2Module
,MapBoard
,SymbolSet
Abstract parent of all importer classes.
- Since:
- 3.1.0
- Author:
- Michael Kiefte
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
forceExtension
(String s, String ext) Strip the extension from a filename and replace with the given extension.static String
Get the extension from a file name.static String
Get the file name without the qualifying path.protected LayeredPieceCollection
protected Map
static String
static String
getUniqueImageFileName
(String s, String ext) Get a unique file name for an image in the game module archive.void
importFile
(ImportAction action, File f) Two methods are needed to import a file.protected static void
insertComponent
(Buildable child, Buildable parent) abstract boolean
Determine whether the file is valid for the given importer.protected void
The method that actually loads the file and creates the classes containing information needed for the archive.static String
Return a null-terminated string from an input stream.static String
readNullTerminatedString
(InputStream in, int maxLen) Read a null-terminated string from a file up to a maximum length which includes the null termination.static String
Read a null-terminated string representing a Windows file name and convert Windows separator characters '\\' to the local separator character.static String
Return a file name without the extension.abstract void
Create the VASSAL module based on the classes created byload
.
-
Field Details
-
action
-
file
-
-
Constructor Details
-
Importer
public Importer()
-
-
Method Details
-
insertComponent
-
getMainMap
- Returns:
- The VASSAL Map object corresponding to this imported map.
-
getLayeredPieceCollection
-
load
The method that actually loads the file and creates the classes containing information needed for the archive. The archive is written inwriteToArchive
.- Parameters:
f
- The base file to be imported.- Throws:
IOException
- oops
-
writeToArchive
Create the VASSAL module based on the classes created byload
. This should not be called directly but ratherimportFile
.- Throws:
IOException
- oops
-
importFile
Two methods are needed to import a file.Importer.importFile
initializes the game module and callsload
which must be overridden by descendants.- Parameters:
action
-ImportAction
which creates theImporter
. This is needed for file dialogs that may be called byImporter
methods.f
- The base file to be imported.- Throws:
IOException
- oops
-
stripExtension
-
readWindowsFileName
Read a null-terminated string representing a Windows file name and convert Windows separator characters '\\' to the local separator character. This is the default file name format for many imported modules and should be used whenever a filename is read as a null-terminated string in order to ensure platform independence.- Throws:
IOException
-
readNullTerminatedString
Read a null-terminated string from a file up to a maximum length which includes the null termination. If the actual string is longer, no more bytes will be read.- Throws:
IOException
-
readNullTerminatedString
Return a null-terminated string from an input stream.- Throws:
IOException
-
getUniqueImageFileName
Get a unique file name for an image in the game module archive. This function tests the provided name against those that are already present in the archive and if the file name already exists, creates an alternate, unique file name. If an alternate is created, it is of the formname + "(n)"
where n is an integer. -
getUniqueImageFileName
-
getFileName
-
getExtension
-
forceExtension
-
isValidImportFile
Determine whether the file is valid for the given importer.- Parameters:
f
- File- Returns:
true
iff
is a valid file for this type.- Throws:
FileNotFoundException
- oopsIOException
- oops
-