Java5 updates - update code to use generics

This is all of the code I missed in my first set of patches.

Change-Id: I8c7c9e5ac28dc3c2f3ac062c806fbf0787c997bd
This commit is contained in:
Noel Grandin
2012-06-29 10:08:15 +02:00
committed by Michael Stahl
parent 531a052bdc
commit f9fa0dd66b
46 changed files with 244 additions and 232 deletions

View File

@@ -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++ )
{

View File

@@ -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);

View File

@@ -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];
}

View File

@@ -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 ] );

View File

@@ -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);

View File

@@ -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 )
{

View File

@@ -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

View File

@@ -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(

View File

@@ -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);

View File

@@ -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 );
}
}

View File

@@ -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;
}

View File

@@ -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..." );

View File

@@ -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() );