Java cleanup, use generic containers where possible

Change-Id: Icd830004de3e121f5b96393e7d7b447775833419
Reviewed-on: https://gerrit.libreoffice.org/3569
Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
This commit is contained in:
Noel Grandin 2013-04-23 09:30:47 +02:00 committed by Fridrich Strba
parent f62324cecd
commit 0c37eeebb0
8 changed files with 179 additions and 189 deletions

View File

@ -115,7 +115,7 @@ public final class TestEquals {
}
}
private final HashMap map = new HashMap();
private final HashMap<String,Object> map = new HashMap<String,Object>();
}
private final class Done implements XDone {
@ -160,7 +160,7 @@ public final class TestEquals {
UnoRuntime.queryInterface(
XDerived.class, test2Aa);
Hashtable params = new Hashtable();
Hashtable<String,String> params = new Hashtable<String,String>();
params.put("UNO_TYPES", unoTypes);
params.put("UNO_SERVICES", unoServices);
XComponentContext context = Bootstrap.

View File

@ -31,13 +31,13 @@ public class MethodHandler implements XPropertyHandler
private XIntrospectionAccess m_introspectionAccess;
private XIdlClass m_idlClass;
private XIdlMethod[] m_methods;
private java.util.HashMap m_methodsHash;
private java.util.HashMap<String,XIdlMethod> m_methodsHash;
/** Creates a new instance of MethodHandler */
public MethodHandler( XComponentContext _context )
{
m_context = _context;
m_methodsHash = new java.util.HashMap();
m_methodsHash = new java.util.HashMap<String,XIdlMethod>();
try
{
@ -169,7 +169,7 @@ public class MethodHandler implements XPropertyHandler
m_introspectionAccess = null;
m_methods = null;
m_methodsHash = new java.util.HashMap();
m_methodsHash = new java.util.HashMap<String,XIdlMethod>();
m_introspectionAccess = m_introspection.inspect( _component );
if ( m_introspectionAccess == null )
@ -217,7 +217,7 @@ public class MethodHandler implements XPropertyHandler
*/
private XIdlMethod impl_getMethod( String _methodName ) throws UnknownPropertyException
{
XIdlMethod method = (XIdlMethod)m_methodsHash.get( _methodName );
XIdlMethod method = m_methodsHash.get( _methodName );
if ( method == null )
throw new com.sun.star.beans.UnknownPropertyException();

View File

@ -48,7 +48,7 @@ public class TableCellTextBinding
private String m_newCellText;
private String m_lastKnownCellText;
private boolean m_haveNewCellText;
private java.util.List m_listeners;
private java.util.List<com.sun.star.util.XModifyListener> m_listeners;
/** Creates a new instance of TableCellTextBinding */
public TableCellTextBinding( XCell cell )
@ -56,7 +56,7 @@ public class TableCellTextBinding
m_cellText = UnoRuntime.queryInterface( XTextRange.class, cell );
m_newCellText = new String();
m_listeners = new java.util.LinkedList();
m_listeners = new java.util.LinkedList<com.sun.star.util.XModifyListener>();
start();
}

View File

@ -103,14 +103,13 @@ public class GlobalString {
public static String[] getMeaningfulLines(String srcStr, String neglectFirstChars) throws Exception {
StringReader outStringReader = new StringReader(srcStr);
BufferedReader outReader = new BufferedReader(outStringReader);
Vector origData = new Vector();
String str = null;
ArrayList<String> origData = new ArrayList<String>();
while(true) {
str = getMeaningfulLine(outReader, neglectFirstChars);
if (str==null) {
break;
}
origData.add(str);
String str = getMeaningfulLine(outReader, neglectFirstChars);
if (str==null) {
break;
}
origData.add(str);
}
return convert1DVectorToStringArray(origData);
}
@ -118,11 +117,11 @@ public class GlobalString {
/**
* convert vector to 1D String array
*/
public static String[] convert1DVectorToStringArray(Vector toToConvert) {
public static String[] convert1DVectorToStringArray(ArrayList<String> toToConvert) {
if (toToConvert==null) return null;
String[] objs = new String[toToConvert.size()];
for (int i=0; i<toToConvert.size(); i++) {
objs[i] =getObjString(toToConvert.elementAt(i));
objs[i] = getObjString(toToConvert.get(i));
}
return(objs);
}

View File

@ -32,47 +32,49 @@
*
*************************************************************************/
import java.util.HashMap;
import java.util.Iterator;
import java.util.Random;
import com.sun.star.awt.Point;
import com.sun.star.awt.Size;
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
import com.sun.star.container.XEnumeration;
import com.sun.star.container.XEnumerationAccess;
import com.sun.star.container.XIndexAccess;
import com.sun.star.container.XIndexReplace;
import com.sun.star.container.XNameAccess;
import com.sun.star.container.XNameContainer;
import com.sun.star.container.XNamed;
import com.sun.star.container.XIndexAccess;
import com.sun.star.container.XIndexReplace;
import com.sun.star.container.XEnumeration;
import com.sun.star.container.XEnumerationAccess;
import com.sun.star.drawing.XDrawPageSupplier;
import com.sun.star.drawing.XShape;
import com.sun.star.drawing.XShapes;
import com.sun.star.drawing.XDrawPageSupplier;
import com.sun.star.frame.XDesktop;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XModel;
import com.sun.star.frame.XController;
import com.sun.star.frame.XDesktop;
import com.sun.star.frame.XModel;
import com.sun.star.frame.XStorable;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.style.NumberingType;
import com.sun.star.style.XStyle;
import com.sun.star.style.XStyleFamiliesSupplier;
import com.sun.star.text.ControlCharacter;
import com.sun.star.text.ReferenceFieldSource;
import com.sun.star.text.ReferenceFieldPart;
import com.sun.star.text.ReferenceFieldSource;
import com.sun.star.text.TextColumn;
import com.sun.star.text.TextContentAnchorType;
import com.sun.star.text.XAutoTextGroup;
import com.sun.star.text.XAutoTextEntry;
import com.sun.star.text.XAutoTextGroup;
import com.sun.star.text.XBookmarksSupplier;
import com.sun.star.text.XDependentTextField;
import com.sun.star.text.XDocumentIndex;
import com.sun.star.text.XFootnote;
import com.sun.star.text.XFootnotesSupplier;
import com.sun.star.text.XPageCursor;
import com.sun.star.text.XParagraphCursor;
import com.sun.star.text.XReferenceMarksSupplier;
import com.sun.star.text.XRelativeTextContentInsert;
@ -84,30 +86,20 @@ import com.sun.star.text.XTextContent;
import com.sun.star.text.XTextCursor;
import com.sun.star.text.XTextDocument;
import com.sun.star.text.XTextField;
import com.sun.star.text.XTextFieldsSupplier;
import com.sun.star.text.XTextFrame;
import com.sun.star.text.XTextRange;
import com.sun.star.text.XTextTable;
import com.sun.star.text.XTextTableCursor;
import com.sun.star.text.XTextTablesSupplier;
import com.sun.star.text.XTextFieldsSupplier;
import com.sun.star.text.XBookmarksSupplier;
import com.sun.star.text.XTextViewCursorSupplier;
import com.sun.star.text.XTextViewCursor;
import com.sun.star.text.XPageCursor;
import com.sun.star.text.XTextViewCursorSupplier;
import com.sun.star.text.XWordCursor;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.util.XRefreshable;
import com.sun.star.frame.XStorable;
import com.sun.star.view.XPrintable;
import java.lang.Math;
import java.util.Random;
import java.util.Hashtable;
/*
* TextDocuments.java
*
@ -170,7 +162,7 @@ public class TextDocuments {
*/
protected void templateExample() throws java.lang.Exception {
// create a small hashtable that simulates a rowset
Hashtable recipient = new Hashtable();
HashMap<String,String> recipient = new HashMap<String,String>();
recipient.put("Company", "Manatee Books");
recipient.put("Contact", "Rod Martin");
recipient.put("ZIP", "34567");
@ -195,10 +187,9 @@ public class TextDocuments {
XEnumerationAccess xEnumeratedFields = xTextFieldsSupplier.getTextFields();
// iterate over hashtable and insert values into field masters
java.util.Enumeration keys = recipient.keys();
while(keys.hasMoreElements()) {
for(Iterator<String> iter = recipient.keySet().iterator(); iter.hasNext(); ) {
// get column name
String key = (String)keys.nextElement();
String key = iter.next();
// access corresponding field master
Object fieldMaster = xNamedFieldMasters.getByName(

View File

@ -88,7 +88,7 @@ public class _XScriptInvocation extends MultiMethodTest {
if (!context.equals("null"))
ctx = loadDocument(context);
HashMap map = new HashMap();
HashMap<String,Object> map = new HashMap<String,Object>();
map.put("SCRIPTING_DOC_STORAGE_ID", new Integer(storageId));
map.put("SCRIPTING_DOC_URI", "hahaha");
if (ctx != null)

View File

@ -81,7 +81,7 @@ public class _XScriptNameResolver extends MultiMethodTest {
log.println(description + ": " + logicalname);
HashMap map = new HashMap();
HashMap<String,Object> map = new HashMap<String,Object>();
map.put("SCRIPTING_DOC_STORAGE_ID", new Integer(storageId));
map.put("SCRIPTING_DOC_URI", util.utils.getFullTestURL(location));

View File

@ -84,7 +84,7 @@ public class TestDataLoader {
private static Parameters getParameters(StringTokenizer st) {
String separator = "=";
HashMap map = new HashMap(5);
HashMap<String,Object> map = new HashMap<String,Object>(5);
while (st.hasMoreTokens()) {
String pair = st.nextToken();