Package 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
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:
-
Field Summary
Fields inherited from class org.eclipse.core.commands.common.HandleObject
defined, id, string -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddListener(IParameterTypeListener listener) Adds a listener to this parameter type that will be notified when its state changes.final intCompares this parameter type with another object by comparing each of the non-transient attributes.final voiddefine(String type, AbstractParameterValueConverter parameterTypeConverter) Defines this parameter type, setting the defined property totrue.Returns the value converter associated with this parameter, if any.booleanisCompatible(Object value) Returns whether the provided value is compatible with this parameter type.final voidremoveListener(IParameterTypeListener listener) Unregisters listener for changes to properties of this parameter type.final StringtoString()The string representation of this parameter type.final voidundefine()Makes this parameter type become undefined.Methods inherited from class org.eclipse.core.commands.common.HandleObject
equals, getId, hashCode, isDefinedMethods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
-
Method Details
-
addListener
Adds a listener to this parameter type that will be notified when its state changes.- Parameters:
listener- The listener to be added; must not benull.
-
compareTo
Compares this parameter type with another object by comparing each of the non-transient attributes.- Specified by:
compareToin interfaceComparable- Parameters:
object- The object with which to compare; must be an instance ofParameterType.- Returns:
- A negative integer, zero or a positive integer, if the object is greater than, equal to or less than this parameter type.
-
define
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;nullis interpreted as"java.lang.Object"parameterTypeConverter- anAbstractParameterValueConverterto perform string/object conversions for parameter values; may benull
-
getValueConverter
Returns the value converter associated with this parameter, if any.- Returns:
- The parameter value converter, or
nullif there is no value converter for this parameter. - Throws:
NotDefinedException- if the parameter type is not currently defined
-
isCompatible
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 benull.- Returns:
trueif the value is compatible with this type,falseotherwise- Throws:
NotDefinedException- if the parameter type is not currently defined
-
removeListener
Unregisters listener for changes to properties of this parameter type.- Parameters:
listener- the instance to unregister. Must not benull. If an attempt is made to unregister an instance which is not already registered with this instance, no operation is performed.
-
toString
The string representation of this parameter type. For debugging purposes only. This string should not be shown to an end user.- Specified by:
toStringin classHandleObject- 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:
undefinein classHandleObject
-