summaryrefslogtreecommitdiff
path: root/ridljar/com/sun/star/lib
diff options
context:
space:
mode:
Diffstat (limited to 'ridljar/com/sun/star/lib')
-rw-r--r--ridljar/com/sun/star/lib/uno/typedesc/TypeDescription.java44
-rw-r--r--ridljar/com/sun/star/lib/util/WeakMap.java76
2 files changed, 66 insertions, 54 deletions
diff --git a/ridljar/com/sun/star/lib/uno/typedesc/TypeDescription.java b/ridljar/com/sun/star/lib/uno/typedesc/TypeDescription.java
index f97666a03e86..f532133299d2 100644
--- a/ridljar/com/sun/star/lib/uno/typedesc/TypeDescription.java
+++ b/ridljar/com/sun/star/lib/uno/typedesc/TypeDescription.java
@@ -55,7 +55,7 @@ public final class TypeDescription implements ITypeDescription {
return get(t);
}
- public static TypeDescription getTypeDescription(Class zClass) {
+ public static TypeDescription getTypeDescription(Class<?> zClass) {
return getDefinitely(new Type(zClass));
}
@@ -206,7 +206,7 @@ public final class TypeDescription implements ITypeDescription {
}
// @see ITypeDescription#getZClass
- public Class getZClass() {
+ public Class<?> getZClass() {
return zClass;
}
@@ -244,7 +244,7 @@ public final class TypeDescription implements ITypeDescription {
{
TypeClass typeClass = type.getTypeClass();
String typeName = type.getTypeName();
- Class zClass = type.getZClass();
+ Class<?> zClass = type.getZClass();
if (zClass == null) {
throw new ClassNotFoundException("UNO type " + type);
}
@@ -322,7 +322,7 @@ public final class TypeDescription implements ITypeDescription {
{
// This code exploits the fact that an instantiated polymorphic
// struct type may not be the direct base of a struct type:
- Class superClass = zClass.getSuperclass();
+ Class<?> superClass = zClass.getSuperclass();
TypeDescription[] superTypes = superClass != Object.class
? new TypeDescription[] { get(new Type(superClass)) }
: null;
@@ -349,7 +349,7 @@ public final class TypeDescription implements ITypeDescription {
case TypeClass.INTERFACE_value:
{
List superTypes = new List();
- Class[] interfaces = zClass.getInterfaces();
+ Class<?>[] interfaces = zClass.getInterfaces();
for (int i = 0; i < interfaces.length; ++i) {
Type t = new Type(interfaces[i]);
if (t.getTypeClass() == TypeClass.INTERFACE) {
@@ -374,7 +374,7 @@ public final class TypeDescription implements ITypeDescription {
private TypeDescription(
TypeClass typeClass, String typeName, String arrayTypeName,
- Class zClass, TypeDescription[] superTypes,
+ Class<?> zClass, TypeDescription[] superTypes,
ITypeDescription componentType)
{
this.typeClass = typeClass;
@@ -414,16 +414,16 @@ public final class TypeDescription implements ITypeDescription {
getDefinitely(Type.VOID), null) };
} else {
int methodOffset = 0;
- ArrayList superList = new ArrayList();
+ ArrayList<MethodDescription> superList = new ArrayList<MethodDescription>();
for (int i = 0; i < superTypes.length; ++i) {
IMethodDescription[] ds = superTypes[i].getMethodDescriptions();
for (int j = 0; j < ds.length; ++j) {
superList.add(new MethodDescription(ds[j], methodOffset++));
}
}
- superMethodDescriptions = (IMethodDescription[]) superList.toArray(
+ superMethodDescriptions = superList.toArray(
new IMethodDescription[superList.size()]);
- ArrayList directList = new ArrayList();
+ ArrayList<MethodDescription> directList = new ArrayList<MethodDescription>();
TypeInfo[] infos = getTypeInfo();
int infoCount = infos == null ? 0 : infos.length;
int index = 0;
@@ -465,7 +465,7 @@ public final class TypeDescription implements ITypeDescription {
+ ": entries not ordererd");
}
Method method = findMethod(methods, info.getName());
- Class[] params = method.getParameterTypes();
+ Class<?>[] params = method.getParameterTypes();
ITypeDescription[] in = new ITypeDescription[params.length];
ITypeDescription[] out
= new ITypeDescription[params.length];
@@ -499,7 +499,7 @@ public final class TypeDescription implements ITypeDescription {
method));
}
}
- methodDescriptions = (IMethodDescription[]) directList.toArray(
+ methodDescriptions = directList.toArray(
new IMethodDescription[directList.size()]);
}
}
@@ -512,7 +512,7 @@ public final class TypeDescription implements ITypeDescription {
if (i < 0) {
return null;
}
- java.util.List args = new java.util.ArrayList();
+ java.util.List<TypeDescription> args = new java.util.ArrayList<TypeDescription>();
do {
++i; // skip '<' or ','
int j = i;
@@ -555,7 +555,7 @@ public final class TypeDescription implements ITypeDescription {
throw new IllegalArgumentException(
"UNO type name \"" + typeName + "\" is syntactically invalid");
}
- return (TypeDescription[]) args.toArray(
+ return args.toArray(
new TypeDescription[args.size()]);
}
@@ -626,7 +626,7 @@ public final class TypeDescription implements ITypeDescription {
}
private static ITypeDescription getTypeDescription(
- Class zClass, TypeInfo typeInfo)
+ Class<?> zClass, TypeInfo typeInfo)
{
return getDefinitely(
new Type(
@@ -649,11 +649,11 @@ public final class TypeDescription implements ITypeDescription {
}
public TypeDescription[] toArray() {
- return (TypeDescription[]) list.toArray(
+ return list.toArray(
new TypeDescription[list.size()]);
}
- private final ArrayList list = new ArrayList();
+ private final ArrayList<TypeDescription> list = new ArrayList<TypeDescription>();
}
private static final class Cache {
@@ -662,7 +662,7 @@ public final class TypeDescription implements ITypeDescription {
public TypeDescription get(String typeName) {
synchronized (map) {
cleanUp();
- Entry e = (Entry) map.get(typeName);
+ Entry e = map.get(typeName);
return e == null ? null : (TypeDescription) e.get();
}
}
@@ -684,8 +684,8 @@ public final class TypeDescription implements ITypeDescription {
}
}
- private static final class Entry extends SoftReference {
- public Entry(TypeDescription desc, ReferenceQueue queue) {
+ private static final class Entry extends SoftReference<TypeDescription> {
+ public Entry(TypeDescription desc, ReferenceQueue<TypeDescription> queue) {
super(desc, queue);
typeName = desc.getTypeName();
}
@@ -693,8 +693,8 @@ public final class TypeDescription implements ITypeDescription {
public final String typeName;
}
- private final HashMap map = new HashMap();
- private final ReferenceQueue queue = new ReferenceQueue();
+ private final HashMap<String, Entry> map = new HashMap<String, Entry>();
+ private final ReferenceQueue<TypeDescription> queue = new ReferenceQueue<TypeDescription>();
}
private static final Cache cache = new Cache();
@@ -702,7 +702,7 @@ public final class TypeDescription implements ITypeDescription {
private final TypeClass typeClass;
private final String typeName;
private final String arrayTypeName;
- private final Class zClass;
+ private final Class<?> zClass;
private final TypeDescription[] superTypes;
private final ITypeDescription componentType;
private final boolean hasTypeArguments;
diff --git a/ridljar/com/sun/star/lib/util/WeakMap.java b/ridljar/com/sun/star/lib/util/WeakMap.java
index a8b72233cfb3..c9ed21d159de 100644
--- a/ridljar/com/sun/star/lib/util/WeakMap.java
+++ b/ridljar/com/sun/star/lib/util/WeakMap.java
@@ -58,7 +58,15 @@ import java.util.Set;
* <code>WeakReference</code> wrappers are automatically cleared as soon as the
* values are disposed.</p>
*/
-public final class WeakMap implements Map {
+public final class WeakMap<K,V> {
+
+ /**
+ * Declare the map as WeakReference instead of Entry because it makes the return
+ * type signatures of values() and keySet() cleaner.
+ */
+ private final HashMap<K, WeakReference<V>> map = new HashMap<K, WeakReference<V>>();
+ private final ReferenceQueue<V> queue = new ReferenceQueue<V>();
+
/**
* Constructs an empty <code>WeakMap</code>.
*/
@@ -70,7 +78,7 @@ public final class WeakMap implements Map {
*
* @param m the map whose mappings are to be placed in this map
*/
- public WeakMap(Map m) {
+ public WeakMap(Map<K,V> m) {
putAll(m);
}
@@ -108,7 +116,7 @@ public final class WeakMap implements Map {
* @return <code>true</code> if this map contains a mapping for the
* specified key
*/
- public boolean containsKey(Object key) {
+ public boolean containsKey(K key) {
return map.containsKey(key);
}
@@ -122,7 +130,7 @@ public final class WeakMap implements Map {
* @return <code>true</code> if this map maps one or more keys to the
* specified value
*/
- public boolean containsValue(Object value) {
+ public boolean containsValue(WeakReference<V> value) {
return map.containsValue(value);
}
@@ -137,7 +145,7 @@ public final class WeakMap implements Map {
* @return the value to which this map maps the specified key, or
* <code>null</code> if the map contains no mapping for this key
*/
- public Object get(Object key) {
+ public WeakReference<V> get(K key) {
return map.get(key);
}
@@ -153,9 +161,9 @@ public final class WeakMap implements Map {
* @return previous value associated with the specified key, or
* <code>null</code> if there was no mapping for the key
*/
- public Object put(Object key, Object value) {
+ public WeakReference<V> put(K key, V value) {
cleanUp();
- return map.put(key, new Entry(key, value, queue));
+ return map.put(key, new Entry<K,V>(key, value, queue));
}
/**
@@ -167,7 +175,7 @@ public final class WeakMap implements Map {
* @return previous value associated with the specified key, or
* <code>null</code> if there was no mapping for the key
*/
- public Object remove(Object key) {
+ public WeakReference<V> remove(K key) {
cleanUp();
return map.remove(key);
}
@@ -181,12 +189,12 @@ public final class WeakMap implements Map {
* must be plain objects, which are then wrapped in instances of
* <code>WeakReference</code>.
*/
- public void putAll(Map t) {
+ public void putAll(Map<K,V> m) {
cleanUp();
- for (Iterator i = t.entrySet().iterator(); i.hasNext();) {
- Map.Entry e = (Map.Entry) i.next();
- Object k = e.getKey();
- map.put(k, new Entry(k, e.getValue(), queue));
+ for (Iterator<Map.Entry<K,V>> i = m.entrySet().iterator(); i.hasNext();) {
+ Map.Entry<K,V> e = i.next();
+ K k = e.getKey();
+ map.put(k, new Entry<K,V>(k, e.getValue(), queue));
}
}
@@ -207,7 +215,7 @@ public final class WeakMap implements Map {
*
* @return a set view of the keys contained in this map
*/
- public Set keySet() {
+ public Set<K> keySet() {
return map.keySet();
}
@@ -218,7 +226,7 @@ public final class WeakMap implements Map {
*
* @return a collection view of the values contained in this map
*/
- public Collection values() {
+ public Collection<WeakReference<V>> values() {
return map.values();
}
@@ -229,7 +237,7 @@ public final class WeakMap implements Map {
*
* @return a collection view of the mappings contained in this map
*/
- public Set entrySet() {
+ public Set<Map.Entry<K,WeakReference<V>>> entrySet() {
return map.entrySet();
}
@@ -253,17 +261,20 @@ public final class WeakMap implements Map {
* @return the referent of the specified <code>WeakReference</code>, or
* <code>null</code> if <code>ref</code> is <code>null</code>
*/
- public static Object getValue(Object ref) {
- return ref == null ? null : ((WeakReference) ref).get();
+ public static <T> T getValue(WeakReference<T> ref) {
+ return ref == null ? null : ref.get();
}
- // cleanUp must only be called from within modifying methods. Otherwise,
- // the implementations of entrySet, keySet and values would break
- // (specificially, iterating over the collections returned by those
- // methods), as non-modifying methods might modify the underlying map.
+ /**
+ * cleanUp() must only be called from within modifying methods. Otherwise,
+ * the implementations of entrySet, keySet and values would break
+ * (Specifically, iterating over the collections returned by those
+ * methods), as non-modifying methods might modify the underlying map.
+ **/
+ @SuppressWarnings("unchecked")
private void cleanUp() {
for (;;) {
- Entry e = (Entry) queue.poll();
+ Entry<K,V> e = (Entry<K,V>) queue.poll();
if (e == null) {
break;
}
@@ -278,15 +289,12 @@ public final class WeakMap implements Map {
}
}
- private static final class Entry extends WeakReference
+ private static final class Entry<K,V> extends WeakReference<V>
implements DisposeListener
{
- public void notifyDispose(DisposeNotifier source) {
- Entry.this.clear(); // qualification needed for Java 1.3
- enqueue();
- }
+ private final K key;
- private Entry(Object key, Object value, ReferenceQueue queue) {
+ private Entry(K key, V value, ReferenceQueue<V> queue) {
super(value, queue);
this.key = key;
if (value instanceof DisposeNotifier) {
@@ -294,9 +302,13 @@ public final class WeakMap implements Map {
}
}
- private final Object key;
+ /**
+ * @see DisposeListener#notifyDispose(DisposeNotifier)
+ */
+ public void notifyDispose(DisposeNotifier source) {
+ clear();
+ enqueue();
+ }
}
- private final HashMap map = new HashMap();
- private final ReferenceQueue queue = new ReferenceQueue();
}