org.eclipse.core.commands
Class ParameterType
java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.core.commands.common.HandleObject
org.eclipse.core.commands.ParameterType
-
All Implemented Interfaces:
-
Comparable,
IIdentifiable
-
public final class ParameterType
- extends
HandleObject
- implements
Comparable
Provides information about the type of a command parameter. Clients can use a
parameter type to check if an object matches the type of the parameter with
isCompatible(Object)
and can get an
AbstractParameterValueConverter
to convert between objects matching
the parameter type and strings that encode the object's identity.
A command parameter is not required to declare a type. To determine if a
given parameter has a type, check if an
IParameter
implements
ITypedParameter
and if so, use
ITypedParameter.getParameterType()
like this:
IParameter parameter = // ... get IParameter from Command
if (parameter instanceof ITypedParameter) {
ParameterType type = ((ITypedParameter)parameter).getParameterType();
if (type != null) {
// this parameter has a ParameterType
}
}
-
Since:
- 3.2
-
See Also:
-
IParameter
,
ITypedParameter.getParameterType()
addListener
public final void addListener(
IParameterTypeListener listener)
- Adds a listener to this parameter type that will be notified when its
state changes.
-
-
-
Parameters:
-
listener
- The listener to be added; must not be null
.
compareTo
public final int compareTo(
Object object)
- Compares this parameter type with another object by comparing each of the
non-transient attributes.
-
-
Specified by:
-
compareTo
in interface
Comparable
-
-
Parameters:
-
object
- The object with which to compare; must be an instance of
ParameterType
.
-
Returns:
- A negative integer, zero or a positive integer, if the object is
greater than, equal to or less than this parameter type.
define
public final void define(
String type,
AbstractParameterValueConverter parameterTypeConverter)
-
Defines this parameter type, setting the defined property to
true
.
Notification is sent to all listeners that something has changed.
-
-
-
Parameters:
-
type
- a string identifying the Java object type for this parameter
type; null
is interpreted as
"java.lang.Object"
-
parameterTypeConverter
- an
AbstractParameterValueConverter
to perform
string/object conversions for parameter values; may be
null
getValueConverter
public final
AbstractParameterValueConverter getValueConverter()
throws
NotDefinedException
- Returns the value converter associated with this parameter, if any.
-
-
-
Returns:
- The parameter value converter, or
null
if there is
no value converter for this parameter.
-
Throws:
-
NotDefinedException
- if the parameter type is not currently defined
isCompatible
public boolean isCompatible(
Object value)
throws
NotDefinedException
- Returns whether the provided value is compatible with this parameter
type. An object is compatible with a parameter type if the object is an
instance of the class defined as the parameter's type class.
-
-
-
Parameters:
-
value
- an object to check for compatibility with this parameter type;
may be null
.
-
Returns:
-
true
if the value is compatible with this type,
false
otherwise
-
Throws:
-
NotDefinedException
- if the parameter type is not currently defined
removeListener
public final void removeListener(
IParameterTypeListener listener)
- Unregisters listener for changes to properties of this parameter type.
-
-
-
Parameters:
-
listener
- the instance to unregister. Must not be null
.
If an attempt is made to unregister an instance which is not
already registered with this instance, no operation is
performed.
toString
public final
String toString()
- The string representation of this parameter type. For debugging purposes
only. This string should not be shown to an end user.
-
-
Specified by:
-
toString
in class
HandleObject
-
-
Returns:
- The string representation; never
null
.
undefine
public final void undefine()
- Makes this parameter type become undefined. Notification is sent to all
listeners.
-
-
Specified by:
-
undefine
in class
HandleObject
-
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.