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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringforceExtension(String s, String ext) Strip the extension from a filename and replace with the given extension.static StringGet the extension from a file name.static StringGet the file name without the qualifying path.protected LayeredPieceCollectionprotected Mapstatic Stringstatic StringgetUniqueImageFileName(String s, String ext) Get a unique file name for an image in the game module archive.voidimportFile(ImportAction action, File f) Two methods are needed to import a file.protected static voidinsertComponent(Buildable child, Buildable parent) abstract booleanDetermine whether the file is valid for the given importer.protected voidThe method that actually loads the file and creates the classes containing information needed for the archive.static StringReturn a null-terminated string from an input stream.static StringreadNullTerminatedString(InputStream in, int maxLen) Read a null-terminated string from a file up to a maximum length which includes the null termination.static StringRead a null-terminated string representing a Windows file name and convert Windows separator characters '\\' to the local separator character.static StringReturn a file name without the extension.abstract voidCreate 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.importFileinitializes the game module and callsloadwhich must be overridden by descendants.- Parameters:
action-ImportActionwhich creates theImporter. This is needed for file dialogs that may be called byImportermethods.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:
trueiffis a valid file for this type.- Throws:
FileNotFoundException- oopsIOException- oops
-