Package net.sf.freecol.common.io
Class FreeColModFile
- java.lang.Object
-
- net.sf.freecol.common.io.FreeColDataFile
-
- net.sf.freecol.common.io.FreeColModFile
-
- All Implemented Interfaces:
ObjectWithId
- Direct Known Subclasses:
FreeColTcFile
public class FreeColModFile extends FreeColDataFile implements ObjectWithId
A wrapped for a file containing a FreeCol modification (mod).
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.lang.String,FreeColModFile>
allMods
A cache of all the mods.private java.lang.String
id
The identifier for this mod.private static java.util.logging.Logger
logger
private java.lang.String
parent
The identifier for the parent of this mod, if any.protected static java.lang.String
SPECIFICATION_FILE
-
Fields inherited from class net.sf.freecol.common.io.FreeColDataFile
ZIP_FILE_EXTENSION
-
-
Constructor Summary
Constructors Constructor Description FreeColModFile(java.io.File file)
Make a FreeColModFile from a File.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FreeColModFile
getFreeColModFile(java.lang.String id)
Get a mod by id.java.lang.String
getId()
Gets the object identifier of this mod.private java.io.InputStream
getModDescriptorInputStream()
Gets the input stream to the mod meta file.static java.util.List<FreeColModFile>
getModsList()
Get all the standard mods.java.lang.String
getParent()
Gets the parent of the mod.Specification
getSpecification()
Gets the Specification.java.io.InputStream
getSpecificationInputStream()
Gets the input stream to the specification.static void
loadMods()
Require all mods to be loaded.protected void
readModDescriptor()
Reads a file object representing this mod.-
Methods inherited from class net.sf.freecol.common.io.FreeColDataFile
getFileFilter, getInputStream, getPath, getResourceMapping, getURI
-
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
allMods
private static final java.util.Map<java.lang.String,FreeColModFile> allMods
A cache of all the mods.
-
SPECIFICATION_FILE
protected static final java.lang.String SPECIFICATION_FILE
- See Also:
- Constant Field Values
-
id
private java.lang.String id
The identifier for this mod.
-
parent
private java.lang.String parent
The identifier for the parent of this mod, if any.
-
-
Method Detail
-
getSpecificationInputStream
public java.io.InputStream getSpecificationInputStream() throws java.io.IOException
Gets the input stream to the specification.- Returns:
- An
InputStream
to the file "specification.xml" within this data file, or null if none present. - Throws:
java.io.IOException
- if thrown while opening the input stream.
-
getSpecification
public Specification getSpecification() throws java.io.IOException, javax.xml.stream.XMLStreamException
Gets the Specification.- Returns:
- The
Specification
, or null if none present. - Throws:
java.io.IOException
- if an error occurs creating a stream to read.javax.xml.stream.XMLStreamException
- if there is an error reading the stream.
-
getModDescriptorInputStream
private java.io.InputStream getModDescriptorInputStream() throws java.io.IOException
Gets the input stream to the mod meta file.- Returns:
- An
InputStream
to the file "mod.xml" within this data file. - Throws:
java.io.IOException
- if thrown while opening the input stream.
-
readModDescriptor
protected final void readModDescriptor() throws java.io.IOException
Reads a file object representing this mod.- Throws:
java.io.IOException
- if thrown while reading the "mod.xml" file.
-
getParent
public java.lang.String getParent()
Gets the parent of the mod.- Returns:
- The mod parent name.
-
getModsList
public static java.util.List<FreeColModFile> getModsList()
Get all the standard mods.- Returns:
- A list of
FreeColModFile
s holding the mods.
-
getId
public java.lang.String getId()
Gets the object identifier of this mod.- Specified by:
getId
in interfaceObjectWithId
- Returns:
- The object identifier of the mod.
-
loadMods
public static void loadMods()
Require all mods to be loaded. This must be delayed until the mods directories are defined. User mods are loaded after standard mods to allow user override.
-
getFreeColModFile
public static FreeColModFile getFreeColModFile(java.lang.String id)
Get a mod by id.- Parameters:
id
- The mod file identifier to look for.- Returns:
- The
FreeColModFile
found, or null if none present.
-
-