Package de.xima.fc.mdl
Class PluginID
java.lang.Object
de.xima.fc.mdl.PluginID
- All Implemented Interfaces:
Serializable
Model for the ID of a plugin. Each plugin must have a Manifest with the entry
Plugin-Key. Optionally, if
the plugin consists of multiple files, it may also have a Plugin-File-Key. The ID of a plugin is the
plugin key + the file key (empty string if not present).
Note that there might still be legacy plugins without an ID, but these are deprecated and will not be supported in a later version anymore.
A plugin ID has a canonical string representation which is a URL path consisting of the key and the file key (if
present), e.g. key, key/fileKey or some%2fkey/fileKey.
- Since:
- 8.0.0
- Author:
- XIMA MEDIA GmbH
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets the plugin key of the plugin, from thePlugin-File-KeyManifest entry of the plugin.getKey()Gets the plugin key of the plugin, from thePlugin-KeyManifest entry of the plugin.inthashCode()booleanChecks whether this ID has a file key.ofManifest(Manifest manifest) Extracts the plugin ID from the main attributes of a Manifest.ofManifestAttributes(Map<?, ?> manifestAttributes) Extracts the plugin ID from the main attributes of a Manifest.static PluginIDParses the canonical representation of a plugin ID, as returned bytoString().toString()
-
Constructor Details
-
PluginID
Creates a new plugin ID from the given components.- Parameters:
key- The key of the plugin, from thePlugin-KeyManifest entry of the plugin.fileKey- Optional file key of the plugin, from thePlugin-File-KeyManifest entry of the plugin.nullvalues are normalized to the empty string.- Throws:
IllegalArgumentException- When thekeyisnullor empty.
-
-
Method Details
-
equals
-
getFileKey
Gets the plugin key of the plugin, from thePlugin-File-KeyManifest entry of the plugin. The file key is required only for plugins that consist of multiple files.- Returns:
- The file key of the plugin, never
nullbut might be empty.
-
getKey
Gets the plugin key of the plugin, from thePlugin-KeyManifest entry of the plugin. The key is required for every plugin.- Returns:
- The key of the plugin
-
hashCode
public int hashCode() -
isHasFileKey
public boolean isHasFileKey()Checks whether this ID has a file key.- Returns:
trueif thegetFileKey()is not empty, orfalseotherwise.
-
toString
-
ofManifest
Extracts the plugin ID from the main attributes of a Manifest.- Parameters:
manifest- Manifest of a plugin JAR file.- Returns:
- The ID from the Manifest, or empty if the Manifest does not contain an ID or if the given Manifest was
null.
-
ofManifestAttributes
Extracts the plugin ID from the main attributes of a Manifest.- Parameters:
manifestAttributes- Map with the Manifest attributes of a plugin JAR file. The values must be strings, the keys can be strings orManifest attribute names.- Returns:
- The ID from the Manifest, or empty if the Manifest attributes do not contain an ID.
-
parse
Parses the canonical representation of a plugin ID, as returned bytoString().- Parameters:
id- ID to parse.- Returns:
- The parsed ID, or
nullif the given ID isnullor empty. - Throws:
IllegalArgumentException- When the ID string is invalid and neithernullnor empty.
-