Class Listing
- java.lang.Object
-
- ca.cgjennings.apps.arkham.plugins.catalog.Listing
-
- All Implemented Interfaces:
java.lang.Comparable<Listing>
public final class Listing extends java.lang.Object implements java.lang.Comparable<Listing>
A catalog listing that provides information about a plug-in bundle that the user might wish to download. A listing can include technical information to enable downloading, verifying, and installing the plug-in, versioning information (aCatalogID), category information, and a description for the user.- Since:
- 2.1
- Author:
- Chris Jennings
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCOMMENTA comment specific to the listing.static java.lang.StringCOREThe listing is a core component and should be shown with a core component icon (the value identifies the core and is used for filtering).static java.lang.StringCREDITName of the plug-in developer.static java.lang.StringDATEAn optional date that overrides the catalog ID.static java.lang.StringDESCRIPTIONThe human-friendly description (may be localized).static java.lang.StringDIGESTThe MD5 checksum of the unpacked bundle.static java.lang.StringGAMEThe listing supports the game with the specific listed game code listed.static java.lang.StringHIDDENThe listing should not be included in the download list shown to the user.static java.lang.StringHOME_PAGEA URL for more information.static java.lang.StringIDThe catalog ID (required).static java.lang.StringINSTALL_SIZEThe installed (unpacked) size (bytes).static java.lang.StringMAXIMUM_VERSIONThe maximum build number that the plug-in is compatible with.static java.lang.StringMINIMUM_VERSIONThe minimum build number needed by the plug-in.static java.lang.StringNAMEThe name of the plug-in (may be localized) (required).static java.lang.StringREPLACESA catalog ID that should be uninstalled if this is installed.static java.lang.StringREQUIRESA list of other catalog IDs required by this plug-in.static java.lang.StringSIZEThe download size (bytes).static java.lang.StringTAGSTags that can be searched for.static java.lang.StringURLThe URL, either absolute or relative to the catalog if it starts with "./" (required).static java.lang.StringVERSIONThe human friendly version of the plug-in.
-
Constructor Summary
Constructors Constructor Description Listing(java.io.File f)Creates a new listing based on a local file that might be added to a catalog.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanchecksumMatches(java.io.File f)Returnstrueif the checksum in this listing matches the checksum of a file.intcompareTo(Listing o)java.lang.Stringget(java.lang.String key)Returns the (possibly localized) value of a key in the catalog properties.intgetApplicationCompatibility()Compares the version of the application to the version information included in the catalog listing, if any.CatalogIDgetCatalogID()Returns the catalog ID for this listing, ornullif none is set.java.lang.StringgetChecksum()Returns the download file checksum string for this listing, ornullif none is present.java.lang.StringgetDescription()java.lang.StringgetDisplayDate()java.net.URLgetHomePage()java.lang.StringgetName()longgetSize()java.lang.StringgetVersion()booleanisHidden()Returnstrueif the listing is hidden.booleanisIdenticalTo(Listing other)Returnstrueif and only if the listing has exactly the same keys and values as the specified listing.booleanisNew()Returnstrueif this plug-in appears to be "new", that is, added recently and not seen by the user before.voidset(java.lang.String key, java.lang.String value)Sets the value of the given key.voidsetCatalogID(CatalogID id)Sets the catalog ID for this listing, or clears it ifnull.voidsetChecksum(MD5Checksum checksum)Sets the checksum value for the listing from a computed checksum value, or removes it ifnull.java.lang.StringtoString()
-
-
-
Field Detail
-
ID
public static final java.lang.String ID
The catalog ID (required).- See Also:
- Constant Field Values
-
URL
public static final java.lang.String URL
The URL, either absolute or relative to the catalog if it starts with "./" (required).- See Also:
- Constant Field Values
-
NAME
public static final java.lang.String NAME
The name of the plug-in (may be localized) (required).- See Also:
- Constant Field Values
-
VERSION
public static final java.lang.String VERSION
The human friendly version of the plug-in.- See Also:
- Constant Field Values
-
SIZE
public static final java.lang.String SIZE
The download size (bytes).- See Also:
- Constant Field Values
-
INSTALL_SIZE
public static final java.lang.String INSTALL_SIZE
The installed (unpacked) size (bytes).- See Also:
- Constant Field Values
-
DESCRIPTION
public static final java.lang.String DESCRIPTION
The human-friendly description (may be localized).- See Also:
- Constant Field Values
-
DIGEST
public static final java.lang.String DIGEST
The MD5 checksum of the unpacked bundle.- See Also:
- Constant Field Values
-
HOME_PAGE
public static final java.lang.String HOME_PAGE
A URL for more information.- See Also:
- Constant Field Values
-
DATE
public static final java.lang.String DATE
An optional date that overrides the catalog ID.- See Also:
- Constant Field Values
-
CREDIT
public static final java.lang.String CREDIT
Name of the plug-in developer.- See Also:
- Constant Field Values
-
TAGS
public static final java.lang.String TAGS
Tags that can be searched for.- See Also:
- Constant Field Values
-
MINIMUM_VERSION
public static final java.lang.String MINIMUM_VERSION
The minimum build number needed by the plug-in.- See Also:
- Constant Field Values
-
MAXIMUM_VERSION
public static final java.lang.String MAXIMUM_VERSION
The maximum build number that the plug-in is compatible with.- See Also:
- Constant Field Values
-
REQUIRES
public static final java.lang.String REQUIRES
A list of other catalog IDs required by this plug-in.- See Also:
- Constant Field Values
-
REPLACES
public static final java.lang.String REPLACES
A catalog ID that should be uninstalled if this is installed.- See Also:
- Constant Field Values
-
HIDDEN
public static final java.lang.String HIDDEN
The listing should not be included in the download list shown to the user.- See Also:
- Constant Field Values
-
CORE
public static final java.lang.String CORE
The listing is a core component and should be shown with a core component icon (the value identifies the core and is used for filtering).- See Also:
- Constant Field Values
-
GAME
public static final java.lang.String GAME
The listing supports the game with the specific listed game code listed.- See Also:
- Constant Field Values
-
COMMENT
public static final java.lang.String COMMENT
A comment specific to the listing.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Listing
public Listing(java.io.File f) throws java.io.IOExceptionCreates a new listing based on a local file that might be added to a catalog. The file must be a plug-in bundle. If it already has a catalog ID, that ID will be used. Otherwise a new ID will be generated and added to the file. Note that no checksum will be set for this listing since checksums are based on the actual download file, which is typically a published bundle generated from the plug-in bundle.- Parameters:
f- the (unpublished) plug-in bundle to extract listing details from- Throws:
java.io.IOException
-
-
Method Detail
-
get
public java.lang.String get(java.lang.String key)
Returns the (possibly localized) value of a key in the catalog properties. The value will be looked up by appending UI locale information in the following order:key_lang_country key_lang key
The first key that is defined will be returned, or elsenullwill be returned if the none of these keys are defined. For example, on a French system in Canada, when looking up the key homepage, the following keys are searched (in order): homepage_fr_CA, homepage_fr, homepage.- Parameters:
key- the name of the catalog listing property to look up- Returns:
- the value of the property in the first matching locale, or
null
-
set
public void set(java.lang.String key, java.lang.String value)Sets the value of the given key. If the value is set tonull, the key will be removed.- Parameters:
key- the name of the key to modifyvalue- the new value of the key, ornullto delete it- Throws:
java.lang.NullPointerException- if the key isnull
-
getCatalogID
public CatalogID getCatalogID()
Returns the catalog ID for this listing, ornullif none is set.- Returns:
- the catalog ID, or
null
-
setCatalogID
public void setCatalogID(CatalogID id)
Sets the catalog ID for this listing, or clears it ifnull.- Parameters:
id- the new ID
-
getChecksum
public java.lang.String getChecksum()
Returns the download file checksum string for this listing, ornullif none is present. The checksum string can be used to check that the file downloaded correctly.- Returns:
- the checksum string or
null
-
setChecksum
public void setChecksum(MD5Checksum checksum)
Sets the checksum value for the listing from a computed checksum value, or removes it ifnull. Checksums are computed on the actual download file (typically a published bundle); they are not computed on the plug-in bundle unless the plug-in bundle is the actual file that will be downloaded.- Parameters:
checksum- the checksum calculator containing the relevant checksum, ornull
-
checksumMatches
public boolean checksumMatches(java.io.File f) throws java.io.IOExceptionReturnstrueif the checksum in this listing matches the checksum of a file. If this listing has no checksum, returnstruewithout computing the file's checksum. Note that checksums should be computed against the actual file that is downloaded (typically a published bundle), not against any other forms.- Parameters:
f- the file to compare to this listing's checksum- Returns:
trueif the file does not appear to be corrupt- Throws:
java.io.IOException- if an exception occurs while processing the file
-
compareTo
public int compareTo(Listing o)
- Specified by:
compareToin interfacejava.lang.Comparable<Listing>
-
isIdenticalTo
public boolean isIdenticalTo(Listing other)
Returnstrueif and only if the listing has exactly the same keys and values as the specified listing. (This method is not namedequalsto avoid confusion withcompareTo, which simply compares the names of the listings for sorting purposes.)- Parameters:
other- the listing to compare this listing to- Returns:
trueif the listings have exactly the same keys and values
-
getName
public java.lang.String getName()
-
getVersion
public java.lang.String getVersion()
-
getSize
public long getSize()
-
getDisplayDate
public java.lang.String getDisplayDate()
-
getDescription
public java.lang.String getDescription()
-
getHomePage
public java.net.URL getHomePage()
-
getApplicationCompatibility
public int getApplicationCompatibility()
Compares the version of the application to the version information included in the catalog listing, if any. Returns 0 if the version information indicates that this plug-in is compatible, -1 if the plug-in is deprecated for this version (the application is too new), or 1 if the plug-in requires a new version of the application.- Returns:
- 0 if the plug-in is compatible, or else -1 or 1 if the application version is too old or too new
-
isHidden
public boolean isHidden()
Returnstrueif the listing is hidden. A listing is hidden if itshiddenproperty is set toyes, or if it is set todependsand the plug-in is either not installed or is up to date.- Returns:
trueif the listing should be hidden in the catalog
-
isNew
public boolean isNew()
Returnstrueif this plug-in appears to be "new", that is, added recently and not seen by the user before. A listing is considered new if its timestamp is more recent than the timestamp of the newest bundle that was observed when the application was last run.- Returns:
trueif this listing is considered "new";falseotherwise
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-