public abstract class PropertyTester extends Object implements IPropertyTester
org.eclipse.core.expresssions.propertyTesters
must extend PropertyTester
.
A property tester implements the property tests enumerated in the property tester extension point. For the following property test extension
<propertyTester namespace="org.eclipse.jdt.core" id="org.eclipse.jdt.core.IPackageFragmentTester" properties="isDefaultPackage" type="org.eclipse.jdt.core.IPackageFragment" class="org.eclipse.demo.MyPackageFragmentTester"> </propertyTester>the corresponding implementation class looks like:
public class MyPackageFragmentTester extends PropertyTester { public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { IPackageFragment fragment= (IPackageFragment)receiver; if ("isDefaultPackage".equals(property)) { return expectedValue == null ? fragment.isDefaultPackage() : fragment.isDefaultPackage() == ((Boolean)expectedValue).booleanValue(); } Assert.isTrue(false); return false; } }The property can then be used in a test expression as follows:
<instanceof value="org.eclipse.core.IPackageFragment"/> <test property="org.eclipse.jdt.core.isDefaultPackage"/>
There is no guarantee that the same instance of a property tester is used to handle <test property="..."/> requests. So property testers should always be implemented in a stateless fashion.
Constructor and Description |
---|
PropertyTester() |
Modifier and Type | Method and Description |
---|---|
boolean |
handles(String namespace,
String property)
Returns whether the property tester can handle the given
property or not.
|
IPropertyTester |
instantiate()
Loads the implementation class for this property tester and returns an
instance of this class.
|
org.eclipse.core.internal.expressions.PropertyTesterDescriptor |
internalCreateDescriptor()
Note: this method is for internal use only.
|
void |
internalInitialize(org.eclipse.core.internal.expressions.PropertyTesterDescriptor descriptor)
Initialize the property tester with the given name space and property.
|
boolean |
isDeclaringPluginActive()
Returns
true if the implementation class of this property
tester can be loaded. |
boolean |
isInstantiated()
Returns whether the implementation class for this property tester is
loaded or not.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
test
public final void internalInitialize(org.eclipse.core.internal.expressions.PropertyTesterDescriptor descriptor)
Note: this method is for internal use only. Clients must not call this method.
descriptor
- the descriptor object for this testerpublic final org.eclipse.core.internal.expressions.PropertyTesterDescriptor internalCreateDescriptor()
public final boolean handles(String namespace, String property)
handles
in interface IPropertyTester
namespace
- the name space to be consideredproperty
- the property to testtrue
if the tester provides an implementation
for the given property; otherwise false
is returnedpublic final boolean isInstantiated()
isInstantiated
in interface IPropertyTester
true
if the implementation class is loaded;
false
otherwisepublic boolean isDeclaringPluginActive()
true
if the implementation class of this property
tester can be loaded. This is the case if the plug-in providing
the implementation class is active. Returns false
otherwise.isDeclaringPluginActive
in interface IPropertyTester
public final IPropertyTester instantiate()
instantiate
in interface IPropertyTester
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.