Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-04-17 14:53:09 +0000
committerUwe Stieber2012-04-17 14:53:09 +0000
commit8739cdba5550a829cefe9ee8a5ec2af6843d31b8 (patch)
treeb5293824f610fdbc5f3cc651eae1db7d74ad0d13 /target_explorer/plugins/org.eclipse.tcf.te.core
parentc79ef924abea4c3138594bbbd494a7144c2040ee (diff)
downloadorg.eclipse.tcf-8739cdba5550a829cefe9ee8a5ec2af6843d31b8.tar.gz
org.eclipse.tcf-8739cdba5550a829cefe9ee8a5ec2af6843d31b8.tar.xz
org.eclipse.tcf-8739cdba5550a829cefe9ee8a5ec2af6843d31b8.zip
Target Explorer: code cleanup, removed commented out code
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.core')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/adapters/ModelNodePersistableURIProvider.java231
1 files changed, 6 insertions, 225 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/adapters/ModelNodePersistableURIProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/adapters/ModelNodePersistableURIProvider.java
index 727b9088e..07fbb5e46 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/adapters/ModelNodePersistableURIProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/adapters/ModelNodePersistableURIProvider.java
@@ -27,6 +27,12 @@ import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider
*/
public class ModelNodePersistableURIProvider implements IPersistableURIProvider {
+ /**
+ * Determine the model node from the given context object.
+ *
+ * @param context The context object or <code>null</code>.
+ * @return The model node or <code>null</code>.
+ */
private IModelNode getModelNode(Object context) {
IModelNode node = null;
@@ -143,229 +149,4 @@ public class ModelNodePersistableURIProvider implements IPersistableURIProvider
return location;
}
- //
- // /* (non-Javadoc)
- // * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider#getInterfaceType(java.lang.Object)
- // */
- // @SuppressWarnings("restriction")
- // @Override
- // public String getInterfaceTypeName(Object data) {
- // if (data instanceof IContainerModelNode) {
- // return org.eclipse.tcf.te.runtime.model.activator.CoreBundleActivator.getUniqueIdentifier() + ":" + IContainerModelNode.class.getName(); //$NON-NLS-1$
- // } else if (data instanceof IModelNode) {
- // return org.eclipse.tcf.te.runtime.model.activator.CoreBundleActivator.getUniqueIdentifier() + ":" + IModelNode.class.getName(); //$NON-NLS-1$
- // }
- // return null;
- // }
- //
- // /* (non-Javadoc)
- // * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider#exportFrom(java.lang.Object)
- // */
- // @Override
- // public Map<String, Object> exportFrom(Object data) throws IOException {
- // Assert.isNotNull(data);
- //
- // // Create a new map instance that will hold the exported properties
- // Map<String, Object> result = new HashMap<String, Object>();
- //
- // // Only model nodes are supported
- // if (data instanceof IModelNode && !((IModelNode)data).isEmpty()) {
- // // Get a snapshot of all properties
- // Map<String, Object> properties = ((IModelNode)data).getProperties();
- // // And export the properties to the result map
- // exportFromMap(properties, result);
- // }
- //
- // // If the result map is empty, return null
- // return !result.isEmpty() ? result : null;
- // }
- //
- // /**
- // * Exports the properties of a map from the given source into the given
- // * destination.
- // *
- // * @param src The map to export the properties from. Must not be <code>null</code>.
- // * @param dst The map to write the exported properties to. Must not be <code>null</code>.
- // *
- // * @throws IOException - if the operation fails.
- // */
- // @SuppressWarnings("unchecked")
- // protected void exportFromMap(Map<String, Object> src, Map<String, Object> dst) throws IOException {
- // Assert.isNotNull(src);
- // Assert.isNotNull(dst);
- //
- // // Loop all properties and check for transient or complex properties
- // for (String key : src.keySet()) {
- // if (key.contains(".transient"))
- // {
- // continue; //$NON-NLS-1$
- // }
- //
- // // Get the property value
- // Object value = src.get(key);
- //
- // // If the value is null, no need to go any further
- // if (value == null) {
- // continue;
- // }
- //
- // // For String, Integer, Boolean, etc ... export them as string
- // boolean isSimpleType = value instanceof String || value instanceof Boolean || value instanceof Integer || value instanceof Long
- // || value instanceof Float || value instanceof Double;
- // if (isSimpleType) {
- // dst.put(key, value.toString());
- // continue;
- // }
- //
- // // BigInteger, BigDecimal ... probably needs special handling, for now, export them as string
- // boolean isBigType = value instanceof BigInteger || value instanceof BigDecimal;
- // if (isBigType) {
- // dst.put(key, value.toString());
- // continue;
- // }
- //
- // // For Lists and Arrays, do a deepToString
- // boolean isListType = value instanceof List<?> || value instanceof Object[];
- // if (isListType) {
- // dst.put(key, Arrays.deepToString(value instanceof List<?> ? ((List<?>)value).toArray() : (Object[])value));
- // continue;
- // }
- //
- // // For Maps, create a new destination map and call ourself
- // boolean isMapType = value instanceof Map<?,?>;
- // if (isMapType) {
- // Map<String, Object> result = new HashMap<String, Object>();
- // exportFromMap((Map<String, Object>)value, result);
- // if (!result.isEmpty()) {
- // dst.put(key, result);
- // }
- // continue;
- // }
- //
- // // For anything remaining, check if the value object type can be adapted to
- // // an IPersistableURIProvider itself
- // IPersistableURIProvider persistableURIProvider = value instanceof IAdaptable ? (IPersistableURIProvider)((IAdaptable)value).getAdapter(IPersistableURIProvider.class) : null;
- // if (persistableURIProvider == null) {
- // persistableURIProvider = (IPersistableURIProvider)Platform.getAdapterManager().getAdapter(value, IPersistableURIProvider.class);
- // }
- // if (persistableURIProvider != null) {
- // String storageID = persistableURIProvider.getStorageID();
- // URI uri = persistableURIProvider.getURI(value);
- // String interfaceTypeName = persistableURIProvider.getInterfaceTypeName(value);
- //
- // // Check if the persistable returns complete information to create the reference
- // if (storageID == null) {
- // throw new IOException(NLS.bind(Messages.ModelNodePersistableAdapter_export_invalidPersistable, value.getClass().getCanonicalName(), "storageID")); //$NON-NLS-1$
- // }
- // if (uri == null) {
- // throw new IOException(NLS.bind(Messages.ModelNodePersistableAdapter_export_invalidPersistable, value.getClass().getCanonicalName(), "uri")); //$NON-NLS-1$
- // }
- // if (interfaceTypeName == null) {
- // throw new IOException(NLS.bind(Messages.ModelNodePersistableAdapter_export_invalidPersistable, value.getClass().getCanonicalName(), "interfaceTypeName")); //$NON-NLS-1$
- // }
- //
- // // Create a reference object
- // Map<String, String> reference = new HashMap<String, String>();
- // reference.put("storageID", storageID); //$NON-NLS-1$
- // reference.put("uri", uri.toString()); //$NON-NLS-1$
- // reference.put("interfaceType", interfaceTypeName); //$NON-NLS-1$
- //
- // IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(storageID, false);
- // if (delegate != null) {
- // delegate.write(uri, persistableURIProvider.exportFrom(value));
- // dst.put("reference:" + key, reference); //$NON-NLS-1$
- // continue;
- // }
- // }
- //
- // // Falling through down here is a problem. We should never end up here,
- // // because it means we have no idea on how to persist an object
- // throw new IOException(NLS.bind(Messages.ModelNodePersistableAdapter_export_unknownType, value.getClass().getCanonicalName(), key));
- // }
- // }
- //
- // /* (non-Javadoc)
- // * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider#importTo(java.lang.Object, java.util.Map)
- // */
- // @Override
- // public void importTo(Object data, Map<String, Object> external) throws IOException {
- // Assert.isNotNull(data);
- // Assert.isNotNull(external);
- //
- // // Only model nodes are supported
- // if (data instanceof IModelNode) {
- // IModelNode node = (IModelNode) data;
- // for (String key : external.keySet()) {
- // // Get the property value
- // Object value = external.get(key);
- //
- // // Check for reference objects
- // if (key.startsWith("reference:") && value instanceof Map<?,?>) { //$NON-NLS-1$
- // // Cut the "reference:" from the key
- // String newKey = key.substring(10);
- //
- // @SuppressWarnings("unchecked")
- // Map<String, String> reference = (Map<String, String>)value;
- //
- // // Get the storage id and the URI from the reference
- // String storageID = reference.get("storageID"); //$NON-NLS-1$
- // String uriString = reference.get("uri"); //$NON-NLS-1$
- // String interfaceTypeName = reference.get("interfaceType"); //$NON-NLS-1$
- //
- // // Check if the reference returns complete information to read the referenced storage
- // if (storageID == null) {
- // throw new IOException(NLS.bind(Messages.ModelNodePersistableAdapter_import_invalidReference, "storageID")); //$NON-NLS-1$
- // }
- // if (uriString == null) {
- // throw new IOException(NLS.bind(Messages.ModelNodePersistableAdapter_import_invalidReference, "uri")); //$NON-NLS-1$
- // }
- // if (interfaceTypeName == null) {
- // throw new IOException(NLS.bind(Messages.ModelNodePersistableAdapter_import_invalidReference, "interfaceType")); //$NON-NLS-1$
- // }
- //
- // // Get the persistence delegate
- // IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(storageID, false);
- // if (delegate != null) {
- // URI uri = URI.create(uriString);
- // Map<String, Object> referenceData = delegate.read(uri);
- // if (referenceData != null && !referenceData.isEmpty()) {
- // try {
- // // Now, we have to recreate the object
- //
- // // Separate the bundleId from the interface name
- // String[] pieces = interfaceTypeName.split(":", 2); //$NON-NLS-1$
- // String bundleId = pieces.length > 1 ? pieces[0] : null;
- // if (pieces.length > 1) {
- // interfaceTypeName = pieces[1];
- // }
- //
- // // Determine the bundle to use for loading the class
- // Bundle bundle = bundleId != null && !"".equals(bundleId.trim()) ? Platform.getBundle(bundleId.trim()) : CoreBundleActivator.getContext().getBundle(); //$NON-NLS-1$
- //
- // Class<? extends IModelNode> interfaceType = (Class<? extends IModelNode>)bundle.loadClass(interfaceTypeName);
- // IModelNode referenceNode = Factory.getInstance().newInstance(interfaceType);
- //
- // IPersistableURIProvider persistableURIProvider = (IPersistableURIProvider)referenceNode.getAdapter(IPersistableURIProvider.class);
- // if (persistableURIProvider == null) {
- // persistableURIProvider = (IPersistableURIProvider)Platform.getAdapterManager().getAdapter(referenceNode, IPersistableURIProvider.class);
- // }
- // if (persistableURIProvider != null) {
- // persistableURIProvider.importTo(referenceNode, referenceData);
- // referenceNode.setProperty(IPersistableNodeProperties.PROPERTY_URI, uriString);
- // node.setProperty(newKey, referenceNode);
- // }
- // } catch (ClassNotFoundException e) {
- // throw new IOException(NLS.bind(Messages.ModelNodePersistableAdapter_import_cannotLoadClass, interfaceTypeName), e);
- // }
- // }
- // }
- // }
- // // Not a reference object -> store the object as is to the node
- // else {
- // node.setProperty(key, value);
- // }
- // }
- // }
- // }
-
}

Back to the top