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 /scripting/java/com/sun/star | |
parent | 531a052bdc1eff3d66fd17ec6f7e9f373cbd1404 (diff) |
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 'scripting/java/com/sun/star')
13 files changed, 58 insertions, 58 deletions
diff --git a/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java index c4593276d76d..cb87c0b24731 100644 --- a/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java +++ b/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java @@ -55,7 +55,7 @@ public class ParcelBrowseNode extends PropertySet { private ScriptProvider provider; //private RootBrowseNode parent; - private Collection browsenodes; + private Collection<XBrowseNode> browsenodes; private String name; private ParcelContainer container; private Parcel parcel; @@ -134,7 +134,7 @@ public class ParcelBrowseNode extends PropertySet if ( hasChildNodes() ) { String[] names = parcel.getElementNames(); - browsenodes = new ArrayList( names.length ); + browsenodes = new ArrayList<XBrowseNode>( names.length ); for ( int index = 0; index < names.length; index++ ) { @@ -153,7 +153,7 @@ public class ParcelBrowseNode extends PropertySet LogUtils.DEBUG( LogUtils.getTrace( e ) ); return new XBrowseNode[0]; } - return (XBrowseNode[])browsenodes.toArray(new XBrowseNode[0]); + return browsenodes.toArray(new XBrowseNode[browsenodes.size()]); } public boolean hasChildNodes() { @@ -245,7 +245,7 @@ public class ParcelBrowseNode extends PropertySet if(browsenodes==null) { LogUtils.DEBUG("browsenodes null!!"); - browsenodes = new ArrayList(4); + browsenodes = new ArrayList<XBrowseNode>(4); } browsenodes.add(sbn); @@ -319,7 +319,7 @@ public class ParcelBrowseNode extends PropertySet { getChildNodes(); } - ScriptBrowseNode[] childNodes = (ScriptBrowseNode[])browsenodes.toArray(new ScriptBrowseNode[0]); + ScriptBrowseNode[] childNodes = browsenodes.toArray(new ScriptBrowseNode[browsenodes.size()]); for ( int index = 0; index < childNodes.length; index++ ) { diff --git a/scripting/java/com/sun/star/script/framework/browse/ProviderBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/ProviderBrowseNode.java index 3756920e580f..881496dd7b0c 100644 --- a/scripting/java/com/sun/star/script/framework/browse/ProviderBrowseNode.java +++ b/scripting/java/com/sun/star/script/framework/browse/ProviderBrowseNode.java @@ -47,7 +47,7 @@ public class ProviderBrowseNode extends PropertySet implements XBrowseNode, XInvocation { protected ScriptProvider provider; - protected Collection browsenodes; + protected Collection<XBrowseNode> browsenodes; protected String name; protected ParcelContainer container; protected Parcel parcel; @@ -105,7 +105,7 @@ public class ProviderBrowseNode extends PropertySet // needs initialisation? LogUtils.DEBUG("** ProviderBrowseNode.getChildNodes(), container is " + container ); String[] parcels = container.getElementNames(); - browsenodes = new ArrayList( parcels.length ); + browsenodes = new ArrayList<XBrowseNode>( parcels.length ); for ( int index = 0; index < parcels.length; index++ ) { try @@ -133,7 +133,7 @@ public class ProviderBrowseNode extends PropertySet LogUtils.DEBUG("*** No container available"); return new XBrowseNode[0]; } - return ( XBrowseNode[] )browsenodes.toArray( new XBrowseNode[0] ); + return browsenodes.toArray( new XBrowseNode[browsenodes.size()] ); } public boolean hasChildNodes() { @@ -231,7 +231,7 @@ public class ProviderBrowseNode extends PropertySet LogUtils.DEBUG("created parcel node "); if ( browsenodes == null ) { - browsenodes = new ArrayList( 5 ); + browsenodes = new ArrayList<XBrowseNode>( 5 ); } browsenodes.add(parcel); diff --git a/scripting/java/com/sun/star/script/framework/container/DeployedUnoPackagesDB.java b/scripting/java/com/sun/star/script/framework/container/DeployedUnoPackagesDB.java index 3ce059c652c6..9a9cb5eb4ef2 100644 --- a/scripting/java/com/sun/star/script/framework/container/DeployedUnoPackagesDB.java +++ b/scripting/java/com/sun/star/script/framework/container/DeployedUnoPackagesDB.java @@ -70,7 +70,7 @@ public class DeployedUnoPackagesDB { public String[] getDeployedPackages( String language ) { - ArrayList packageUrls = new ArrayList(4); + ArrayList<String> packageUrls = new ArrayList<String>(4); Element main = document.getDocumentElement(); Element root = null; Element item; @@ -108,7 +108,7 @@ public class DeployedUnoPackagesDB { } if ( !packageUrls.isEmpty() ) { - return (String[])packageUrls.toArray( new String[0] ); + return packageUrls.toArray( new String[packageUrls.size()] ); } return new String[0]; } diff --git a/scripting/java/com/sun/star/script/framework/container/ParcelContainer.java b/scripting/java/com/sun/star/script/framework/container/ParcelContainer.java index 90a31711ae4d..ff4678f7a97f 100644 --- a/scripting/java/com/sun/star/script/framework/container/ParcelContainer.java +++ b/scripting/java/com/sun/star/script/framework/container/ParcelContainer.java @@ -50,11 +50,11 @@ public class ParcelContainer implements XNameAccess { protected String language; protected String containerUrl; - protected Collection parcels = new ArrayList(10); + protected Collection<Parcel> parcels = new ArrayList<Parcel>(10); static protected XSimpleFileAccess m_xSFA; protected XComponentContext m_xCtx; private ParcelContainer parent = null; - private Collection childContainers = new ArrayList(10);; + private Collection<ParcelContainer> childContainers = new ArrayList<ParcelContainer>(10); private boolean isPkgContainer = false; /** @@ -102,7 +102,7 @@ public class ParcelContainer implements XNameAccess { return new ParcelContainer[0]; } - return (ParcelContainer[]) childContainers.toArray( new ParcelContainer[0] ); + return childContainers.toArray( new ParcelContainer[childContainers.size()] ); } /** @@ -141,10 +141,10 @@ public class ParcelContainer implements XNameAccess public ParcelContainer getChildContainer( String key ) { ParcelContainer result = null; - Iterator iter = childContainers.iterator(); + Iterator<ParcelContainer> iter = childContainers.iterator(); while ( iter.hasNext() ) { - ParcelContainer c = (ParcelContainer) iter.next(); + ParcelContainer c = iter.next(); String location = ScriptMetaData.getLocationPlaceHolder( c.containerUrl, c.getName()); @@ -171,10 +171,10 @@ public class ParcelContainer implements XNameAccess public ParcelContainer getChildContainerForURL( String containerUrl ) { ParcelContainer result = null; - Iterator iter = childContainers.iterator(); + Iterator<ParcelContainer> iter = childContainers.iterator(); while ( iter.hasNext() ) { - ParcelContainer c = (ParcelContainer) iter.next(); + ParcelContainer c = iter.next(); if ( containerUrl.equals( c.containerUrl ) ) { result = c; @@ -327,10 +327,10 @@ public class ParcelContainer implements XNameAccess { if ( hasElements() ) { - Iterator iter = parcels.iterator(); + Iterator<Parcel> iter = parcels.iterator(); while ( iter.hasNext() ) { - Parcel parcelToCheck = (Parcel)iter.next(); + Parcel parcelToCheck = iter.next(); if ( parcelToCheck.getName().equals( aName ) ) { @@ -354,7 +354,7 @@ public class ParcelContainer implements XNameAccess { if ( hasElements() ) { - Parcel[] theParcels = (Parcel[])parcels.toArray( new Parcel[0] ); + Parcel[] theParcels = parcels.toArray( new Parcel[parcels.size()] ); String[] names = new String[ theParcels.length ]; for ( int count = 0; count < names.length; count++ ) { @@ -404,7 +404,7 @@ public class ParcelContainer implements XNameAccess { LogUtils.DEBUG( getParcelContainerDir() + " is a folder " ); String[] children = m_xSFA.getFolderContents( getParcelContainerDir(), true ); - parcels = new ArrayList(children.length); + parcels = new ArrayList<Parcel>(children.length); for ( int i = 0; i < children.length; i++) { LogUtils.DEBUG("Processing " + children[ i ] ); diff --git a/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java b/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java index 36edde14e86c..55c5c2fdd3a1 100644 --- a/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java +++ b/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java @@ -46,7 +46,7 @@ public class ParcelDescriptor { PARCEL_DESCRIPTOR_NAME = "parcel-descriptor.xml"; // Collection of all ParcelDescriptor created for files - private static final Map PARCEL_DESCRIPTOR_MAP = new HashMap(5); + private static final Map<File,ParcelDescriptor> PARCEL_DESCRIPTOR_MAP = new HashMap<File,ParcelDescriptor>(5); // This is the default contents of a parcel descriptor to be used when // creating empty descriptors @@ -58,7 +58,7 @@ public class ParcelDescriptor { private File file = null; private Document document = null; private String language = null; - private Map languagedepprops = new Hashtable(3); + private Map<String,String> languagedepprops = new Hashtable<String,String>(3); public static synchronized void removeParcelDescriptor(File parent) { File path = new File(parent, PARCEL_DESCRIPTOR_NAME); @@ -67,7 +67,7 @@ public class ParcelDescriptor { public static synchronized void renameParcelDescriptor(File oldFile, File newFile) { File oldPath = new File(oldFile, PARCEL_DESCRIPTOR_NAME); - ParcelDescriptor pd = (ParcelDescriptor)PARCEL_DESCRIPTOR_MAP.get(oldPath); + ParcelDescriptor pd = PARCEL_DESCRIPTOR_MAP.get(oldPath); if(pd != null) { PARCEL_DESCRIPTOR_MAP.remove(oldPath); File newPath = new File(newFile, PARCEL_DESCRIPTOR_NAME); @@ -82,7 +82,7 @@ public class ParcelDescriptor { getParcelDescriptor(File parent) { File path = new File(parent, PARCEL_DESCRIPTOR_NAME); - ParcelDescriptor pd = (ParcelDescriptor)PARCEL_DESCRIPTOR_MAP.get(path); + ParcelDescriptor pd = PARCEL_DESCRIPTOR_MAP.get(path); if (pd == null && path.exists()) { try { @@ -214,7 +214,7 @@ public class ParcelDescriptor { } public ScriptEntry[] getScriptEntries() { - ArrayList scripts = new ArrayList(); + ArrayList<ScriptEntry> scripts = new ArrayList<ScriptEntry>(); NodeList scriptNodes; int len; @@ -225,7 +225,7 @@ public class ParcelDescriptor { for (int i = 0; i < len; i++) { String language, languagename, logicalname, description = ""; - Map langProps = new HashMap(); + Map<String,String> langProps = new HashMap<String,String>(); NodeList nl; Element tmp; @@ -285,7 +285,7 @@ public class ParcelDescriptor { ScriptEntry entry = new ScriptEntry(language, languagename, logicalname, "",langProps, description); scripts.add(entry); } - return (ScriptEntry[])scripts.toArray(new ScriptEntry[0]); + return scripts.toArray(new ScriptEntry[scripts.size()]); } public void setScriptEntries(ScriptEntry[] scripts) { @@ -301,7 +301,7 @@ public class ParcelDescriptor { } public String getLanguageProperty(String name) { - return (String)languagedepprops.get(name); + return languagedepprops.get(name); } public void setLanguageProperty(String name, String value) { @@ -424,12 +424,12 @@ public class ParcelDescriptor { String key; item = document.createElement("languagedepprops"); - Iterator iter = languagedepprops.keySet().iterator(); + Iterator<String> iter = languagedepprops.keySet().iterator(); while (iter.hasNext()) { tempitem = document.createElement("prop"); key = (String)iter.next(); tempitem.setAttribute("name", key); - tempitem.setAttribute("value", (String)languagedepprops.get(key)); + tempitem.setAttribute("value", languagedepprops.get(key)); item.appendChild(tempitem); } root.appendChild(item); diff --git a/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java b/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java index e35abe671302..e0051aeaf87c 100644 --- a/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java +++ b/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java @@ -22,7 +22,7 @@ import java.net.URL; import java.io.ByteArrayInputStream; -import java.util.Vector; +import java.util.ArrayList; import java.util.StringTokenizer; import java.io.InputStream; @@ -250,7 +250,7 @@ public class ScriptMetaData extends ScriptEntry implements Cloneable { try { String classpath = (String)getLanguageProperties().get("classpath"); - Vector paths = null; + ArrayList paths = null; if ( classpath == null ) { @@ -267,7 +267,7 @@ public class ScriptMetaData extends ScriptEntry implements Cloneable { // replace \ with / parcelPath = parcelPath.replace( '\\', '/' ); - Vector classPathVec = new Vector(); + ArrayList<URL> classPathVec = new ArrayList<URL>(); StringTokenizer stk = new StringTokenizer(classpath, ":"); while ( stk.hasMoreElements() ) { @@ -289,7 +289,7 @@ public class ScriptMetaData extends ScriptEntry implements Cloneable { } } - return (URL[])classPathVec.toArray( new URL[0]); + return classPathVec.toArray( new URL[classPathVec.size()]); } catch ( Exception e ) { diff --git a/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java b/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java index b08797819c69..b4389eec9b0d 100644 --- a/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java +++ b/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java @@ -40,7 +40,7 @@ import com.sun.star.deployment.ExtensionRemovedException; public class UnoPkgContainer extends ParcelContainer { - private Map registeredPackages = new HashMap(); + private Map<String,ParcelContainer> registeredPackages = new HashMap<String,ParcelContainer>(); protected String extensionDb; protected String extensionRepository; @@ -64,7 +64,7 @@ public class UnoPkgContainer extends ParcelContainer LogUtils.DEBUG("** getRegisterPackage ctx = " + containerUrl ); LogUtils.DEBUG("** getRegisterPackage for uri " + url ); LogUtils.DEBUG("** getRegisterPackage for langugage " + language ); - ParcelContainer result = (ParcelContainer)registeredPackages.get( url ); + ParcelContainer result = registeredPackages.get( url ); LogUtils.DEBUG("getRegisterPackage result is " + result ); return result; } @@ -110,8 +110,7 @@ public class UnoPkgContainer extends ParcelContainer if ( db.removePackage( language, url ) ) { writeUnoPackageDB( db ); - ParcelContainer container = - ( ParcelContainer ) registeredPackages.get( url ); + ParcelContainer container = registeredPackages.get( url ); if ( !container.hasElements() ) { // When all libraries within a package bundle diff --git a/scripting/java/com/sun/star/script/framework/container/XMLParserFactory.java b/scripting/java/com/sun/star/script/framework/container/XMLParserFactory.java index 0afe85cb45e8..69d94eb252c3 100644 --- a/scripting/java/com/sun/star/script/framework/container/XMLParserFactory.java +++ b/scripting/java/com/sun/star/script/framework/container/XMLParserFactory.java @@ -90,7 +90,7 @@ public class XMLParserFactory { } public void write(Document doc, OutputStream out) throws IOException { - Class clazz = doc.getClass(); + Class<?> clazz = doc.getClass(); String name = clazz.getName(); // depending on the class of the Document object use introspection @@ -111,8 +111,8 @@ public class XMLParserFactory { // try xerces serialize package using introspection ClassLoader cl = this.getClass().getClassLoader(); - Class serializerClass = null; - Class formatterClass = null; + Class<?> serializerClass = null; + Class<?> formatterClass = null; try { serializerClass = Class.forName( diff --git a/scripting/java/com/sun/star/script/framework/io/UCBStreamHandler.java b/scripting/java/com/sun/star/script/framework/io/UCBStreamHandler.java index 16c866431404..78f74d40e215 100644 --- a/scripting/java/com/sun/star/script/framework/io/UCBStreamHandler.java +++ b/scripting/java/com/sun/star/script/framework/io/UCBStreamHandler.java @@ -41,7 +41,7 @@ public class UCBStreamHandler extends URLStreamHandler { private XComponentContext m_xContext = null; private XMultiComponentFactory m_xMultiComponentFactory = null; private XSimpleFileAccess m_xSimpleFileAccess = null; - private HashMap m_jarStreamMap = new HashMap(12); + private HashMap<String,InputStream> m_jarStreamMap = new HashMap<String,InputStream>(12); public static String m_ucbscheme; public UCBStreamHandler( XComponentContext ctxt, String scheme, XSimpleFileAccess xSFA ) @@ -149,7 +149,7 @@ public class UCBStreamHandler extends URLStreamHandler { try { if (path.endsWith(".jar")) { - is = (InputStream)m_jarStreamMap.get(path); + is = m_jarStreamMap.get(path); if (is == null) { is = getFileStreamFromUCB(path); diff --git a/scripting/java/com/sun/star/script/framework/io/XStorageHelper.java b/scripting/java/com/sun/star/script/framework/io/XStorageHelper.java index 6a3d90d3ac62..3752f8a766ab 100644 --- a/scripting/java/com/sun/star/script/framework/io/XStorageHelper.java +++ b/scripting/java/com/sun/star/script/framework/io/XStorageHelper.java @@ -56,7 +56,7 @@ public class XStorageHelper implements XEventListener XStream xStream; XInputStream xIs = null; XOutputStream xOs = null; - static Map modelMap = new HashMap(); + static Map<String,XModel> modelMap = new HashMap<String,XModel>(); XModel xModel = null; private static XStorageHelper listener = new XStorageHelper(); @@ -262,7 +262,7 @@ public class XStorageHelper implements XEventListener public XModel getModelForURL( String url ) { //TODO does not cater for untitled documents - return (XModel)modelMap.get( url ); + return modelMap.get( url ); } } diff --git a/scripting/java/com/sun/star/script/framework/provider/java/ScriptDescriptor.java b/scripting/java/com/sun/star/script/framework/provider/java/ScriptDescriptor.java index 6a4c490ba9fa..ea7b19dc781b 100644 --- a/scripting/java/com/sun/star/script/framework/provider/java/ScriptDescriptor.java +++ b/scripting/java/com/sun/star/script/framework/provider/java/ScriptDescriptor.java @@ -18,7 +18,8 @@ package com.sun.star.script.framework.provider.java; -import java.util.Vector; +import java.util.List; +import java.util.ArrayList; import java.util.StringTokenizer; /** @@ -33,8 +34,8 @@ public class ScriptDescriptor private String m_name; private String m_methodName; private String m_className; - private Vector m_classpath; - private Vector m_argumentTypes = new Vector( 11 ); + private List<String> m_classpath; + private ArrayList<Class<?>> m_argumentTypes = new ArrayList<Class<?>>( 11 ); /** @@ -110,7 +111,7 @@ public class ScriptDescriptor * * @param classpath The new classpath value */ - public void setClasspath( Vector classpath ) + public void setClasspath( List<String> classpath ) { this.m_classpath = classpath; } @@ -121,7 +122,7 @@ public class ScriptDescriptor * * @return The classpath value */ - public Vector getClasspath() + public List<String> getClasspath() { return m_classpath; } @@ -133,9 +134,9 @@ public class ScriptDescriptor * * @param clazz The feature to be added to the ArgumentType attribute */ - public synchronized void addArgumentType( Class clazz ) + public synchronized void addArgumentType( Class<?> clazz ) { - m_argumentTypes.addElement( clazz ); + m_argumentTypes.add( clazz ); } @@ -162,11 +163,11 @@ public class ScriptDescriptor * * @return The argumentTypes value */ - public synchronized Class[] + public synchronized Class<?>[] getArgumentTypes() { if ( m_argumentTypes.size() > 0 ) - return ( Class[] ) m_argumentTypes.toArray( new Class[ 0 ] ); + return m_argumentTypes.toArray( new Class[ m_argumentTypes.size() ] ); else return null; } diff --git a/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java b/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java index 598089689e22..dbe8967beffc 100644 --- a/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java +++ b/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java @@ -240,7 +240,7 @@ class ScriptImpl implements XScript throw e2; } - ArrayList invocationArgList = new ArrayList(); + ArrayList<Object> invocationArgList = new ArrayList<Object>(); Object[] invocationArgs = null; LogUtils.DEBUG( "Parameter Mapping..." ); diff --git a/scripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java b/scripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java index e596131a410e..3722b1fd5d22 100644 --- a/scripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java +++ b/scripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java @@ -110,7 +110,7 @@ public class StrictResolver implements Resolver * @exception ClassNotFoundException * @exception NoSuchMethodException */ - private Method resolveArguments( ScriptDescriptor sd, Class c ) + private Method resolveArguments( ScriptDescriptor sd, Class<?> c ) throws ClassNotFoundException, NoSuchMethodException { return c.getMethod( sd.getMethodName(), sd.getArgumentTypes() ); |