Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2008-05-19 04:11:28 +0000
committerslewis2008-05-19 04:11:28 +0000
commitf72bd0c76e580ba6f1ed4cc69c75d202b6a15613 (patch)
tree13a5402fa7cc6d9627f8727eab52ba955a97746f
parent146302c74c1800448d47e7caff94e87a1a451702 (diff)
downloadorg.eclipse.ecf-f72bd0c76e580ba6f1ed4cc69c75d202b6a15613.tar.gz
org.eclipse.ecf-f72bd0c76e580ba6f1ed4cc69c75d202b6a15613.tar.xz
org.eclipse.ecf-f72bd0c76e580ba6f1ed4cc69c75d202b6a15613.zip
Generalized putAssociates/getAssociates for IIDEntry so that sets of IDs could be added via a key
-rw-r--r--framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/IDEntry.java22
-rw-r--r--framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/storage/IIDEntry.java19
2 files changed, 20 insertions, 21 deletions
diff --git a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/IDEntry.java b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/IDEntry.java
index e9cbf372b..ca66c241d 100644
--- a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/IDEntry.java
+++ b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/IDEntry.java
@@ -32,8 +32,6 @@ public class IDEntry implements IIDEntry {
private final ISecurePreferences prefs;
- private final String ASSOCIATE_IDENTRIES_NODE = "associates"; //$NON-NLS-1$
-
public IDEntry(ISecurePreferences prefs) {
this.prefs = prefs;
}
@@ -45,11 +43,12 @@ public class IDEntry implements IIDEntry {
return prefs;
}
- /* (non-Javadoc)
- * @see org.eclipse.ecf.storage.IIDEntry#addAssociateIDEntry(org.eclipse.ecf.storage.IIDEntry,boolean encrypt)
- */
- public void addAssociateIDEntry(IIDEntry entry, boolean encrypt) throws IDStoreException {
- ISecurePreferences associateNode = prefs.node(ASSOCIATE_IDENTRIES_NODE);
+ public void putAssociate(String key, IIDEntry entry, boolean encrypt) throws IDStoreException {
+ if (key == null)
+ throw new IDStoreException("key cannot be null"); //$NON-NLS-1$
+ if (entry == null)
+ throw new IDStoreException("entry cannot be null"); //$NON-NLS-1$
+ ISecurePreferences associateNode = prefs.node(key);
String entryAssociate = createAssociateName(entry);
associateNode.node(entryAssociate);
}
@@ -104,11 +103,10 @@ public class IDEntry implements IIDEntry {
prefs.removeNode();
}
- /* (non-Javadoc)
- * @see org.eclipse.ecf.storage.IIDEntry#getAssociateIDEntries()
- */
- public IIDEntry[] getAssociateIDEntries() {
- ISecurePreferences associateNode = prefs.node(ASSOCIATE_IDENTRIES_NODE);
+ public IIDEntry[] getAssociates(String key) {
+ if (key == null)
+ return new IIDEntry[0];
+ ISecurePreferences associateNode = prefs.node(key);
String[] childrenNames = associateNode.childrenNames();
List results = new ArrayList();
for (int i = 0; i < childrenNames.length; i++) {
diff --git a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/storage/IIDEntry.java b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/storage/IIDEntry.java
index 7e85f0233..283eac812 100644
--- a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/storage/IIDEntry.java
+++ b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/storage/IIDEntry.java
@@ -40,24 +40,25 @@ public interface IIDEntry {
public ID createID() throws IDCreateException;
/**
- * Get any {@link IIDEntry}s that have previously been associated with this IIDEntry via {@link #addAssociateIDEntry(IIDEntry,boolean)}.
+ * Get any {@link IIDEntry}s that have previously been associated with this IIDEntry via {@link #putAssociate(java.lang.String,IIDEntry,boolean)}.
+ * @param key the String key for retrieving associates. Must not be <code>null</code>.
*
- * @return IIDEntry[] of associated IIDEntry instances that have previously been successfully stored via {@link #addAssociateIDEntry(IIDEntry,boolean)}.
- * If no IIDEntries have been previously stored, an empty array will be returned. Will not return <code>null</code>.
+ * @return IIDEntry[] of associated IIDEntry instances that have previously been successfully stored via {@link #putAssociate(java.lang.String,IIDEntry,boolean)}.
+ * If no IIDEntries have been previously stored with the given key, an empty array will be returned. Will not return <code>null</code>.
*/
- public IIDEntry[] getAssociateIDEntries();
+ public IIDEntry[] getAssociates(String key);
/**
- * Associate an IIDEntry instance with this IIDEntry in the store. The association is one-way (i.e. if successful, future calls to
- * this{@link #getAssociateIDEntries()} will include the given entry, but calls to entry.getAssociatedIDEntries() will
- * not include this IIDEntry).
+ * Associate an IIDEntry instance with a String key in this IIDEntry. The association is one-way (i.e. if successful, future calls to
+ * this {@link #getAssociates(java.lang.String)} with the same key will include the new entry.
*
- * @param entry the {@link IIDEntry} to associated with this {@link IIDEntry}.
+ * @param key the String key for storing associates. Must not be <code>null</code>..
+ * @param entry the {@link IIDEntry} to associated with this {@link IIDEntry}. Must not be <code>null</code>.
* @param encrypt if <code>true</code> associate IIDEntry will be encrypted, <code>false</code> and it will
* not be encrypted.
* @throws IDStoreException thrown if the given {@link IIDEntry} cannot be stored.
*/
- public void addAssociateIDEntry(IIDEntry entry, boolean encrypt) throws IDStoreException;
+ public void putAssociate(String key, IIDEntry entry, boolean encrypt) throws IDStoreException;
/**
* Delete this IIDEntry from the {@link IIDStore}. This will <b>not</be> delete any associated {@link IIDEntry}s. It is

Back to the top