net.rim.device.api.command
Class CommandMetadata

java.lang.Object
  extended by net.rim.device.api.command.CommandMetadata

public class CommandMetadata
extends Object

Encapsulates metadata associated with a CommandHandler. The only required piece of metadata for a command is the command's identifier, which is set when the CommandMetadata object is constructed and is stored in the CommandMetadata.COMMAND_ID field.

For more information about using this class, see the package overview.

Since:
BlackBerry API 6.0.0

Field Summary
static String ALIGNMENT
          The alignment used by the command.
static String BITMAP_ICON
          The bitmap icon of the command.
static String COMMAND_ID
          The identifier of the command.
static String LABEL
          The label of the command.
static String LABEL_ORIENTATION
          The orientation of the command's label.
static String LABEL_RESOURCE_ID
          The identifier of the command's label.
static String PREDEFINED_ICON
          The predefined icon of the command.
static String RESOURCE_BUNDLE_NAME
          The name of the resource bundle used by the command.
static String THEMED_ICON
          The themed icon of the command.
 
Constructor Summary
CommandMetadata(String commandId)
          Creates an instance of CommandMetadata.
CommandMetadata(CommandMetadata metadata)
          Creates an instance of CommandMetadata based on an existing CommandMetadata instance.
 
Method Summary
 void addCommandCategory(String commandCategory)
          Adds a command category to the command categories for the associated command.
 void addContextCategory(String contextCategory)
          Adds a context category to the context categories for the associated command.
 boolean getBoolean(String name)
          Returns the value associated with a specified attribute name as a boolean.
 String getClassname()
          Returns the command's class name.
 CategoryCollection getCommandCategories()
          Returns the command categories for the associated command.
 String getCommandId()
          Returns the command's identifier (the value stored in CommandMetadata.COMMAND_ID).
 CategoryCollection getContextCategories()
          Returns the context categories for the associated command.
 ExecutionContextEnum getExecutionContext()
          Returns the execution context of the associated command.
 int getInt(String name)
          Returns the value associated with a specified attribute name as an int.
 long getLong(String name)
          Returns the value associated with a specified attribute name as a long.
 String getResourceBundleName()
          Returns the name of the command's resource bundle (the value stored in CommandMetadata.RESOURCE_BUNDLE_NAME).
 String getString(String name)
          Returns the value associated with a specified attribute name as a string.
 boolean has(String name)
          Determines if the metadata instance contains a specified attribute name.
 boolean optBoolean(String name)
          Returns the value associated with a specified attribute name as a boolean.
 boolean optBoolean(String name, boolean defaultValue)
          Returns the value associated with a specified attribute name as a boolean.
 int optInt(String name)
          Returns the value associated with a specified attribute name as a int.
 int optInt(String name, int defaultValue)
          Returns the value associated with a specified attribute name as a int.
 long optLong(String name)
          Returns the value associated with a specified attribute name as a long.
 long optLong(String name, long defaultValue)
          Returns the value associated with a specified attribute name as a long.
 String optString(String name)
          Returns the value associated with a specified attribute name as a string.
 String optString(String name, String defaultValue)
          Returns the value associated with a specified attribute name as a string.
 void set(String name, boolean value)
          Stores an attribute name and boolean value in the metadata instance.
 void set(String name, int value)
          Stores an attribute name and int value in the metadata instance.
 void set(String name, String value)
          Stores an attribute name and string value in the metadata instance.
 void set(String name, long value)
          Stores an attribute name and long value in the metadata instance.
 void setClassname(String classname)
          Sets the class name of the command.
 void setCommandCategories(CategoryCollection commandCategories)
          Sets the command categories for the associated command.
 void setContextCategories(CategoryCollection contextCategories)
          Sets the context categories for the associated command.
 void setExecutionContext(ExecutionContextEnum executionContext)
          Sets the execution context of the associated command.
 void setResourceBundleName(String resourceBundleName)
          Sets the name of the command's resource bundle (the value stored in CommandMetadata.RESOURCE_BUNDLE_NAME).
 String toString()
          Returns a string representation of the instance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 



Field Detail

COMMAND_ID

public static final String COMMAND_ID
The identifier of the command.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

RESOURCE_BUNDLE_NAME

public static final String RESOURCE_BUNDLE_NAME
The name of the resource bundle used by the command.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

LABEL_RESOURCE_ID

public static final String LABEL_RESOURCE_ID
The identifier of the command's label.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

LABEL

public static final String LABEL
The label of the command.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

LABEL_ORIENTATION

public static final String LABEL_ORIENTATION
The orientation of the command's label.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

THEMED_ICON

