From 8be40d31d78723debd47f671544f480c1c606db7 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 3 May 2013 15:03:19 +0200 Subject: Java cleanup, convert Hashtable to HashMap Change-Id: If8a9c0c3a4b357fb9c0ff096f44ed1b44ebbcef4 --- .../com/sun/star/comp/helper/Bootstrap.java | 22 ++++++++++++++++++++-- .../com/sun/star/comp/helper/ComponentContext.java | 9 +++++++-- .../com/sun/star/comp/helper/Bootstrap_Test.java | 4 ++-- .../star/comp/helper/ComponentContext_Test.java | 13 +++++-------- 4 files changed, 34 insertions(+), 14 deletions(-) (limited to 'javaunohelper') diff --git a/javaunohelper/com/sun/star/comp/helper/Bootstrap.java b/javaunohelper/com/sun/star/comp/helper/Bootstrap.java index 989e283853b0..85bc4837a99d 100644 --- a/javaunohelper/com/sun/star/comp/helper/Bootstrap.java +++ b/javaunohelper/com/sun/star/comp/helper/Bootstrap.java @@ -89,13 +89,21 @@ public class Bootstrap { "com.sun.star.comp.connections.Acceptor", null, null, null ) ); } + /** + * backwards compatibility stub. + */ + static public XComponentContext createInitialComponentContext( Hashtable context_entries ) + throws Exception + { + return createInitialComponentContext((java.util.Map)context_entries); + } /** Bootstraps an initial component context with service manager and basic jurt components inserted. @param context_entries the hash table contains mappings of entry names (type string) to context entries (type class ComponentContextEntry). @return a new context. */ - static public XComponentContext createInitialComponentContext( Hashtable context_entries ) + static public XComponentContext createInitialComponentContext( java.util.Map context_entries ) throws Exception { ServiceManager xSMgr = new ServiceManager(); @@ -148,6 +156,16 @@ public class Bootstrap { { return defaultBootstrap_InitialComponentContext( null, null ); } + /** + * Backwards compatibility stub. + */ + static public final XComponentContext defaultBootstrap_InitialComponentContext( + String ini_file, Hashtable bootstrap_parameters ) + throws Exception + { + return defaultBootstrap_InitialComponentContext(ini_file, (java.util.Map)bootstrap_parameters); + + } /** Bootstraps the initial component context from a native UNO installation. @param ini_file @@ -158,7 +176,7 @@ public class Bootstrap { @see "cppuhelper/defaultBootstrap_InitialComponentContext()" */ static public final XComponentContext defaultBootstrap_InitialComponentContext( - String ini_file, Hashtable bootstrap_parameters ) + String ini_file, java.util.Map bootstrap_parameters ) throws Exception { // jni convenience: easier to iterate over array than calling Hashtable diff --git a/javaunohelper/com/sun/star/comp/helper/ComponentContext.java b/javaunohelper/com/sun/star/comp/helper/ComponentContext.java index c47d623dcfa8..0b3b1948acd2 100644 --- a/javaunohelper/com/sun/star/comp/helper/ComponentContext.java +++ b/javaunohelper/com/sun/star/comp/helper/ComponentContext.java @@ -58,7 +58,7 @@ 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 java.util.Map m_table; private XComponentContext m_xDelegate; private XMultiComponentFactory m_xSMgr; @@ -66,6 +66,11 @@ public class ComponentContext implements XComponentContext, XComponent private ArrayList m_eventListener; + public ComponentContext( Hashtable table, XComponentContext xDelegate ) + { + this((java.util.Map)table, xDelegate); + } + /** 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 ComponentContextEntry objects. @@ -75,7 +80,7 @@ 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( java.util.Map table, XComponentContext xDelegate ) { m_eventListener = new ArrayList(); m_table = table; diff --git a/javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java b/javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java index 2a292be96b1a..8e8032f1addd 100644 --- a/javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java +++ b/javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java @@ -28,7 +28,7 @@ import com.sun.star.lang.XMultiServiceFactory; public class Bootstrap_Test { - static public boolean test( String ini_file, java.util.Hashtable bootstrap_parameters ) + static public boolean test( String ini_file, java.util.Map bootstrap_parameters ) throws java.lang.Exception { boolean passed = false; @@ -91,7 +91,7 @@ public class Bootstrap_Test { if ( args.length == 0 ) usage(); - java.util.Hashtable bootstrap_parameters = new java.util.Hashtable(); + java.util.HashMap bootstrap_parameters = new java.util.HashMap(); for ( int nPos = 1; nPos < args.length; ++nPos ) { String arg = args[ nPos ]; diff --git a/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java b/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java index 1a28a77f84f2..7847a86a26ec 100644 --- a/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java +++ b/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java @@ -17,25 +17,22 @@ */ package com.sun.star.comp.helper; -import com.sun.star.uno.XComponentContext; +import java.util.HashMap; + import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiComponentFactory; - -import com.sun.star.comp.helper.ComponentContext; -import com.sun.star.comp.helper.ComponentContextEntry; import com.sun.star.uno.UnoRuntime; - -import java.util.Hashtable; +import com.sun.star.uno.XComponentContext; public class ComponentContext_Test { public static void main(String args[]) { try { - Hashtable table = new Hashtable(); + HashMap table = new HashMap(); table.put( "bla1", new ComponentContextEntry( null, new Integer( 1 ) ) ); XComponentContext xInitialContext = Bootstrap.createInitialComponentContext( table ); - table = new Hashtable(); + table = new HashMap(); table.put( "bla2", new ComponentContextEntry( new Integer( 2 ) ) ); table.put( "bla3", new Integer( 3 ) ); XComponentContext xContext = new ComponentContext( table, xInitialContext ); -- cgit