diff options
author | Noel Grandin <noel@peralex.com> | 2012-06-29 10:08:15 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-06-29 22:03:05 +0200 |
commit | f9fa0dd66b830ff21c4a2dcd201151a4e9ca2de8 (patch) | |
tree | 1c1a421028cbef391af4f2886eac2677f75c5ee7 /javaunohelper/com/sun/star | |
parent | Java5 update - convert to use generics (diff) | |
download | core-f9fa0dd66b830ff21c4a2dcd201151a4e9ca2de8.tar.gz core-f9fa0dd66b830ff21c4a2dcd201151a4e9ca2de8.zip |
Java5 updates - update code to use generics
This is all of the code I missed in my first set of patches.
Change-Id: I8c7c9e5ac28dc3c2f3ac062c806fbf0787c997bd
Diffstat (limited to 'javaunohelper/com/sun/star')
9 files changed, 126 insertions, 128 deletions
diff --git a/javaunohelper/com/sun/star/comp/helper/Bootstrap.java b/javaunohelper/com/sun/star/comp/helper/Bootstrap.java index 30eb200bd0ce..d5fda64c035e 100644 --- a/javaunohelper/com/sun/star/comp/helper/Bootstrap.java +++ b/javaunohelper/com/sun/star/comp/helper/Bootstrap.java @@ -36,8 +36,9 @@ import java.io.File; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; -import java.util.Enumeration; -import java.util.Hashtable; +import java.util.Iterator; +import java.util.Map; +import java.util.HashMap; import java.util.Random; /** Bootstrap offers functionality to obtain a context or simply @@ -93,7 +94,7 @@ public class Bootstrap { context entries (type class ComponentContextEntry). @return a new context. */ - static public XComponentContext createInitialComponentContext( Hashtable context_entries ) + static public XComponentContext createInitialComponentContext( Map<String,Object> context_entries ) throws Exception { XImplementationLoader xImpLoader = UnoRuntime.queryInterface( @@ -116,7 +117,7 @@ public class Bootstrap { // initial component context if (context_entries == null) - context_entries = new Hashtable( 1 ); + context_entries = new HashMap<String,Object>( 1 ); // add smgr context_entries.put( "/singletons/com.sun.star.lang.theServiceManager", @@ -171,7 +172,7 @@ public class Bootstrap { @see "cppuhelper/defaultBootstrap_InitialComponentContext()" */ static public final XComponentContext defaultBootstrap_InitialComponentContext( - String ini_file, Hashtable bootstrap_parameters ) + String ini_file, Map<String,String> bootstrap_parameters ) throws Exception { // jni convenience: easier to iterate over array than calling Hashtable @@ -179,13 +180,13 @@ public class Bootstrap { if (null != bootstrap_parameters) { pairs = new String [ 2 * bootstrap_parameters.size() ]; - Enumeration keys = bootstrap_parameters.keys(); + Iterator<String> keys = bootstrap_parameters.keySet().iterator(); int n = 0; - while (keys.hasMoreElements()) + while (keys.hasNext()) { - String name = (String)keys.nextElement(); + String name = keys.next(); pairs[ n++ ] = name; - pairs[ n++ ] = (String)bootstrap_parameters.get( name ); + pairs[ n++ ] = bootstrap_parameters.get( name ); } } diff --git a/javaunohelper/com/sun/star/comp/helper/ComponentContext.java b/javaunohelper/com/sun/star/comp/helper/ComponentContext.java index 868f1c723c41..0f08c548b8e7 100644 --- a/javaunohelper/com/sun/star/comp/helper/ComponentContext.java +++ b/javaunohelper/com/sun/star/comp/helper/ComponentContext.java @@ -27,9 +27,10 @@ import com.sun.star.lang.XComponent; import com.sun.star.lang.XEventListener; import com.sun.star.lang.EventObject; -import java.util.Hashtable; -import java.util.Enumeration; -import java.util.Vector; +import java.util.HashMap; +import java.util.Map; +import java.util.Iterator; +import java.util.ArrayList; //================================================================================================== @@ -57,13 +58,13 @@ public class ComponentContext implements XComponentContext, XComponent private static final String SMGR_NAME = "/singletons/com.sun.star.lang.theServiceManager"; private static final String TDMGR_NAME = "/singletons/com.sun.star.reflection.theTypeDescriptionManager"; - private Hashtable m_table; + private Map<String,Object> m_table; private XComponentContext m_xDelegate; private XMultiComponentFactory m_xSMgr; private boolean m_bDisposeSMgr; - private Vector m_eventListener; + private ArrayList<XEventListener> m_eventListener; /** Ctor to create a component context passing a hashtable for values and a delegator reference. Entries of the passed hashtable are either direct values or @@ -74,9 +75,9 @@ public class ComponentContext implements XComponentContext, XComponent @param xDelegate if values are not found, request is delegated to this object */ - public ComponentContext( Hashtable table, XComponentContext xDelegate ) + public ComponentContext( Map<String,Object> table, XComponentContext xDelegate ) { - m_eventListener = new Vector(); + m_eventListener = new ArrayList<XEventListener>(); m_table = table; m_xDelegate = xDelegate; m_xSMgr = null; @@ -219,20 +220,20 @@ public class ComponentContext implements XComponentContext, XComponent // fire events EventObject evt = new EventObject( this ); - Enumeration eventListener = m_eventListener.elements(); - while (eventListener.hasMoreElements()) + Iterator<XEventListener> eventListener = m_eventListener.iterator(); + while (eventListener.hasNext()) { - XEventListener listener = (XEventListener)eventListener.nextElement(); + XEventListener listener = eventListener.next(); listener.disposing( evt ); } - m_eventListener.removeAllElements(); + m_eventListener.clear(); XComponent tdmgr = null; // dispose values, then service manager, then typdescription manager - Enumeration keys = m_table.keys(); - while (keys.hasMoreElements()) + Iterator<String> keys = m_table.keySet().iterator(); + while (keys.hasNext()) { - String name = (String)keys.nextElement(); + String name = keys.next(); if (! name.equals( SMGR_NAME )) { Object o = m_table.get( name ); @@ -286,7 +287,7 @@ public class ComponentContext implements XComponentContext, XComponent if (m_eventListener.contains( xListener )) throw new com.sun.star.uno.RuntimeException( "Listener already registred." ); - m_eventListener.addElement( xListener ); + m_eventListener.add( xListener ); } //______________________________________________________________________________________________ public void removeEventListener( XEventListener xListener ) @@ -296,6 +297,6 @@ public class ComponentContext implements XComponentContext, XComponent if (! m_eventListener.contains( xListener )) throw new com.sun.star.uno.RuntimeException( "Listener is not registered." ); - m_eventListener.removeElement( xListener ); + m_eventListener.remove( xListener ); } } diff --git a/javaunohelper/com/sun/star/lib/uno/helper/Factory.java b/javaunohelper/com/sun/star/lib/uno/helper/Factory.java index fa189f49610f..586498cde844 100644 --- a/javaunohelper/com/sun/star/lib/uno/helper/Factory.java +++ b/javaunohelper/com/sun/star/lib/uno/helper/Factory.java @@ -118,7 +118,7 @@ public class Factory //============================================================================================== private String m_impl_name; private String [] m_supported_services; - private Class m_impl_class; + private Class<?> m_impl_class; private java.lang.reflect.Method m_method; private java.lang.reflect.Constructor m_ctor; diff --git a/javaunohelper/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer.java b/javaunohelper/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer.java index 443a2418eb49..6ebc687bb4b8 100644 --- a/javaunohelper/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer.java +++ b/javaunohelper/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer.java @@ -26,7 +26,7 @@ import java.util.Iterator; public class MultiTypeInterfaceContainer { - private Map map= new HashMap(); + private Map<Object,InterfaceContainer> map= new HashMap<Object,InterfaceContainer>(); /** Creates a new instance of MultiTypeInterfaceContainer */ public MultiTypeInterfaceContainer() @@ -45,13 +45,13 @@ public class MultiTypeInterfaceContainer if ( (size=map.size()) > 0) { Type [] arTypes= new Type[size]; - Iterator it= map.keySet().iterator(); + Iterator<Object> it= map.keySet().iterator(); int countTypes= 0; while (it.hasNext()) { Object key= it.next(); - InterfaceContainer cont= (InterfaceContainer) map.get(key); + InterfaceContainer cont= map.get(key); if (cont != null && cont.size() > 0) { if (key == null) @@ -82,18 +82,18 @@ public class MultiTypeInterfaceContainer synchronized public InterfaceContainer getContainer(Object key) { InterfaceContainer retVal= null; - Iterator it= map.keySet().iterator(); + Iterator<Object> it= map.keySet().iterator(); while (it.hasNext()) { Object obj= it.next(); if (obj == null && key == null) { - retVal= (InterfaceContainer) map.get(null); + retVal= map.get(null); break; } else if( obj != null && obj.equals(key)) { - retVal= (InterfaceContainer) map.get(obj); + retVal= map.get(obj); break; } } @@ -109,7 +109,7 @@ public class MultiTypeInterfaceContainer // Type a= new Type(XInterface.class); // Type b= new Type(XInterface.class); // Allthough a != b , the map interprets both as being the same. - InterfaceContainer cont= (InterfaceContainer) map.get(ckey); + InterfaceContainer cont= map.get(ckey); if (cont != null) { cont.add(iface); @@ -127,7 +127,7 @@ public class MultiTypeInterfaceContainer synchronized public int removeInterface(Object key, Object iface) { int retVal= 0; - InterfaceContainer cont= (InterfaceContainer) map.get(key); + InterfaceContainer cont= map.get(key); if (cont != null) { cont.remove(iface); @@ -138,19 +138,19 @@ public class MultiTypeInterfaceContainer public void disposeAndClear(EventObject evt) { - Iterator it= null; + Iterator<InterfaceContainer> it= null; synchronized(this) { it= map.values().iterator(); } while (it.hasNext() ) - ((InterfaceContainer) it.next()).disposeAndClear(evt); + it.next().disposeAndClear(evt); } synchronized public void clear() { - Iterator it= map.values().iterator(); + Iterator<InterfaceContainer> it= map.values().iterator(); while (it.hasNext()) - ((InterfaceContainer) it.next()).clear(); + it.next().clear(); } } diff --git a/javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java b/javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java index 99227a6d06ba..b2571813f34e 100644 --- a/javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java +++ b/javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java @@ -76,9 +76,9 @@ import com.sun.star.lang.DisposedException; public class PropertySet extends ComponentBase implements XPropertySet, XFastPropertySet, XMultiPropertySet { - private HashMap _nameToPropertyMap; - private HashMap _handleToPropertyMap; - private HashMap _propertyToIdMap; + private HashMap<String,Property> _nameToPropertyMap; + private HashMap<Integer,Property> _handleToPropertyMap; + private HashMap<Property,Object> _propertyToIdMap; private Property[] arProperties; private int lastHandle= 1; @@ -205,7 +205,7 @@ XMultiPropertySet */ protected Property getProperty(String propertyName) { - return (Property) _nameToPropertyMap.get(propertyName); + return _nameToPropertyMap.get(propertyName); } /** Returns the Property object with a handle (Property.Handle) as specified by the argument @@ -217,7 +217,7 @@ XMultiPropertySet */ protected Property getPropertyByHandle(int nHandle) { - return (Property) _handleToPropertyMap.get(new Integer(nHandle)); + return _handleToPropertyMap.get(new Integer(nHandle)); } /** Returns an array of all Property objects or an array of length null if there @@ -230,8 +230,8 @@ XMultiPropertySet { if (arProperties == null) { - Collection values= _nameToPropertyMap.values(); - arProperties= (Property[]) values.toArray(new Property[_nameToPropertyMap.size()]); + Collection<Property> values= _nameToPropertyMap.values(); + arProperties= values.toArray(new Property[_nameToPropertyMap.size()]); } return arProperties; } @@ -290,9 +290,9 @@ XMultiPropertySet */ protected void initMappings() { - _nameToPropertyMap= new HashMap(); - _handleToPropertyMap= new HashMap(); - _propertyToIdMap= new HashMap(); + _nameToPropertyMap= new HashMap<String,Property>(); + _handleToPropertyMap= new HashMap<Integer,Property>(); + _propertyToIdMap= new HashMap<Property,Object>(); } /** Makes sure that listeners which are kept in aBoundLC (XPropertyChangeListener) and aVetoableLC diff --git a/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java b/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java index 26aaa8cdb0fe..950840cb0d1c 100644 --- a/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java +++ b/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java @@ -144,12 +144,11 @@ public final class PropertySetMixin { "unexpected com.sun.star.container.NoSuchElementException: " + e.getMessage()); } - HashMap map = new HashMap(); - ArrayList handleNames = new ArrayList(); - initProperties(ifc, map, handleNames, new HashSet()); + HashMap<String,PropertyData> map = new HashMap<String,PropertyData>(); + ArrayList<String> handleNames = new ArrayList<String>(); + initProperties(ifc, map, handleNames, new HashSet<String>()); properties = map; - handleMap = (String[]) handleNames.toArray( - new String[handleNames.size()]); + handleMap = handleNames.toArray(new String[handleNames.size()]); } /** @@ -202,38 +201,39 @@ public final class PropertySetMixin { {@link BoundListeners#notifyListeners} has not yet been called); may only be null if the attribute that is going to be set is not bound */ + @SuppressWarnings("unchecked") public void prepareSet( String propertyName, Object oldValue, Object newValue, BoundListeners bound) throws PropertyVetoException { // assert properties.get(propertyName) != null; - Property p = ((PropertyData) properties.get(propertyName)).property; - Vector specificVeto = null; - Vector unspecificVeto = null; + Property p = properties.get(propertyName).property; + ArrayList<XVetoableChangeListener> specificVeto = null; + ArrayList<XVetoableChangeListener> unspecificVeto = null; synchronized (this) { if (disposed) { throw new DisposedException("disposed", object); } if ((p.Attributes & PropertyAttribute.CONSTRAINED) != 0) { - Object o = vetoListeners.get(propertyName); + ArrayList<XVetoableChangeListener> o = vetoListeners.get(propertyName); if (o != null) { - specificVeto = (Vector) ((Vector) o).clone(); + specificVeto = (ArrayList<XVetoableChangeListener>) o.clone(); } o = vetoListeners.get(""); if (o != null) { - unspecificVeto = (Vector) ((Vector) o).clone(); + unspecificVeto = (ArrayList<XVetoableChangeListener>) o.clone(); } } if ((p.Attributes & PropertyAttribute.BOUND) != 0) { // assert bound != null; - Object o = boundListeners.get(propertyName); + ArrayList<XPropertyChangeListener> o = boundListeners.get(propertyName); if (o != null) { - bound.specificListeners = (Vector) ((Vector) o).clone(); + bound.specificListeners = (ArrayList<XPropertyChangeListener>) o.clone(); } o = boundListeners.get(""); if (o != null) { - bound.unspecificListeners = (Vector) ((Vector) o).clone(); + bound.unspecificListeners = (ArrayList<XPropertyChangeListener>) o.clone(); } } } @@ -241,18 +241,16 @@ public final class PropertySetMixin { PropertyChangeEvent event = new PropertyChangeEvent( object, propertyName, false, p.Handle, oldValue, newValue); if (specificVeto != null) { - for (Iterator i = specificVeto.iterator(); i.hasNext();) { + for (Iterator<XVetoableChangeListener> i = specificVeto.iterator(); i.hasNext();) { try { - ((XVetoableChangeListener) i.next()).vetoableChange( - event); + i.next().vetoableChange(event); } catch (DisposedException e) {} } } if (unspecificVeto != null) { - for (Iterator i = unspecificVeto.iterator(); i.hasNext();) { + for (Iterator<XVetoableChangeListener> i = unspecificVeto.iterator(); i.hasNext();) { try { - ((XVetoableChangeListener) i.next()).vetoableChange( - event); + i.next().vetoableChange(event); } catch (DisposedException e) {} } } @@ -298,8 +296,8 @@ public final class PropertySetMixin { ignored.</p> */ public void dispose() { - HashMap bound; - HashMap veto; + HashMap<String,ArrayList<XPropertyChangeListener>> bound; + HashMap<String,ArrayList<XVetoableChangeListener>> veto; synchronized (this) { bound = boundListeners; boundListeners = null; @@ -309,18 +307,18 @@ public final class PropertySetMixin { } EventObject event = new EventObject(object); if (bound != null) { - for (Iterator i = bound.values().iterator(); i.hasNext();) { - for (Iterator j = ((Vector) i.next()).iterator(); j.hasNext();) + for (Iterator<ArrayList<XPropertyChangeListener>> i = bound.values().iterator(); i.hasNext();) { + for (Iterator<XPropertyChangeListener> j = i.next().iterator(); j.hasNext();) { - ((XPropertyChangeListener) j.next()).disposing(event); + j.next().disposing(event); } } } if (veto != null) { - for (Iterator i = veto.values().iterator(); i.hasNext();) { - for (Iterator j = ((Vector) i.next()).iterator(); j.hasNext();) + for (Iterator<ArrayList<XVetoableChangeListener>> i = veto.values().iterator(); i.hasNext();) { + for (Iterator<XVetoableChangeListener> j = i.next().iterator(); j.hasNext();) { - ((XVetoableChangeListener) j.next()).disposing(event); + j.next().disposing(event); } } } @@ -370,9 +368,9 @@ public final class PropertySetMixin { synchronized (this) { disp = disposed; if (!disp) { - Vector v = (Vector) boundListeners.get(propertyName); + ArrayList<XPropertyChangeListener> v = boundListeners.get(propertyName); if (v == null) { - v = new Vector(); + v = new ArrayList<XPropertyChangeListener>(); boundListeners.put(propertyName, v); } v.add(listener); @@ -395,7 +393,7 @@ public final class PropertySetMixin { checkUnknown(propertyName); synchronized (this) { if (boundListeners != null) { - Vector v = (Vector) boundListeners.get(propertyName); + ArrayList<XPropertyChangeListener> v = boundListeners.get(propertyName); if (v != null) { v.remove(listener); } @@ -420,9 +418,9 @@ public final class PropertySetMixin { synchronized (this) { disp = disposed; if (!disp) { - Vector v = (Vector) vetoListeners.get(propertyName); + ArrayList<XVetoableChangeListener> v = vetoListeners.get(propertyName); if (v == null) { - v = new Vector(); + v = new ArrayList<XVetoableChangeListener>(); vetoListeners.put(propertyName, v); } v.add(listener); @@ -445,7 +443,7 @@ public final class PropertySetMixin { checkUnknown(propertyName); synchronized (this) { if (vetoListeners != null) { - Vector v = (Vector) vetoListeners.get(propertyName); + ArrayList<XVetoableChangeListener> v = vetoListeners.get(propertyName); if (v != null) { v.remove(listener); } @@ -547,26 +545,24 @@ public final class PropertySetMixin { */ public void notifyListeners() { if (specificListeners != null) { - for (Iterator i = specificListeners.iterator(); i.hasNext();) { + for (Iterator<XPropertyChangeListener> i = specificListeners.iterator(); i.hasNext();) { try { - ((XPropertyChangeListener) i.next()).propertyChange( - event); + i.next().propertyChange(event); } catch (DisposedException e) {} } } if (unspecificListeners != null) { - for (Iterator i = unspecificListeners.iterator(); i.hasNext();) + for (Iterator<XPropertyChangeListener> i = unspecificListeners.iterator(); i.hasNext();) { try { - ((XPropertyChangeListener) i.next()).propertyChange( - event); + i.next().propertyChange(event); } catch (DisposedException e) {} } } } - private Vector specificListeners = null; - private Vector unspecificListeners = null; + private ArrayList<XPropertyChangeListener> specificListeners = null; + private ArrayList<XPropertyChangeListener> unspecificListeners = null; private PropertyChangeEvent event = null; } @@ -595,7 +591,7 @@ public final class PropertySetMixin { } private void initProperties( - XTypeDescription type, HashMap map, ArrayList handleNames, HashSet seen) + XTypeDescription type, HashMap<String,PropertyData> map, ArrayList<String> handleNames, HashSet<String> seen) { XInterfaceTypeDescription2 ifc = UnoRuntime.queryInterface( XInterfaceTypeDescription2.class, resolveTypedefs(type)); @@ -1039,19 +1035,19 @@ public final class PropertySetMixin { private final class Info extends WeakBase implements XPropertySetInfo { - public Info(Map properties) { + public Info(Map<String,PropertyData> properties) { this.properties = properties; } public Property[] getProperties() { - ArrayList al = new ArrayList(properties.size()); - for (Iterator i = properties.values().iterator(); i.hasNext();) { - PropertyData p = (PropertyData) i.next(); + ArrayList<Property> al = new ArrayList<Property>(properties.size()); + for (Iterator<PropertyData> i = properties.values().iterator(); i.hasNext();) { + PropertyData p = i.next(); if (p.present) { al.add(p.property); } } - return (Property[]) al.toArray(new Property[al.size()]); + return al.toArray(new Property[al.size()]); } public Property getPropertyByName(String name) @@ -1065,7 +1061,7 @@ public final class PropertySetMixin { return p != null && p.present; } - private final Map properties; // from String to Property + private final Map<String,PropertyData> properties; } private final XComponentContext context; @@ -1073,12 +1069,14 @@ public final class PropertySetMixin { private final Type type; private final String[] absentOptional; private final XIdlClass idlClass; - private final Map properties; // from String to Property + private final Map<String,PropertyData> properties; // from String to Property private final String[] handleMap; - private HashMap boundListeners = new HashMap(); + private HashMap<String,ArrayList<XPropertyChangeListener>> boundListeners + = new HashMap<String,ArrayList<XPropertyChangeListener>>(); // from String to Vector of XPropertyChangeListener - private HashMap vetoListeners = new HashMap(); + private HashMap<String,ArrayList<XVetoableChangeListener>> vetoListeners + = new HashMap<String,ArrayList<XVetoableChangeListener>>(); // from String to Vector of XVetoableChangeListener private boolean disposed = false; } diff --git a/javaunohelper/com/sun/star/lib/uno/helper/UnoUrl.java b/javaunohelper/com/sun/star/lib/uno/helper/UnoUrl.java index 4205fb1091f8..844d9e30f579 100644 --- a/javaunohelper/com/sun/star/lib/uno/helper/UnoUrl.java +++ b/javaunohelper/com/sun/star/lib/uno/helper/UnoUrl.java @@ -19,7 +19,7 @@ package com.sun.star.lib.uno.helper; import java.io.UnsupportedEncodingException; import java.util.HashMap; -import java.util.Vector; +import java.util.ArrayList; /** * Object representation and parsing of Uno Urls, @@ -66,13 +66,13 @@ public class UnoUrl { static private class UnoUrlPart { private String partTypeName; - private HashMap partParameters; + private HashMap<String,String> partParameters; private String uninterpretedParameterString; public UnoUrlPart( String uninterpretedParameterString, String partTypeName, - HashMap partParameters) { + HashMap<String,String> partParameters) { this.uninterpretedParameterString = uninterpretedParameterString; this.partTypeName = partTypeName; this.partParameters = partParameters; @@ -82,7 +82,7 @@ public class UnoUrl { return partTypeName; } - public HashMap getPartParameters() { + public HashMap<String,String> getPartParameters() { return partParameters; } @@ -146,7 +146,7 @@ public class UnoUrl { * * @return a HashMap with key/value pairs for protocol parameters. */ - public HashMap getProtocolParameters() { + public HashMap<String,String> getProtocolParameters() { return protocol.getPartParameters(); } @@ -157,7 +157,7 @@ public class UnoUrl { * * @return a HashMap with key/value pairs for connection parameters. */ - public HashMap getConnectionParameters() { + public HashMap<String,String> getConnectionParameters() { return connection.getPartParameters(); } @@ -220,7 +220,7 @@ public class UnoUrl { private static String decodeUTF8(String s) throws com.sun.star.lang.IllegalArgumentException { - Vector v = new Vector(); + ArrayList<Integer> v = new ArrayList<Integer>(); for (int i = 0; i < s.length(); i++) { int ch = s.charAt(i); @@ -231,13 +231,13 @@ public class UnoUrl { ch = (hb << 4) | lb; } - v.addElement(new Integer(ch)); + v.add(new Integer(ch)); } int size = v.size(); byte[] bytes = new byte[size]; for (int i = 0; i < size; i++) { - Integer anInt = (Integer) v.elementAt(i); + Integer anInt = v.get(i); bytes[i] = (byte) (anInt.intValue() & 0xFF); } @@ -249,9 +249,9 @@ public class UnoUrl { } } - private static HashMap buildParamHashMap(String paramString) + private static HashMap<String,String> buildParamHashMap(String paramString) throws com.sun.star.lang.IllegalArgumentException { - HashMap params = new HashMap(); + HashMap<String,String> params = new HashMap<String,String>(); int pos = 0; @@ -313,7 +313,7 @@ public class UnoUrl { + "' may only consist of alpha numeric ASCII characters."); } - HashMap params = buildParamHashMap(theParamPart); + HashMap<String,String> params = buildParamHashMap(theParamPart); return new UnoUrlPart(theParamPart, partName, params); } diff --git a/javaunohelper/com/sun/star/lib/uno/helper/WeakAdapter.java b/javaunohelper/com/sun/star/lib/uno/helper/WeakAdapter.java index 2df7820a5943..46ba04d368cb 100644 --- a/javaunohelper/com/sun/star/lib/uno/helper/WeakAdapter.java +++ b/javaunohelper/com/sun/star/lib/uno/helper/WeakAdapter.java @@ -34,17 +34,17 @@ public class WeakAdapter implements XAdapter { private final boolean DEBUG= false; // references the XWeak implementation - private WeakReference m_weakRef; + private WeakReference<Object> m_weakRef; // contains XReference objects registered by addReference - private List m_xreferenceList; + private List<XReference> m_xreferenceList; /** *@param component the object that is to be held weak */ public WeakAdapter(Object component) { - m_weakRef= new WeakReference(component); - m_xreferenceList= Collections.synchronizedList( new LinkedList()); + m_weakRef= new WeakReference<Object>(component); + m_xreferenceList= Collections.synchronizedList( new LinkedList<XReference>()); } /** Called by the XWeak implementation (WeakBase) when it is being finalized. @@ -59,10 +59,10 @@ public class WeakAdapter implements XAdapter void referentDying() { //synchronized call - Object[] references= m_xreferenceList.toArray(); + XReference[] references= m_xreferenceList.toArray(new XReference[m_xreferenceList.size()]); for (int i= references.length; i > 0; i--) { - ((XReference) references[i-1]).dispose(); + references[i-1].dispose(); } } diff --git a/javaunohelper/com/sun/star/lib/uno/helper/WeakBase.java b/javaunohelper/com/sun/star/lib/uno/helper/WeakBase.java index 829eb02d0f29..409773860be7 100644 --- a/javaunohelper/com/sun/star/lib/uno/helper/WeakBase.java +++ b/javaunohelper/com/sun/star/lib/uno/helper/WeakBase.java @@ -21,9 +21,9 @@ import com.sun.star.uno.XWeak; import com.sun.star.uno.XAdapter; import com.sun.star.lang.XTypeProvider; import com.sun.star.uno.Type; -import java.util.Vector; +import java.util.ArrayList; import java.util.Map; -import java.util.Hashtable; +import java.util.HashMap; /** This class can be used as the base class for UNO components. It implements the capability @@ -38,8 +38,8 @@ public class WeakBase implements XWeak, XTypeProvider // They have to be notified when this object dies private WeakAdapter m_adapter; - protected static Map _mapImplementationIds= new Hashtable(); - protected static Map _mapTypes= new Hashtable(); + protected static Map<Class<?>,byte[]> _mapImplementationIds = new HashMap<Class<?>,byte[]>(); + protected static Map<Class<?>,Type[]> _mapTypes = new HashMap<Class<?>,Type[]>(); /** Method of XWeak. The returned XAdapter implementation can be used to keap * a weak reference to this object. @@ -69,10 +69,10 @@ public class WeakBase implements XWeak, XTypeProvider */ public Type[] getTypes() { - Type[] arTypes= (Type[]) _mapTypes.get( getClass()); + Type[] arTypes= _mapTypes.get( getClass()); if (arTypes == null) { - Vector vec= new Vector(); + ArrayList<Type> vec= new ArrayList<Type>(); Class currentClass= getClass(); do { @@ -87,9 +87,7 @@ public class WeakBase implements XWeak, XTypeProvider currentClass= currentClass.getSuperclass(); } while (currentClass != null); - Type types[]= new Type[vec.size()]; - for( int i= 0; i < types.length; i++) - types[i]= (Type) vec.elementAt(i); + Type types[]= vec.toArray(new Type[vec.size()]); _mapTypes.put(getClass(), types); arTypes= types; } @@ -107,7 +105,7 @@ public class WeakBase implements XWeak, XTypeProvider byte[] id= null; synchronized (_mapImplementationIds) { - id= (byte[]) _mapImplementationIds.get(getClass()); + id= _mapImplementationIds.get(getClass()); if (id == null) { |