Class ComponentMetadata
- java.lang.Object
-
- ca.cgjennings.apps.arkham.component.ComponentMetadata
-
public class ComponentMetadata extends java.lang.Object
Provides access to the game component metadata stored in modern game component files. Depending on the version of Strange Eons that wrote the file, different levels of metadata will be available. You can determine which level of metadata is supported by callinggetMetadataVersion()
. The following table lists the metadata available for each possible version (higher version numbers include all of the data available from lower version numbers):- Version -1
- No metadata available.
- Version 1
- Class name, component name, deck layout support.
- Version 2
- Build number, DIY script resource.
- Since:
- 3.00
- Author:
- Chris Jennings
-
-
Constructor Summary
Constructors Constructor Description ComponentMetadata(java.io.File source)
Creates a newComponentMetadata
instance that reads metadata from the specified file, if available.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getBuildNumber()
Returns the build number of the version of Strange Eons that this file was written from, or -1 if there is no metadata or the metadata version is less than 2.java.lang.Class<? extends GameComponent>
getComponentClass()
Returns theClass
instance that the game component is an instance of.java.lang.String
getComponentClassName()
Returns the name of the class that the game component is an instance of.java.lang.String
getDIYScriptResource()
Returns the resource identifier of the script file used to create the component, if it is a DIY component and uses a script.int
getMetadataVersion()
Returns the version of the metadata available from the file.java.lang.String
getName()
Returns the name of the component, as would be returned by callingGameComponent.getFullName()
on the actual component.boolean
isDeckLayoutSupported()
Returnstrue
if the component has metadata and can be included in a deck.static void
writeMetadataToStream(SEObjectOutputStream out, GameComponent gc)
Writes metadata for a component at the head of a component stream.
-
-
-
Constructor Detail
-
ComponentMetadata
public ComponentMetadata(java.io.File source)
Creates a newComponentMetadata
instance that reads metadata from the specified file, if available. If there is an error while reading the metadata, the resulting object will be identical to that of a file that does not contain metadata.- Parameters:
source
- the file to component file to read metadata from
-
-
Method Detail
-
getMetadataVersion
public int getMetadataVersion()
Returns the version of the metadata available from the file. Older components that have no metadata will return -1. If the actual version of the metadata in the file is greater than the version understood by this class, the version number is capped at the version understood by this class.- Returns:
- the version of the metadata available through this class, or -1 if no metadata is available
-
getBuildNumber
public int getBuildNumber()
Returns the build number of the version of Strange Eons that this file was written from, or -1 if there is no metadata or the metadata version is less than 2.- Returns:
- the build number, or -1 if this is unavailable
-
getComponentClass
public java.lang.Class<? extends GameComponent> getComponentClass() throws java.lang.ClassNotFoundException
Returns theClass
instance that the game component is an instance of. Returnsnull
if the component has no metadata.- Returns:
- the class representing the component
- Throws:
java.lang.ClassNotFoundException
- if the class cannot currently be loaded; for example, if it is part of a plug-in that is not currently installed
-
getComponentClassName
public java.lang.String getComponentClassName()
Returns the name of the class that the game component is an instance of. Returnsnull
if the component has no metadata.- Returns:
- the class name, if available
-
getName
public java.lang.String getName()
Returns the name of the component, as would be returned by callingGameComponent.getFullName()
on the actual component.- Returns:
- the component's name, or
null
if not available
-
isDeckLayoutSupported
public boolean isDeckLayoutSupported()
Returnstrue
if the component has metadata and can be included in a deck. Most components can be included in a deck, but some can't, including case books and other decks.- Returns:
true
if it is known for certain that the component can be placed in a deck
-
getDIYScriptResource
public java.lang.String getDIYScriptResource()
Returns the resource identifier of the script file used to create the component, if it is a DIY component and uses a script. Returnsnull
if the metadata version is less than 2 or the component is not a script-based DIY component.- Returns:
- the name of the DIY script, or
null
-
writeMetadataToStream
public static void writeMetadataToStream(SEObjectOutputStream out, GameComponent gc) throws java.io.IOException
Writes metadata for a component at the head of a component stream.- Parameters:
out
- the stream to write togc
- the component to produce metadata for- Throws:
java.io.IOException
- if an error occurs while writing to the stream
-
-