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>allModsA cache of all the mods.private java.lang.StringidThe identifier for this mod.private static java.util.logging.Loggerloggerprivate java.lang.StringparentThe identifier for the parent of this mod, if any.protected static java.lang.StringSPECIFICATION_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 FreeColModFilegetFreeColModFile(java.lang.String id)Get a mod by id.java.lang.StringgetId()Gets the object identifier of this mod.private java.io.InputStreamgetModDescriptorInputStream()Gets the input stream to the mod meta file.static java.util.List<FreeColModFile>getModsList()Get all the standard mods.java.lang.StringgetParent()Gets the parent of the mod.SpecificationgetSpecification()Gets the Specification.java.io.InputStreamgetSpecificationInputStream()Gets the input stream to the specification.static voidloadMods()Require all mods to be loaded.protected voidreadModDescriptor()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.IOExceptionGets the input stream to the specification.- Returns:
- An
InputStreamto 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.IOExceptionGets the input stream to the mod meta file.- Returns:
- An
InputStreamto 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.IOExceptionReads 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
FreeColModFiles holding the mods.
-
getId
public java.lang.String getId()
Gets the object identifier of this mod.- Specified by:
getIdin 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
FreeColModFilefound, or null if none present.
-
-