public static final String THEMED_ICON
The themed icon of the command.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

PREDEFINED_ICON

public static final String PREDEFINED_ICON
The predefined icon of the command.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

ALIGNMENT

public static final String ALIGNMENT
The alignment used by the command.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

BITMAP_ICON

public static final String BITMAP_ICON
The bitmap icon of the command.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0


Constructor Detail

CommandMetadata

public CommandMetadata(String commandId)
Creates an instance of CommandMetadata.

Parameters:
commandId - Identifier of the command that the instance is associated with.
Since:
BlackBerry API 6.0.0

CommandMetadata

public CommandMetadata(CommandMetadata metadata)
Creates an instance of CommandMetadata based on an existing CommandMetadata instance.

This constructor does a shallow copy of the metadata, except for the command categories and context categories, each of which are deep copied.

Parameters:
metadata - CommandMetadata instance to clone.
Since:
BlackBerry API 6.0.0


Method Detail

getCommandId

public String getCommandId()
Returns the command's identifier (the value stored in CommandMetadata.COMMAND_ID).

Returns:
The command's identifier.
Since:
BlackBerry API 6.0.0

getClassname

public String getClassname()
Returns the command's class name.

Returns:
The command's class name.
Since:
BlackBerry API 6.0.0

setClassname

public void setClassname(String classname)
Sets the class name of the command.

Parameters:
classname - The command's class name.
Since:
BlackBerry API 6.0.0

getResourceBundleName

public String getResourceBundleName()
Returns the name of the command's resource bundle (the value stored in CommandMetadata.RESOURCE_BUNDLE_NAME).

Returns:
The resource bundle name.
Since:
BlackBerry API 6.0.0

setResourceBundleName

public void setResourceBundleName(String resourceBundleName)
Sets the name of the command's resource bundle (the value stored in CommandMetadata.RESOURCE_BUNDLE_NAME).

Parameters:
resourceBundleName - The name of the resource bundle.
Since:
BlackBerry API 6.0.0

getExecutionContext

public ExecutionContextEnum getExecutionContext()
Returns the execution context of the associated command.

Returns:
The execution context.
See Also:
CommandMetadata.setExecutionContext(net.rim.device.api.command.ExecutionContextEnum)
Since:
BlackBerry API 6.0.0

setExecutionContext

public void setExecutionContext(ExecutionContextEnum executionContext)
Sets the execution context of the associated command.

The value of the execution context instructs the command registrar to execute the command in an execution context other than the current thread (for example, in the process that registered the command).

Parameters:
executionContext - The execution context.
Since:
BlackBerry API 6.0.0

getCommandCategories

public CategoryCollection getCommandCategories()
Returns the command categories for the associated command.

Returns:
The command categories. Never returns null. If no command categories have been set for the associated command, returns a NullCategoryCollection singleton instance.
Since:
BlackBerry API 6.0.0

setCommandCategories

public void setCommandCategories(CategoryCollection commandCategories)
Sets the command categories for the associated command.

Parameters:
commandCategories - The command categories. If null, sets the command categories to a NullCategoryCollection singleton instance.
Since:
BlackBerry API 6.0.0

addCommandCategory

public void addCommandCategory(String commandCategory)
Adds a command category to the command categories for the associated command.

Parameters:
commandCategory - The command category to add.
Since:
BlackBerry API 6.0.0

getContextCategories

public CategoryCollection getContextCategories()
Returns the context categories for the associated command.

Returns:
The context categories. Never returns null. If no context categories have been set for the associated command, returns a NullCategoryCollection singleton instance.
Since:
BlackBerry API 6.0.0

setContextCategories

public void setContextCategories(CategoryCollection contextCategories)
Sets the context categories for the associated command.

Parameters:
contextCategories - The context categories. If null, sets the context categories to a NullCategoryCollection singleton instance.
Since:
BlackBerry API 6.0.0

addContextCategory

public void addContextCategory(String contextCategory)
Adds a context category to the context categories for the associated command.

Parameters:
contextCategory - Context category to add.
Since:
BlackBerry API 6.0.0

has

public boolean has(String name)
Determines if the metadata instance contains a specified attribute name.

Parameters:
name - Metadata attribute name to check.
Returns:
true if the metadata instance contains the specified name, false otherwise.
Since:
BlackBerry API 6.0.0

set

public void set(String name,
                String value)
Stores an attribute name and string value in the metadata instance.

Parameters:
name - Name of the attribute.
value - Value of the attribute.
Since:
BlackBerry API 6.0.0

getString

public String getString(String name)
                 throws CommandMetadataException
Returns the value associated with a specified attribute name as a string.

