summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-03-11 10:02:58 (EDT)
committerEike Stepper2007-03-11 10:02:58 (EDT)
commit246a6d17420a69f106f067a2d20e4f5236fc306c (patch)
tree72fd59feeb51954e3b21d3dd11276877ce9007ac
parentcea0aabf741f56cd306f07e9380a2860467d4d29 (diff)
downloadcdo-246a6d17420a69f106f067a2d20e4f5236fc306c.zip
cdo-246a6d17420a69f106f067a2d20e4f5236fc306c.tar.gz
cdo-246a6d17420a69f106f067a2d20e4f5236fc306c.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/AbstractCachingMap.java330
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/AbstractDelegatingMap.java192
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/factory/Factory.java8
3 files changed, 4 insertions, 526 deletions
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/AbstractCachingMap.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/AbstractCachingMap.java
deleted file mode 100644
index df0d490..0000000
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/AbstractCachingMap.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004-2007 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.internal.net4j.util;
-
-import java.util.AbstractMap;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Implementation note: {@link AbstractCachingMap} does not preserve the
- * "modifyable view" contract of {@link Map#entrySet()} as well as of
- * {@link Map#keySet()}, i.e. they are disconnected sets and modifications
- * applied to them are not applied to their underlying
- * {@link AbstractCachingMap}.
- * <p>
- *
- * @author Eike Stepper
- */
-public abstract class AbstractCachingMap<K, V> extends AbstractDelegatingMap<K, V>
-{
- protected AbstractCachingMap()
- {
- }
-
- protected AbstractCachingMap(Map<? extends K, ? extends V> t)
- {
- super(t);
- }
-
- public void clear()
- {
- cachedClear();
- }
-
- public boolean containsKey(Object key)
- {
- return cachedContainsKey(key) || delegatedContainsKey(key);
- }
-
- public boolean containsValue(Object value)
- {
- return cachedContainsValue(value) || cachedContainsValue(value);
- }
-
- public Set<Entry<K, V>> entrySet()
- {
- return mergedEntrySet();
- }
-
- public V get(Object key)
- {
- V result = cachedGet(key);
- if (result == null)
- {
- result = delegatedGet(key);
- }
-
- return result;
- }
-
- public boolean isEmpty()
- {
- return cachedIsEmpty() && delegatedIsEmpty();
- }
-
- public Set<K> keySet()
- {
- return mergedKeySet();
- }
-
- public V put(K key, V value)
- {
- return cachedPut(key, value);
- }
-
- public void putAll(Map<? extends K, ? extends V> t)
- {
- cachedPutAll(t);
- }
-
- public V remove(Object key)
- {
- return cachedRemove(key);
- }
-
- public int size()
- {
- return keySet().size();
- }
-
- public Collection<V> values()
- {
- return mergedValues();
- }
-
- @Override
- public boolean equals(Object obj)
- {
- return mergedEquals(obj);
- }
-
- @Override
- public int hashCode()
- {
- return mergedHashCode();
- }
-
- @Override
- public String toString()
- {
- return mergedToString();
- }
-
- protected void cachedClear()
- {
- getCache().clear();
- }
-
- protected boolean cachedContainsKey(Object key)
- {
- return getCache().containsKey(key);
- }
-
- protected boolean cachedContainsValue(Object value)
- {
- return getCache().containsValue(value);
- }
-
- protected Set<Entry<K, V>> cachedEntrySet()
- {
- return getCache().entrySet();
- }
-
- protected V cachedGet(Object key)
- {
- return getCache().get(key);
- }
-
- protected boolean cachedIsEmpty()
- {
- return getCache().isEmpty();
- }
-
- protected Set<K> cachedKeySet()
- {
- return getCache().keySet();
- }
-
- protected V cachedPut(K key, V value)
- {
- return getCache().put(key, value);
- }
-
- protected void cachedPutAll(Map<? extends K, ? extends V> t)
- {
- getCache().putAll(t);
- }
-
- protected V cachedRemove(Object key)
- {
- return getCache().remove(key);
- }
-
- protected int cachedSize()
- {
- return getCache().size();
- }
-
- protected Collection<V> cachedValues()
- {
- return getCache().values();
- }
-
- protected boolean cachedEquals(Object obj)
- {
- return getCache().equals(obj);
- }
-
- protected int cachedHashCode()
- {
- return getCache().hashCode();
- }
-
- protected String cachedToString()
- {
- return getCache().toString();
- }
-
- protected Set<Entry<K, V>> mergedEntrySet()
- {
- final Map<K, V> delegate = getDelegate();
- final Map<K, V> cache = getCache();
- final Map<K, V> merged = new HashMap(delegate.size() + cache.size());
-
- merged.putAll(delegate);
- merged.putAll(cache);
- return merged.entrySet();
- }
-
- protected Set<K> mergedKeySet()
- {
- final Set<K> delegateKeys = getDelegate().keySet();
- final Set<K> cacheKeys = getCache().keySet();
- final Set<K> merged = new HashSet(delegateKeys.size() + cacheKeys.size());
-
- merged.addAll(delegateKeys);
- merged.addAll(cacheKeys);
- return merged;
- }
-
- protected Collection<V> mergedValues()
- {
- final Set<K> keys = keySet();
- final List<V> result = new ArrayList(keys.size());
- for (K key : keys)
- {
- result.add(get(key));
- }
-
- return result;
- }
-
- /**
- * @see AbstractMap#equals(Object)
- */
- protected boolean mergedEquals(Object o)
- {
- if (o == this)
- return true;
-
- if (!(o instanceof Map))
- return false;
-
- Map<K, V> t = (Map<K, V>)o;
- if (t.size() != size())
- return false;
-
- try
- {
- Iterator<Entry<K, V>> i = entrySet().iterator();
- while (i.hasNext())
- {
- Entry<K, V> e = i.next();
- K key = e.getKey();
- V value = e.getValue();
- if (value == null)
- {
- if (!(t.get(key) == null && t.containsKey(key)))
- return false;
- }
- else
- {
- if (!value.equals(t.get(key)))
- return false;
- }
- }
- }
- catch (ClassCastException unused)
- {
- return false;
- }
- catch (NullPointerException unused)
- {
- return false;
- }
-
- return true;
- }
-
- /**
- * @see AbstractMap#hashCode()
- */
- protected int mergedHashCode()
- {
- int h = 0;
- Iterator<Entry<K, V>> i = entrySet().iterator();
- while (i.hasNext())
- h += i.next().hashCode();
- return h;
- }
-
- /**
- * @see AbstractMap#toString()
- */
- protected String mergedToString()
- {
- StringBuffer buf = new StringBuffer();
- buf.append("{"); //$NON-NLS-1$
-
- Iterator<Entry<K, V>> i = entrySet().iterator();
- boolean hasNext = i.hasNext();
- while (hasNext)
- {
- Entry<K, V> e = i.next();
- K key = e.getKey();
- V value = e.getValue();
- if (key == this)
- buf.append("(this Map)"); //$NON-NLS-1$
- else
- buf.append(key);
- buf.append("="); //$NON-NLS-1$
- if (value == this)
- buf.append("(this Map)"); //$NON-NLS-1$
- else
- buf.append(value);
- hasNext = i.hasNext();
- if (hasNext)
- buf.append(", "); //$NON-NLS-1$
- }
-
- buf.append("}"); //$NON-NLS-1$
- return buf.toString();
- }
-
- protected abstract Map<K, V> getCache();
-}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/AbstractDelegatingMap.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/AbstractDelegatingMap.java
deleted file mode 100644
index 55e3686..0000000
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/AbstractDelegatingMap.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004-2007 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.internal.net4j.util;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Implementation note: {@link AbstractDelegatingMap} does not necessarily
- * preserve the "modifyable view" contract of {@link Map#entrySet()} as well as
- * of {@link Map#keySet()}, i.e. they might be disconnected sets and
- * modifications applied to them might not be applied to their underlying
- * {@link AbstractDelegatingMap}.
- * <p>
- *
- * @author Eike Stepper
- */
-public abstract class AbstractDelegatingMap<K, V> implements Map<K, V>
-{
- protected AbstractDelegatingMap()
- {
- }
-
- protected AbstractDelegatingMap(Map<? extends K, ? extends V> t)
- {
- putAll(t);
- }
-
- public void clear()
- {
- delegatedClear();
- }
-
- public boolean containsKey(Object key)
- {
- return delegatedContainsKey(key);
- }
-
- public boolean containsValue(Object value)
- {
- return delegatedContainsValue(value);
- }
-
- public Set<Entry<K, V>> entrySet()
- {
- return delegatedEntrySet();
- }
-
- public V get(Object key)
- {
- return delegatedGet(key);
- }
-
- public boolean isEmpty()
- {
- return delegatedIsEmpty();
- }
-
- public Set<K> keySet()
- {
- return delegatedKeySet();
- }
-
- public V put(K key, V value)
- {
- return delegatedPut(key, value);
- }
-
- public void putAll(Map<? extends K, ? extends V> t)
- {
- delegatedPutAll(t);
- }
-
- public V remove(Object key)
- {
- return delegatedRemove(key);
- }
-
- public int size()
- {
- return delegatedSize();
- }
-
- public Collection<V> values()
- {
- return delegatedValues();
- }
-
- @Override
- public boolean equals(Object obj)
- {
- return delegatedEquals(obj);
- }
-
- @Override
- public int hashCode()
- {
- return delegatedHashCode();
- }
-
- @Override
- public String toString()
- {
- return delegatedToString();
- }
-
- protected void delegatedClear()
- {
- getDelegate().clear();
- }
-
- protected boolean delegatedContainsKey(Object key)
- {
- return getDelegate().containsKey(key);
- }
-
- protected boolean delegatedContainsValue(Object value)
- {
- return getDelegate().containsValue(value);
- }
-
- protected Set<Entry<K, V>> delegatedEntrySet()
- {
- return getDelegate().entrySet();
- }
-
- protected V delegatedGet(Object key)
- {
- return getDelegate().get(key);
- }
-
- protected boolean delegatedIsEmpty()
- {
- return getDelegate().isEmpty();
- }
-
- protected Set<K> delegatedKeySet()
- {
- return getDelegate().keySet();
- }
-
- protected V delegatedPut(K key, V value)
- {
- return getDelegate().put(key, value);
- }
-
- protected void delegatedPutAll(Map<? extends K, ? extends V> t)
- {
- getDelegate().putAll(t);
- }
-
- protected V delegatedRemove(Object key)
- {
- return getDelegate().remove(key);
- }
-
- protected int delegatedSize()
- {
- return getDelegate().size();
- }
-
- protected Collection<V> delegatedValues()
- {
- return getDelegate().values();
- }
-
- protected boolean delegatedEquals(Object obj)
- {
- return getDelegate().equals(obj);
- }
-
- protected int delegatedHashCode()
- {
- return getDelegate().hashCode();
- }
-
- protected String delegatedToString()
- {
- return getDelegate().toString();
- }
-
- protected abstract Map<K, V> getDelegate();
-}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/factory/Factory.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/factory/Factory.java
index 94b25ba..dac6048 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/factory/Factory.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/factory/Factory.java
@@ -17,19 +17,19 @@ import org.eclipse.net4j.util.factory.IFactory;
*/
public abstract class Factory<PRODUCT> implements IFactory<PRODUCT>
{
- private String productGroupID;
+ private String productGroup;
private String type;
- public Factory(String productGroupID, String type)
+ public Factory(String productGroup, String type)
{
- this.productGroupID = productGroupID;
+ this.productGroup = productGroup;
this.type = type;
}
public String getProductGroup()
{
- return productGroupID;
+ return productGroup;
}
public String getType()