Package ca.cgjennings.apps.arkham.deck
Class DeckDeserializationSupport
- java.lang.Object
-
- ca.cgjennings.apps.arkham.deck.DeckDeserializationSupport
-
public final class DeckDeserializationSupport extends java.lang.Object
A helper class used when deserializing decks to track linked files that cannot be found (and the new files that replace them). As long as you useResourceKit.getGameComponentFromFile
to read game components, deck deserialization will be handled for you and you needn't worry about this class.- Author:
- Chris Jennings
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description GameComponent
findGameComponent(java.lang.String path, java.lang.String name)
Called from withinCardFace
s during deserialization to get a game component from the face's identifier.java.io.File
getDefaultFallbackFolder()
Returns the folder that will be used as a last-ditch fallback to find a missing file linked to by the deck.static DeckDeserializationSupport
getShared()
Returns the shared instance of the helper.boolean
isActive()
Returnstrue
if there is currently a deserialization session active.void
setDefaultFallbackFolder(java.io.File folder)
Sets the folder that will be used as a last-ditch fallback to find a missing file linked to by the deck.
-
-
-
Method Detail
-
getShared
public static DeckDeserializationSupport getShared()
Returns the shared instance of the helper. Because it is shared, only one deck can be (de)serialized at a time.- Returns:
- the shared helper instance
-
isActive
public boolean isActive()
Returnstrue
if there is currently a deserialization session active.- Returns:
true
if the shared instance is in use
-
setDefaultFallbackFolder
public void setDefaultFallbackFolder(java.io.File folder)
Sets the folder that will be used as a last-ditch fallback to find a missing file linked to by the deck. This is typically set to the parent folder of the deck file being read on the local system, if known.- Parameters:
folder
- the folder to search- Throws:
java.lang.IllegalArgumentException
- if the folder exists but is not a folder
-
getDefaultFallbackFolder
public java.io.File getDefaultFallbackFolder()
Returns the folder that will be used as a last-ditch fallback to find a missing file linked to by the deck. May benull
.- Returns:
- the fallback folder, or
null
-
findGameComponent
public GameComponent findGameComponent(java.lang.String path, java.lang.String name) throws java.io.IOException
Called from withinCardFace
s during deserialization to get a game component from the face's identifier.- Parameters:
path
- the identifier that locates the original filename
- the component name to display to the user as a hint- Returns:
- the game component for the identifier, or
null
- Throws:
java.io.IOException
- if an I/O error occurs while reading the file
-
-