Parameters:
name - Name of the attribute.
Returns:
Value of the attribute.
Throws:
CommandMetadataException - if the value associated with name is not a string.
NonExistentAttributeException - if an attribute with the specified name does not exist in the instance.
Since:
BlackBerry API 6.0.0

optString

public String optString(String name)
Returns the value associated with a specified attribute name as a string.

Parameters:
name - Name of the attribute.
Returns:
Value of the attribute. Returns null if an attribute with the specified name does not exist in the metadata instance.
Since:
BlackBerry API 6.0.0

optString

public String optString(String name,
                        String defaultValue)
Returns the value associated with a specified attribute name as a string.

Parameters:
name - Name of the attribute.
defaultValue - Default value.
Returns:
Value of the attribute. Returns defaultValue if an attribute with the specified name does not exist in the instance.
Since:
BlackBerry API 6.0.0

set

public void set(String name,
                long value)
Stores an attribute name and long value in the metadata instance.

Parameters:
name - Name of the attribute.
value - Value of the attribute.
Since:
BlackBerry API 6.0.0

getLong

public long getLong(String name)
             throws CommandMetadataException
Returns the value associated with a specified attribute name as a long.

Parameters:
name - Name of the attribute.
Returns:
Value of the aattribute.
Throws:
CommandMetadataException - if name is not a long.
NonExistentAttributeException - if an attribute with the specified name does not exist in the instance.
Since:
BlackBerry API 6.0.0

optLong

public long optLong(String name,
                    long defaultValue)
Returns the value associated with a specified attribute name as a long.

Parameters:
name - Name of the attribute.
defaultValue - Default value.
Returns:
Value of the attribute. Returns defaultValue if an attribute with the specified name does not exist in the instance.
Since:
BlackBerry API 6.0.0

optLong

public long optLong(String name)
Returns the value associated with a specified attribute name as a long.

Parameters:
name - Name of the attribute.
Returns:
Value of the attribute. Returns null if an attribute with the specified name does not exist in the metadata instance.
Since:
BlackBerry API 6.0.0

set

public void set(String name,
                int value)
Stores an attribute name and int value in the metadata instance.

Parameters:
name - Name of the attribute.
value - Value of the attribute.
Since:
BlackBerry API 6.0.0

getInt

public int getInt(String name)
           throws CommandMetadataException
Returns the value associated with a specified attribute name as an int.

Parameters:
name - Name of the attribute.
Returns:
Value of the attribute.
Throws:
CommandMetadataException - if name is not an int.
NonExistentAttributeException - if an attribute with the specified name does not exist in the instance.
Since:
BlackBerry API 6.0.0

optInt

public int optInt(String name,
                  int defaultValue)
Returns the value associated with a specified attribute name as a int.

Parameters:
name - Name of the attribute.
defaultValue - Default value.
Returns:
Value of the attribute. Returns defaultValue if an attribute with the specified name does not exist in the instance.
Since:
BlackBerry API 6.0.0

optInt

public int optInt(String name)
Returns the value associated with a specified attribute name as a int.

Parameters:
name - Name of the attribute.
Returns:
Value of the attribute. Returns null if an attribute with the specified name does not exist in the metadata instance.
Since:
BlackBerry API 6.0.0

set

public void set(String name,
                boolean value)
Stores an attribute name and boolean value in the metadata instance.

Parameters:
name - Name of the attribute.
value - Value of the attribute.
Since:
BlackBerry API 6.0.0

getBoolean

public boolean getBoolean(String name)
                   throws CommandMetadataException
Returns the value associated with a specified attribute name as a boolean.

Parameters:
name - Name of the attribute.
Returns:
Value of the attribute.
Throws:
CommandMetadataException - if name is not a boolean.
NonExistentAttributeException - if an attribute with the specified name does not exist in the instance.
Since:
BlackBerry API 6.0.0

optBoolean

public boolean optBoolean(String name,
                          boolean defaultValue)
Returns the value associated with a specified attribute name as a boolean.

Parameters:
name - Name of the attribute.
defaultValue - Default value.
Returns:
Value of the attribute. Returns defaultValue if an attribute with the specified name does not exist in the metadata instance.
Since:
BlackBerry API 6.0.0

optBoolean

public boolean optBoolean(String name)
Returns the value associated with a specified attribute name as a boolean.

Parameters:
name - Name of the attribute.
Returns:
Value of the attribute. Returns false if an attribute with the specified name does not exist in the metadata instance.
Since:
BlackBerry API 6.0.0

toString

public String toString()
Returns a string representation of the instance.

Overrides:
toString in class Object
Returns:
A string representation of the instance.
Since:
BlackBerry API 6.0.0





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.