Bukkit  1.4.7-R1.0
 All Classes Namespaces Files Functions Variables Enumerator Pages
org.bukkit.metadata.MetadataStoreBase< T > Class Referenceabstract

Public Member Functions

synchronized void setMetadata (T subject, String metadataKey, MetadataValue newMetadataValue)
 Adds a metadata value to an object.
 
synchronized List< MetadataValuegetMetadata (T subject, String metadataKey)
 Returns all metadata values attached to an object.
 
synchronized boolean hasMetadata (T subject, String metadataKey)
 Tests to see if a metadata attribute has been set on an object.
 
synchronized void removeMetadata (T subject, String metadataKey, Plugin owningPlugin)
 Removes a metadata item owned by a plugin from a subject.
 
synchronized void invalidateAll (Plugin owningPlugin)
 Invalidates all metadata in the metadata store that originates from the given plugin.
 

Protected Member Functions

abstract String disambiguate (T subject, String metadataKey)
 Creates a unique name for the object receiving metadata by combining unique data from the subject with a metadataKey.
 

Detailed Description

Definition at line 8 of file MetadataStoreBase.java.

Member Function Documentation

abstract String org.bukkit.metadata.MetadataStoreBase< T >.disambiguate ( subject,
String  metadataKey 
)
protectedpure virtual

Creates a unique name for the object receiving metadata by combining unique data from the subject with a metadataKey.

The name created must be globally unique for the given object and any two equivalent objects must generate the same unique name. For example, two Player objects must generate the same string if they represent the same player, even if the objects would fail a reference equality test.

Parameters
subjectThe object for which this key is being generated.
metadataKeyThe name identifying the metadata value.
Returns
a unique metadata key for the given subject.
synchronized List<MetadataValue> org.bukkit.metadata.MetadataStoreBase< T >.getMetadata ( subject,
String  metadataKey 
)

Returns all metadata values attached to an object.

If multiple plugins have attached metadata, each will value will be included.

Parameters
subjectthe object being interrogated.
metadataKeythe unique metadata key being sought.
Returns
A list of values, one for each plugin that has set the requested value.
See Also
MetadataStore::getMetadata(Object, String)

Definition at line 57 of file MetadataStoreBase.java.

synchronized boolean org.bukkit.metadata.MetadataStoreBase< T >.hasMetadata ( subject,
String  metadataKey 
)

Tests to see if a metadata attribute has been set on an object.

Parameters
subjectthe object upon which the has-metadata test is performed.
metadataKeythe unique metadata key being queried.
Returns
the existence of the metadataKey within subject.

Definition at line 73 of file MetadataStoreBase.java.

synchronized void org.bukkit.metadata.MetadataStoreBase< T >.invalidateAll ( Plugin  owningPlugin)

Invalidates all metadata in the metadata store that originates from the given plugin.

Doing this will force each invalidated metadata item to be recalculated the next time it is accessed.

Parameters
owningPluginthe plugin requesting the invalidation.
See Also
MetadataStore::invalidateAll(org.bukkit.plugin.Plugin)
Exceptions
IllegalArgumentExceptionIf plugin is null

Definition at line 110 of file MetadataStoreBase.java.

synchronized void org.bukkit.metadata.MetadataStoreBase< T >.removeMetadata ( subject,
String  metadataKey,
Plugin  owningPlugin 
)

Removes a metadata item owned by a plugin from a subject.

Parameters
subjectthe object to remove the metadata from.
metadataKeythe unique metadata key identifying the metadata to remove.
owningPluginthe plugin attempting to remove a metadata item.
See Also
MetadataStore::removeMetadata(Object, String, org.bukkit.plugin.Plugin)
Exceptions
IllegalArgumentExceptionIf plugin is null

Definition at line 87 of file MetadataStoreBase.java.

synchronized void org.bukkit.metadata.MetadataStoreBase< T >.setMetadata ( subject,
String  metadataKey,
MetadataValue  newMetadataValue 
)

Adds a metadata value to an object.

Each metadata value is owned by a specificPlugin. If a plugin has already added a metadata value to an object, that value will be replaced with the value of

newMetadataValue

. Multiple plugins can set independent values for the same

metadataKey

without conflict.

Implementation note: I considered using a java.util.concurrent.locks.ReadWriteLock for controlling access to

metadataMap

, but decided that the added overhead wasn't worth the finer grained access control. Bukkit is almost entirely single threaded so locking overhead shouldn't pose a problem.

Parameters
subjectThe object receiving the metadata.
metadataKeyA unique key to identify this metadata.
newMetadataValueThe metadata value to apply.
See Also
MetadataStore::setMetadata(Object, String, MetadataValue)
Exceptions
IllegalArgumentExceptionIf value is null, or the owning plugin is null

Definition at line 28 of file MetadataStoreBase.java.

References org.bukkit.metadata.MetadataValue.getOwningPlugin().


The documentation for this class was generated from the following file: