* the adaptable to adapt
* @return the resultant adaptable. May be the same adaptable, a new
* adaptable, or <code>null</code>.
*/
private IAdaptable adapt(Type type, IAdaptable adaptable) {
IAdapterManager adapterManager = Platform.getAdapterManager();
Class[] directClasses = adapterManager.computeClassOrder(adaptable
.getClass());
for (int i = 0; i < directClasses.length; i++) {
Class clazz = directClasses[i];
if (clazz.getName().equals(type.className))
return adaptable;
}
if ((type.flags & Type.ADAPT) != 0) {
Object adapted = adapterManager.getAdapter(adaptable,
type.className);
if (adapted instanceof IAdaptable)
return (IAdaptable) adapted;
PackageAdmin admin = getPackageAdmin();