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.String
COMMENT
A comment specific to the listing.static 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).static java.lang.String
CREDIT
Name of the plug-in developer.static java.lang.String
DATE
An optional date that overrides the catalog ID.static java.lang.String
DESCRIPTION
The human-friendly description (may be localized).static java.lang.String
DIGEST
The MD5 checksum of the unpacked bundle.static java.lang.String
GAME
The listing supports the game with the specific listed game code listed.static java.lang.String
HIDDEN
The listing should not be included in the download list shown to the user.static java.lang.String
HOME_PAGE
A URL for more information.static java.lang.String
ID
The catalog ID (required).static java.lang.String
INSTALL_SIZE
The installed (unpacked) size (bytes).static java.lang.String
MAXIMUM_VERSION
The maximum build number that the plug-in is compatible with.static java.lang.String
MINIMUM_VERSION
The minimum build number needed by the plug-in.static java.lang.String
NAME
The name of the plug-in (may be localized) (required).static java.lang.String
REPLACES
A catalog ID that should be uninstalled if this is installed.static java.lang.String
REQUIRES
A list of other catalog IDs required by this plug-in.static java.lang.String
SIZE
The download size (bytes).static java.lang.String
TAGS
Tags that can be searched for.static java.lang.String
URL
The URL, either absolute or relative to the catalog if it starts with "./" (required).static java.lang.String
VERSION
The 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 boolean
checksumMatches(java.io.File f)
Returnstrue
if the checksum in this listing matches the checksum of a file.int
compareTo(Listing o)
java.lang.String
get(java.lang.String key)
Returns the (possibly localized) value of a key in the catalog properties.int
getApplicationCompatibility()
Compares the version of the application to the version information included in the catalog listing, if any.CatalogID
getCatalogID()
Returns the catalog ID for this listing, ornull
if none is set.java.lang.String
getChecksum()
Returns the download file checksum string for this listing, ornull
if none is present.java.lang.String
getDescription()
java.lang.String
getDisplayDate()
java.net.URL
getHomePage()
java.lang.String
getName()
long
getSize()
java.lang.String
getVersion()
boolean
isHidden()
Returnstrue
if the listing is hidden.boolean
isIdenticalTo(Listing other)
Returnstrue
if and only if the listing has exactly the same keys and values as the specified listing.boolean
isNew()
Returnstrue
if this plug-in appears to be "new", that is, added recently and not seen by the user before.void
set(java.lang.String key, java.lang.String value)
Sets the value of the given key.void
setCatalogID(CatalogID id)
Sets the catalog ID for this listing, or clears it ifnull
.void
setChecksum(MD5Checksum checksum)
Sets the checksum value for the listing from a computed checksum value, or removes it ifnull
.java.lang.String
toString()
-
-
-
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.IOException
Creates 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 elsenull
will 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, ornull
to delete it- Throws:
java.lang.NullPointerException
- if the key isnull
-
getCatalogID
public CatalogID getCatalogID()
Returns the catalog ID for this listing, ornull
if 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, ornull
if 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.IOException
Returnstrue
if the checksum in this listing matches the checksum of a file. If this listing has no checksum, returnstrue
without 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:
true
if 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:
compareTo
in interfacejava.lang.Comparable<Listing>
-
isIdenticalTo
public boolean isIdenticalTo(Listing other)
Returnstrue
if and only if the listing has exactly the same keys and values as the specified listing. (This method is not namedequals
to avoid confusion withcompareTo
, which simply compares the names of the listings for sorting purposes.)- Parameters:
other
- the listing to compare this listing to- Returns:
true
if 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()
Returnstrue
if the listing is hidden. A listing is hidden if itshidden
property is set toyes
, or if it is set todepends
and the plug-in is either not installed or is up to date.- Returns:
true
if the listing should be hidden in the catalog
-
isNew
public boolean isNew()
Returnstrue
if 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:
true
if this listing is considered "new";false
otherwise
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-