From 587c59fbc931b12f4d63d077a78bcaa43ffbf83d Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 3 May 2013 14:35:04 +0200 Subject: Java cleanup, Convert Vector to ArrayList Change-Id: I323a6625f93347e69f3114fc10cb04dc759a539f --- .../DevelopersGuide/Forms/ButtonOperator.java | 14 ++--- .../DevelopersGuide/Forms/SalesFilter.java | 6 +- .../OfficeDev/DesktopEnvironment/IOnewayLink.java | 4 +- .../OfficeDev/DesktopEnvironment/Interceptor.java | 8 +-- .../DesktopEnvironment/OnewayExecutor.java | 16 +++--- .../DesktopEnvironment/StatusListener.java | 6 +- .../DesktopEnvironment/ViewContainer.java | 13 ++--- .../DevelopersGuide/Spreadsheet/ExampleAddIn.java | 12 ++-- .../DevelopersGuide/UCB/ChildrenRetriever.java | 48 ++++++++-------- .../DevelopersGuide/UCB/PropertiesComposer.java | 24 ++++---- .../DevelopersGuide/UCB/PropertiesRetriever.java | 22 ++++---- .../EmbeddedObject/OwnEmbeddedObject.java | 40 +++++++------- odk/examples/java/Inspector/HideableTreeModel.java | 33 ++++++----- odk/examples/java/Inspector/Inspector.java | 14 +++-- odk/examples/java/Inspector/Introspector.java | 11 ++-- .../java/Inspector/MethodParametersDialog.java | 14 +++-- .../java/Inspector/SourceCodeGenerator.java | 15 ++--- .../java/Inspector/SwingUnoMethodNode.java | 9 +-- odk/examples/java/Inspector/UnoMethodNode.java | 3 +- odk/examples/java/Inspector/UnoNode.java | 7 ++- odk/examples/java/Inspector/XUnoMethodNode.java | 3 +- odk/examples/java/ToDo/ToDo.java | 64 +++++++++++----------- 22 files changed, 193 insertions(+), 193 deletions(-) (limited to 'odk') diff --git a/odk/examples/DevelopersGuide/Forms/ButtonOperator.java b/odk/examples/DevelopersGuide/Forms/ButtonOperator.java index a447381a2c69..3d121589d8e6 100644 --- a/odk/examples/DevelopersGuide/Forms/ButtonOperator.java +++ b/odk/examples/DevelopersGuide/Forms/ButtonOperator.java @@ -32,6 +32,8 @@ * *************************************************************************/ // java base stuff +import java.util.ArrayList; + import com.sun.star.awt.ActionEvent; import com.sun.star.awt.XActionListener; import com.sun.star.awt.XButton; @@ -42,7 +44,6 @@ import com.sun.star.form.runtime.XFormOperations; import com.sun.star.lang.EventObject; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; -import java.util.Vector; /**************************************************************************/ @@ -55,7 +56,7 @@ public class ButtonOperator implements XActionListener, XFeatureInvalidation private XPropertySet m_form; private XFormOperations m_formOperations; - private Vector m_aButtons; + private ArrayList m_aButtons; /* ------------------------------------------------------------------ */ /** ctor @@ -65,7 +66,7 @@ public class ButtonOperator implements XActionListener, XFeatureInvalidation m_componentContext = xCtx; m_aDocument = aDocument; m_form = _form; - m_aButtons = new Vector(); + m_aButtons = new ArrayList(); } /* ------------------------------------------------------------------ */ @@ -89,7 +90,7 @@ public class ButtonOperator implements XActionListener, XFeatureInvalidation { for ( int i=0; i < m_aButtons.size(); ++i ) { - XPropertySet button = m_aButtons.elementAt( i ); + XPropertySet button = m_aButtons.get( i ); if ( _formFeature == getAssociatedFormFeature( button ) ) return button; } @@ -104,7 +105,7 @@ public class ButtonOperator implements XActionListener, XFeatureInvalidation int nPos = -1; for ( int i=0; ( i < m_aButtons.size() ) && ( -1 == nPos ); ++i ) { - if ( xButton.equals( m_aButtons.elementAt( i ) ) ) + if ( xButton.equals( m_aButtons.get( i ) ) ) nPos = i; } return nPos; @@ -207,9 +208,8 @@ public class ButtonOperator implements XActionListener, XFeatureInvalidation public void invalidateAllFeatures() throws com.sun.star.uno.RuntimeException { - for ( int i=0; i < m_aButtons.size(); ++i ) + for ( XPropertySet buttonModel : m_aButtons ) { - XPropertySet buttonModel = m_aButtons.elementAt( i ); updateButtonState( buttonModel, getAssociatedFormFeature( buttonModel ) ); } } diff --git a/odk/examples/DevelopersGuide/Forms/SalesFilter.java b/odk/examples/DevelopersGuide/Forms/SalesFilter.java index e4c516160d0f..33053db662ca 100644 --- a/odk/examples/DevelopersGuide/Forms/SalesFilter.java +++ b/odk/examples/DevelopersGuide/Forms/SalesFilter.java @@ -362,7 +362,7 @@ class SalesFilter implements XActionListener, XPropertyChangeListener, XResetLis String[] aOldFilterItems = (String[])m_xFilterList.getPropertyValue( "StringItemList" ); // translate this into a vector - much more comfort to work with a vector than with an array .... - java.util.Vector aFilterItems = new java.util.Vector(); + java.util.ArrayList aFilterItems = new java.util.ArrayList(); for ( int i=0; i 10 ) // (6 standard items + 5 user defined items) { // the first (and thus oldes) user defined item - aFilterItems.removeElementAt( 6 ); + aFilterItems.remove( 6 ); // keep our date vector synchron m_aFilterDates.removeElementAt( 6 ); } @@ -397,7 +397,7 @@ class SalesFilter implements XActionListener, XPropertyChangeListener, XResetLis m_bAdjustingFilterList = true; String[] aNewFilterItems = new String[ aFilterItems.size() ]; for ( int i=0; i lParams ); + public abstract void execOneway( int nRequest, ArrayList lParams ); } diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java index c9fe4f38c33f..628cc587c83d 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java @@ -34,7 +34,7 @@ // __________ Imports __________ -import java.util.Vector; +import java.util.ArrayList; import com.sun.star.frame.FrameActionEvent; import com.sun.star.uno.UnoRuntime; @@ -160,7 +160,7 @@ public class Interceptor implements com.sun.star.frame.XFrameActionListener, * @param lParams * the vector with all packed parameters of the original request */ - public void execOneway(/*IN*/ int nRequest,/*IN*/ Vector lParams ) + public void execOneway(/*IN*/ int nRequest,/*IN*/ ArrayList lParams ) { synchronized(this) { @@ -234,7 +234,7 @@ public class Interceptor implements com.sun.star.frame.XFrameActionListener, return; // pack the event and start thread - which call us back later - Vector lOutParams = new Vector(); + ArrayList lOutParams = new ArrayList(); lOutParams.add(aEvent); OnewayExecutor aExecutor = new OnewayExecutor( this , @@ -272,7 +272,7 @@ public class Interceptor implements com.sun.star.frame.XFrameActionListener, lInURL[0] = aURL ; lInArguments[0] = lArguments; - Vector lOutParams = OnewayExecutor.encodeDispatch( + ArrayList lOutParams = OnewayExecutor.encodeDispatch( lInURL , lInArguments ); OnewayExecutor aExecutor = new OnewayExecutor( this , diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java index 0f48ede996ae..2861b23bde3a 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java @@ -32,7 +32,7 @@ * *************************************************************************/ -import java.util.Vector; +import java.util.ArrayList; // __________ Implementation __________ @@ -76,7 +76,7 @@ class OnewayExecutor extends Thread */ private IOnewayLink m_rLink ; private int m_nRequest ; - private Vector m_lParams ; + private ArrayList m_lParams ; // _______________________________ @@ -102,7 +102,7 @@ class OnewayExecutor extends Thread */ public OnewayExecutor( IOnewayLink rLink , int nRequest , - Vector lParams ) + ArrayList lParams ) { m_rLink = rLink ; m_nRequest = nRequest; @@ -144,13 +144,13 @@ class OnewayExecutor extends Thread // _______________________________ - public static Vector encodeDispatch( + public static ArrayList encodeDispatch( com.sun.star.util.URL[] aURL, com.sun.star.beans.PropertyValue[][] lArgs) { int nLength = lArgs.length+1; int nPos = 0; - Vector lParams = new Vector(nLength); + ArrayList lParams = new ArrayList(nLength); lParams.add( aURL[0] ); --nLength; @@ -165,7 +165,7 @@ class OnewayExecutor extends Thread } public static void decodeDispatch( - Vector lParams, + ArrayList lParams, com.sun.star.util.URL[] aURL, com.sun.star.beans.PropertyValue[][] lArgs) { @@ -173,12 +173,12 @@ class OnewayExecutor extends Thread int nPos = 0; lArgs[0] = new com.sun.star.beans.PropertyValue[nLength]; - aURL[0] = (com.sun.star.util.URL) lParams.elementAt(0); + aURL[0] = (com.sun.star.util.URL) lParams.get(0); while (nPos lParams ) + public void execOneway(/*IN*/ int nRequest,/*IN*/ ArrayList lParams ) { synchronized(this) { @@ -213,7 +213,7 @@ class StatusListener implements com.sun.star.frame.XStatusListener, if (! bHandle) return; - Vector lOutParams = new Vector(); + ArrayList lOutParams = new ArrayList(); lOutParams.add(aEvent); OnewayExecutor aExecutor = new OnewayExecutor( this , diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java index c2fbff2cde91..e9f396e1c0a2 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java @@ -74,8 +74,8 @@ public class ViewContainer extends Thread */ private ViewContainer() { - mlViews = new Vector(); - mlListener = new Vector(); + mlViews = new ArrayList(); + mlListener = new ArrayList(); mbShutdownActive = false ; Runtime.getRuntime().addShutdownHook(this); } @@ -204,9 +204,8 @@ public class ViewContainer extends Thread IShutdownListener aListener = null; synchronized(mlListener) { - try{ - aListener = mlListener.firstElement(); - } catch(java.util.NoSuchElementException exEmpty) {} + if (!mlListener.isEmpty()) + aListener = mlListener.get(0); } if (aListener==null) break; @@ -258,7 +257,7 @@ public class ViewContainer extends Thread */ public static boolean mbInplace = false ; private static ViewContainer maSingleton = null ; - private Vector mlViews ; - private Vector mlListener ; + private ArrayList mlViews ; + private ArrayList mlListener ; private boolean mbShutdownActive ; } diff --git a/odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.java b/odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.java index 388e4890bbd2..47cc018ac2e4 100644 --- a/odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.java +++ b/odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.java @@ -38,7 +38,7 @@ class ExampleAddInResult implements com.sun.star.sheet.XVolatileResult { private String aName; private int nValue; - private java.util.Vector aListeners = new java.util.Vector(); + private java.util.ArrayList aListeners = new java.util.ArrayList(); public ExampleAddInResult( String aNewName ) { @@ -56,7 +56,7 @@ class ExampleAddInResult implements com.sun.star.sheet.XVolatileResult public void addResultListener(com.sun.star.sheet.XResultListener aListener) { - aListeners.addElement( aListener ); + aListeners.add( aListener ); // immediately notify of initial value aListener.modified( getResult() ); @@ -64,7 +64,7 @@ class ExampleAddInResult implements com.sun.star.sheet.XVolatileResult public void removeResultListener(com.sun.star.sheet.XResultListener aListener) { - aListeners.removeElement( aListener ); + aListeners.remove( aListener ); } public void incrementValue() @@ -72,10 +72,8 @@ class ExampleAddInResult implements com.sun.star.sheet.XVolatileResult ++nValue; com.sun.star.sheet.ResultEvent aEvent = getResult(); - java.util.Enumeration aEnum = aListeners.elements(); - while (aEnum.hasMoreElements()) - aEnum.nextElement().modified( - aEvent); + for( XResultListener l : aListeners) + l.modified(aEvent); } } diff --git a/odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java b/odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java index 00591ec4bc58..03a45bae9c23 100644 --- a/odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java +++ b/odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java @@ -32,19 +32,18 @@ * *************************************************************************/ +import java.util.ArrayList; +import java.util.StringTokenizer; + +import com.sun.star.beans.Property; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.sdbc.XRow; import com.sun.star.ucb.OpenCommandArgument2; import com.sun.star.ucb.OpenMode; import com.sun.star.ucb.XContent; import com.sun.star.ucb.XContentAccess; import com.sun.star.ucb.XDynamicResultSet; -import com.sun.star.beans.Property; import com.sun.star.uno.UnoRuntime; -import com.sun.star.sdbc.XRow; -import com.sun.star.sdbc.XResultSet; - -import java.util.Vector; -import java.util.Enumeration; -import java.util.StringTokenizer; /** * Retrieve the Children of a UCB Folder Content @@ -57,7 +56,7 @@ public class ChildrenRetriever { private Helper m_helper; private XContent m_content; private String m_contenturl = ""; - private Vector m_propnames = new Vector(); + private ArrayList m_propnames = new ArrayList(); /** * Constructor. Create a new connection with the specific args to a running office @@ -87,30 +86,30 @@ public class ChildrenRetriever { * This method requires the main and the optional arguments to be set in order to work. * See Constructor. * - *@return Vector Returns children properties values if values successfully retrieved, + *@return Returns children properties values if values successfully retrieved, * null otherwise *@exception com.sun.star.ucb.CommandAbortedException *@exception com.sun.star.uno.Exception */ - public Vector> getChildren() + public ArrayList> getChildren() throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception { - Vector properties = getProperties(); + ArrayList properties = getProperties(); return getChildren ( properties ); } /** * Open a folder content, get properties values for the properties. * - *@param Vector Properties - *@return Vector Returns children properties values if values successfully retrieved, + *@param properties + *@return Returns children properties values if values successfully retrieved, * null otherwise *@exception com.sun.star.ucb.CommandAbortedException *@exception com.sun.star.uno.Exception */ - public Vector> getChildren( Vector properties ) + public ArrayList> getChildren( ArrayList properties ) throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception { - Vector> result = null; + ArrayList> result = null; if ( m_content != null ) { int size = 0; if ( properties != null && !properties.isEmpty()) { @@ -140,7 +139,7 @@ public class ChildrenRetriever { XDynamicResultSet.class, m_helper.executeCommand( m_content, "open", arg )); XResultSet resultSet = set.getStaticResultSet(); - result = new Vector>(); + result = new ArrayList>(); ///////////////////////////////////////////////////////////////////// // Iterate over children, access children and property values... @@ -153,7 +152,7 @@ public class ChildrenRetriever { XRow row = UnoRuntime.queryInterface( XRow.class, resultSet ); do { - Vector propsValues = new Vector(); + ArrayList propsValues = new ArrayList(); // Obtain URL of child. String id = contentAccess.queryContentIdentifierString(); @@ -187,7 +186,7 @@ public class ChildrenRetriever { * *@return String That contains the properties */ - public Vector getProperties() { + public ArrayList getProperties() { return m_propnames; } @@ -240,10 +239,8 @@ public class ChildrenRetriever { /** * Print all properties out contained in vector . - * - *@param Vector */ - public void printLine( Vector props ) { + public void printLine( ArrayList props ) { int limit; while ( !props.isEmpty() ) { String print = ""; @@ -305,7 +302,7 @@ public class ChildrenRetriever { ChildrenRetriever access = new ChildrenRetriever( args ); // Get the properties Title and IsFolder for the children. - Vector> result = access.getChildren(); + ArrayList> result = access.getChildren(); String tempPrint = "\nChildren of resource " + access.getContentURL(); int size = tempPrint.length(); @@ -318,9 +315,9 @@ public class ChildrenRetriever { if ( result != null && !result.isEmpty() ) { - Vector cont = new Vector(); + ArrayList cont = new ArrayList(); cont.add("URL:"); - Vector props = access.getProperties(); + ArrayList props = access.getProperties(); size = props.size(); for ( int i = 0; i < size; i++ ) { Object obj = props.get( i ); @@ -329,8 +326,7 @@ public class ChildrenRetriever { } access.printLine(cont); System.out.println( "\n" ); - for ( Enumeration> e = result.elements(); e.hasMoreElements(); ) { - Vector propsV = e.nextElement(); + for ( ArrayList propsV : result ) { access.printLine( propsV ); } } diff --git a/odk/examples/DevelopersGuide/UCB/PropertiesComposer.java b/odk/examples/DevelopersGuide/UCB/PropertiesComposer.java index 794502262ff2..19a11139bad8 100644 --- a/odk/examples/DevelopersGuide/UCB/PropertiesComposer.java +++ b/odk/examples/DevelopersGuide/UCB/PropertiesComposer.java @@ -32,7 +32,7 @@ * *************************************************************************/ -import java.util.Vector; +import java.util.ArrayList; import java.util.StringTokenizer; import com.sun.star.beans.PropertyValue; @@ -49,8 +49,8 @@ public class PropertiesComposer { private Helper m_helper; private XContent m_content; private String m_contenturl = ""; - private Vector m_propNames = new Vector(); - private Vector m_propValues = new Vector(); + private ArrayList m_propNames = new ArrayList(); + private ArrayList m_propValues = new ArrayList(); /** * Constructor. @@ -89,22 +89,22 @@ public class PropertiesComposer { */ public Object[] setProperties() throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception { - Vector properties = getProperties(); - Vector propertyValues = getPropertyValues(); + ArrayList properties = getProperties(); + ArrayList propertyValues = getPropertyValues(); return setProperties( properties, propertyValues ); } /** * Set values of the properties. * - *@param Vector Properties - *@param Vector Properties value + *@param properties + *@param propertiesValue *@return Object[] Returns null or instance object of com.sun.star.uno.Any * if values successfully seted, properties otherwise *@exception com.sun.star.ucb.CommandAbortedException *@exception com.sun.star.uno.Exception */ - public Object[] setProperties( Vector properties, Vector propertiesValues ) + public Object[] setProperties( ArrayList properties, ArrayList propertiesValues ) throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception { Object[] result = null; @@ -161,7 +161,7 @@ public class PropertiesComposer { * *@return Vector That contains the properties names */ - public Vector getProperties() { + public ArrayList getProperties() { return m_propNames; } @@ -170,7 +170,7 @@ public class PropertiesComposer { * *@return Vector That contains the properties values */ - public Vector getPropertyValues() { + public ArrayList getPropertyValues() { return m_propValues; } @@ -263,8 +263,8 @@ public class PropertiesComposer { try { PropertiesComposer setProp = new PropertiesComposer( args ); - Vector properties = setProp.getProperties(); - Vector propertiesValues = setProp.getPropertyValues(); + ArrayList properties = setProp.getProperties(); + ArrayList propertiesValues = setProp.getPropertyValues(); Object[] result = setProp.setProperties( properties, propertiesValues ); String tempPrint = "\nSetting properties of resource " + setProp.getContentURL(); diff --git a/odk/examples/DevelopersGuide/UCB/PropertiesRetriever.java b/odk/examples/DevelopersGuide/UCB/PropertiesRetriever.java index 49f0fa2a3604..002d5c4e6cc2 100644 --- a/odk/examples/DevelopersGuide/UCB/PropertiesRetriever.java +++ b/odk/examples/DevelopersGuide/UCB/PropertiesRetriever.java @@ -32,13 +32,13 @@ * *************************************************************************/ -import java.util.Vector; +import java.util.ArrayList; import java.util.StringTokenizer; import com.sun.star.beans.Property; +import com.sun.star.sdbc.XRow; import com.sun.star.ucb.XContent; import com.sun.star.uno.UnoRuntime; -import com.sun.star.sdbc.XRow; /** @@ -52,7 +52,7 @@ public class PropertiesRetriever { private Helper m_helper; private XContent m_content; private String m_contenturl = ""; - private Vector m_propNames = new Vector(); + private ArrayList m_propNames = new ArrayList(); /** * Constructor. @@ -87,9 +87,9 @@ public class PropertiesRetriever { *@exception com.sun.star.ucb.CommandAbortedException *@exception com.sun.star.uno.Exception */ - public Vector getPropertyValues() + public ArrayList getPropertyValues() throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception { - Vector properties = getProperties(); + ArrayList properties = getProperties(); return getPropertyValues ( properties ); } @@ -101,9 +101,9 @@ public class PropertiesRetriever { *@exception com.sun.star.ucb.CommandAbortedException *@exception com.sun.star.uno.Exception */ - public Vector getPropertyValues( Vector properties ) + public ArrayList getPropertyValues( ArrayList properties ) throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception { - Vector m_propValues = null; + ArrayList m_propValues = null; if ( m_content != null && properties != null && !properties.isEmpty() ) { int size = properties.size(); @@ -124,7 +124,7 @@ public class PropertiesRetriever { UnoRuntime.queryInterface( XRow.class, m_helper.executeCommand( m_content,"getPropertyValues", props )); - m_propValues = new Vector(); + m_propValues = new ArrayList(); /* Extract values from row object. Note that the @@ -155,7 +155,7 @@ public class PropertiesRetriever { * *@return Vector That contains the properties */ - public Vector getProperties() { + public ArrayList getProperties() { return m_propNames; } @@ -222,8 +222,8 @@ public class PropertiesRetriever { "--------------------------------------------------------------" ); try { PropertiesRetriever obtProperty = new PropertiesRetriever( args ); - Vector properties = obtProperty.getProperties(); - Vector propertiesValues = obtProperty.getPropertyValues( properties ); + ArrayList properties = obtProperty.getProperties(); + ArrayList propertiesValues = obtProperty.getPropertyValues( properties ); String tempPrint = "\nProperties of resource " + obtProperty.getContentURL(); int size = tempPrint.length(); diff --git a/odk/examples/java/EmbedDocument/EmbeddedObject/OwnEmbeddedObject.java b/odk/examples/java/EmbedDocument/EmbeddedObject/OwnEmbeddedObject.java index cdf3c290199e..b38bb8c3b56f 100644 --- a/odk/examples/java/EmbedDocument/EmbeddedObject/OwnEmbeddedObject.java +++ b/odk/examples/java/EmbedDocument/EmbeddedObject/OwnEmbeddedObject.java @@ -16,27 +16,25 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XComponentContext; -import com.sun.star.lang.XMultiComponentFactory; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.uno.AnyConverter; -import com.sun.star.lib.uno.helper.WeakBase; -import com.sun.star.io.XStream; -import com.sun.star.io.XOutputStream; +import java.awt.Dimension; +import java.util.ArrayList; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.embed.VisualRepresentation; +import com.sun.star.embed.XStorage; +import com.sun.star.embed.XTransactedObject; import com.sun.star.io.XInputStream; +import com.sun.star.io.XOutputStream; +import com.sun.star.io.XStream; import com.sun.star.io.XTruncate; -import com.sun.star.beans.XPropertySet; import com.sun.star.lang.XComponent; -import com.sun.star.embed.VisualRepresentation; -import com.sun.star.container.XNameAccess; - - -import com.sun.star.embed.*; - -import java.util.Vector; -import java.awt.Dimension; -import java.lang.Integer; +import com.sun.star.lang.XMultiComponentFactory; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lib.uno.helper.WeakBase; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; public final class OwnEmbeddedObject extends WeakBase implements com.sun.star.embed.XEmbedPersist, @@ -59,7 +57,7 @@ public final class OwnEmbeddedObject extends WeakBase protected EditorFrame m_aEditorFrame; - protected Vector m_aListeners; + protected ArrayList m_aListeners; com.sun.star.embed.VerbDescriptor[] m_pOwnVerbs; @@ -68,10 +66,10 @@ public final class OwnEmbeddedObject extends WeakBase Dimension m_aObjSize; // ------------------------------------------------------------- - protected Vector GetListeners() + protected ArrayList GetListeners() { if ( m_aListeners == null ) - m_aListeners = new Vector( 10, 10 ); + m_aListeners = new ArrayList(10); return m_aListeners; } diff --git a/odk/examples/java/Inspector/HideableTreeModel.java b/odk/examples/java/Inspector/HideableTreeModel.java index 44c208c8be3a..0184e24b8aed 100644 --- a/odk/examples/java/Inspector/HideableTreeModel.java +++ b/odk/examples/java/Inspector/HideableTreeModel.java @@ -18,15 +18,18 @@ import java.util.ArrayList; import java.util.Enumeration; -import java.util.Vector; -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.tree.*; + +import javax.swing.JTree; +import javax.swing.event.TreeModelEvent; +import javax.swing.event.TreeModelListener; +import javax.swing.tree.TreeModel; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; public class HideableTreeModel implements TreeModel { - private Vector modelListeners = new Vector(); + private ArrayList modelListeners = new ArrayList(); private Object root = null; @@ -72,12 +75,12 @@ public class HideableTreeModel implements TreeModel { public void addTreeModelListener(TreeModelListener l) { - modelListeners.addElement(l); + modelListeners.add(l); } public void removeTreeModelListener(TreeModelListener l) { - modelListeners.removeElement(l); + modelListeners.remove(l); } @@ -135,28 +138,28 @@ public class HideableTreeModel implements TreeModel { protected void fireTreeNodesChanged(TreeModelEvent event) { - for(int i = 0; i < modelListeners.size(); i++) { - modelListeners.elementAt(i).treeNodesChanged(event); + for(TreeModelListener l : modelListeners) { + l.treeNodesChanged(event); } } protected void fireTreeNodesInserted(TreeModelEvent event) { - for(int i = 0; i < modelListeners.size(); i++) { - modelListeners.elementAt(i).treeNodesInserted(event); + for(TreeModelListener l : modelListeners) { + l.treeNodesInserted(event); } } protected void fireTreeNodesRemoved(TreeModelEvent event) { - for(int i = 0; i < modelListeners.size(); i++) { - modelListeners.elementAt(i).treeNodesRemoved(event); + for(TreeModelListener l : modelListeners) { + l.treeNodesRemoved(event); } } protected void fireTreeStructureChanged(TreeModelEvent event) { - for(int i = 0; i < modelListeners.size(); i++) { - modelListeners.elementAt(i).treeStructureChanged(event); + for(TreeModelListener l : modelListeners) { + l.treeStructureChanged(event); } } diff --git a/odk/examples/java/Inspector/Inspector.java b/odk/examples/java/Inspector/Inspector.java index 3b5052d7041b..137a08019f70 100644 --- a/odk/examples/java/Inspector/Inspector.java +++ b/odk/examples/java/Inspector/Inspector.java @@ -32,6 +32,13 @@ * *************************************************************************/ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Set; + +import org.openoffice.XInstanceInspector; + import com.sun.star.awt.Rectangle; import com.sun.star.awt.XMessageBox; import com.sun.star.awt.XMessageBoxFactory; @@ -56,11 +63,6 @@ import com.sun.star.uno.XComponentContext; import com.sun.star.util.CloseVetoException; import com.sun.star.util.XChangesBatch; import com.sun.star.util.XCloseable; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Set; -import java.util.Vector; -import org.openoffice.XInstanceInspector; /** The purpose of this class is to provide a factory for creating the service @@ -79,7 +81,7 @@ public class Inspector{ static private final String __serviceName = "org.openoffice.InstanceInspector"; private HashMap aApplicationHashMap = new HashMap(); private String sTitle = "Object Inspector"; - private Vector aHiddenDocuments = new Vector(); + private ArrayList aHiddenDocuments = new ArrayList(); // private String[] sApplicationDocUrls = new String[]{"private:factory/swriter", "private:factory/scalc", "private:factory/simpress", "private:factory/sdraw", "private:factory/sbase"}; // private String[] sApplicationDocNames = new String[]{"Text Document", "Spreadsheet", "Presentation", "Drawing", "Database"}; private XComponentContext m_xComponentContext; diff --git a/odk/examples/java/Inspector/Introspector.java b/odk/examples/java/Inspector/Introspector.java index e8c80cf5c82d..79b90d4ef859 100644 --- a/odk/examples/java/Inspector/Introspector.java +++ b/odk/examples/java/Inspector/Introspector.java @@ -32,6 +32,9 @@ * *************************************************************************/ +import java.util.ArrayList; +import java.util.List; + import com.sun.star.beans.IllegalTypeException; import com.sun.star.beans.MethodConcept; import com.sun.star.beans.Property; @@ -66,8 +69,6 @@ import com.sun.star.uno.TypeClass; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; import com.sun.star.util.URL; -import java.util.List; -import java.util.Vector; public class Introspector extends WeakBase{ @@ -160,7 +161,7 @@ public class Introspector extends WeakBase{ public Object[] getUnoObjectsOfContainer(Object _oUnoParentObject) { Object[] oRetComponents = null; try { - Vector oRetComponentsVector = new Vector(); + ArrayList oRetComponentsVector = new ArrayList(); XIntrospectionAccess xIntrospectionAccessObject = getXIntrospectionAccess(_oUnoParentObject); if ( xIntrospectionAccessObject != null ) { XEnumerationAccess xEnumerationAccess = UnoRuntime.queryInterface(XEnumerationAccess.class, xIntrospectionAccessObject.queryAdapter( new Type( XEnumerationAccess.class ) ) ); @@ -260,7 +261,7 @@ public class Introspector extends WeakBase{ protected Property[] getProperties(Object _oUnoObject, String _sServiceName){ Property[] aProperties = getProperties(_oUnoObject); List aListOfProperties = java.util.Arrays.asList(aProperties); - Vector aPropertiesVector = new Vector(aListOfProperties); + ArrayList aPropertiesVector = new ArrayList(aListOfProperties); if (aProperties != null){ XPropertyTypeDescription[] xPropertyTypeDescriptions = getPropertyDescriptionsOfService(_sServiceName); for (int i = aProperties.length - 1; i >= 0; i--){ @@ -278,7 +279,7 @@ public class Introspector extends WeakBase{ protected Type[] getInterfaces(Object _oUnoObject, String _sServiceName){ Type[] aTypes = getInterfaces(_oUnoObject); List aListOfTypes = java.util.Arrays.asList(aTypes); - Vector aTypesVector = new Vector(aListOfTypes); + ArrayList aTypesVector = new ArrayList(aListOfTypes); if (aTypes != null){ XInterfaceTypeDescription[] xInterfaceTypeDescriptions = getInterfaceDescriptionsOfService(_sServiceName); for (int i = aTypes.length - 1; i >= 0; i--){ diff --git a/odk/examples/java/Inspector/MethodParametersDialog.java b/odk/examples/java/Inspector/MethodParametersDialog.java index 8a261b1d98b6..6a43c697ad0d 100644 --- a/odk/examples/java/Inspector/MethodParametersDialog.java +++ b/odk/examples/java/Inspector/MethodParametersDialog.java @@ -32,15 +32,13 @@ * *************************************************************************/ -import com.sun.star.reflection.ParamInfo; -import com.sun.star.reflection.XIdlMethod; -import com.sun.star.uno.TypeClass; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; -import java.util.Vector; +import java.util.ArrayList; + import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; @@ -49,6 +47,10 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import com.sun.star.reflection.ParamInfo; +import com.sun.star.reflection.XIdlMethod; +import com.sun.star.uno.TypeClass; + public class MethodParametersDialog extends JDialog{ private javax.swing.JPanel jPnlParamContainer; private ParameterPanel[] m_aParameterPanels; @@ -76,7 +78,7 @@ public class MethodParametersDialog extends JDialog{ } - public Vector getMethodObjects() { + public ArrayList getMethodObjects() { super.setModal(true); addBorderPanel(getContentPane(), BorderLayout.NORTH); addBorderPanel(getContentPane(), BorderLayout.WEST); @@ -105,7 +107,7 @@ public class MethodParametersDialog extends JDialog{ m_aParameterPanels[0].getInputComponent().requestFocusInWindow(); setVisible(true); if (!bisdiposed){ - Vector aMethodObjects = new Vector(); + ArrayList aMethodObjects = new ArrayList(); for (int i = 0; i < m_aParameterPanels.length; i++){ aMethodObjects.add(m_aParameterPanels[i].getValue()); } diff --git a/odk/examples/java/Inspector/SourceCodeGenerator.java b/odk/examples/java/Inspector/SourceCodeGenerator.java index 45431bd86f38..4e6f3bc30115 100644 --- a/odk/examples/java/Inspector/SourceCodeGenerator.java +++ b/odk/examples/java/Inspector/SourceCodeGenerator.java @@ -32,6 +32,10 @@ * *************************************************************************/ +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.Hashtable; + import com.sun.star.reflection.ParamInfo; import com.sun.star.reflection.XIdlClass; import com.sun.star.reflection.XIdlMethod; @@ -40,15 +44,12 @@ import com.sun.star.uno.Any; import com.sun.star.uno.AnyConverter; import com.sun.star.uno.Type; import com.sun.star.uno.TypeClass; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Vector; public class SourceCodeGenerator { - private Vector sExceptions = new Vector(); - Vector sHeaderStatements = new HeaderStatements(); + private ArrayList sExceptions = new ArrayList(); + ArrayList sHeaderStatements = new HeaderStatements(); private XLanguageSourceCodeGenerator m_xLanguageSourceCodeGenerator; private String sHeaderCode = ""; private String sStatementCode = ""; @@ -61,7 +62,7 @@ public class SourceCodeGenerator { private final String SUNOOBJECTNAME = "oUnobject"; private final String SUNOSTRUCTNAME = "aUnoStruct"; private Introspector m_oIntrospector; - private Vector aTreepathProviders = new Vector(); + private ArrayList aTreepathProviders = new ArrayList(); private XTreePathProvider xTreepathProvider = null; private boolean baddExceptionHandling = false; private boolean bXPropertySetExceptionsAreAdded = false; @@ -361,7 +362,7 @@ public class SourceCodeGenerator { } - private class HeaderStatements extends Vector { + private class HeaderStatements extends ArrayList { public boolean contains(String _oElement){ String sCompName = _oElement; diff --git a/odk/examples/java/Inspector/SwingUnoMethodNode.java b/odk/examples/java/Inspector/SwingUnoMethodNode.java index 3f67de3a2096..92bebe505e1c 100644 --- a/odk/examples/java/Inspector/SwingUnoMethodNode.java +++ b/odk/examples/java/Inspector/SwingUnoMethodNode.java @@ -31,11 +31,12 @@ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *************************************************************************/ -import com.sun.star.reflection.XIdlMethod; -import com.sun.star.uno.TypeClass; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.Vector; +import java.util.ArrayList; + +import com.sun.star.reflection.XIdlMethod; +import com.sun.star.uno.TypeClass; @@ -120,7 +121,7 @@ public class SwingUnoMethodNode extends SwingUnoNode implements ActionListener, openIdlDescription(m_xDialogProvider.getIDLPath()); } - public Vector getMethodObjects(){ + public ArrayList getMethodObjects(){ MethodParametersDialog oMethodParametersDialog = new MethodParametersDialog(this); oMethodParametersDialog.addActionListener(this); return oMethodParametersDialog.getMethodObjects(); diff --git a/odk/examples/java/Inspector/UnoMethodNode.java b/odk/examples/java/Inspector/UnoMethodNode.java index c02261f5efe3..69bb58e4d2d9 100644 --- a/odk/examples/java/Inspector/UnoMethodNode.java +++ b/odk/examples/java/Inspector/UnoMethodNode.java @@ -37,7 +37,6 @@ import com.sun.star.reflection.ParamMode; import com.sun.star.reflection.XIdlClass; import com.sun.star.reflection.XIdlMethod; import com.sun.star.uno.TypeClass; -import java.util.Vector; public class UnoMethodNode extends UnoNode{ XIdlMethod m_xIdlMethod = null; @@ -93,7 +92,7 @@ public class UnoMethodNode extends UnoNode{ m_bisInvoked = true; } else{ - Vector oUnoMethodObjects = m_xUnoMethodNode.getMethodObjects(); + java.util.List oUnoMethodObjects = m_xUnoMethodNode.getMethodObjects(); if (oUnoMethodObjects != null){ for (int i = 0; i < getXIdlMethod().getParameterInfos().length; i++){ this.m_oParamObjects[i] = oUnoMethodObjects.get(i); diff --git a/odk/examples/java/Inspector/UnoNode.java b/odk/examples/java/Inspector/UnoNode.java index dac2e82ed58d..76592251405f 100644 --- a/odk/examples/java/Inspector/UnoNode.java +++ b/odk/examples/java/Inspector/UnoNode.java @@ -32,6 +32,9 @@ * *************************************************************************/ +import java.util.ArrayList; +import java.util.List; + import com.sun.star.beans.PropertyValue; import com.sun.star.frame.FrameSearchFlag; import com.sun.star.frame.XDesktop; @@ -52,8 +55,6 @@ import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; import com.sun.star.util.URL; import com.sun.star.util.XURLTransformer; -import java.util.List; -import java.util.Vector; public class UnoNode{ @@ -270,7 +271,7 @@ public class UnoNode{ private static String[] removeMandatoryServiceNames(String[] _sServiceNames){ try{ List aList = java.util.Arrays.asList(_sServiceNames); - Vector aVector = new Vector(aList); + ArrayList aVector = new ArrayList(aList); for (int n = 0; n < _sServiceNames.length; n++){ String[] sDelServiceNames = getMandatoryServiceNames(_sServiceNames[n]); for (int m = 0; m < sDelServiceNames.length; m++){ diff --git a/odk/examples/java/Inspector/XUnoMethodNode.java b/odk/examples/java/Inspector/XUnoMethodNode.java index eee0cb023a18..c0186f5e99b7 100644 --- a/odk/examples/java/Inspector/XUnoMethodNode.java +++ b/odk/examples/java/Inspector/XUnoMethodNode.java @@ -34,7 +34,6 @@ import com.sun.star.reflection.XIdlMethod; import com.sun.star.uno.TypeClass; -import java.util.Vector; public interface XUnoMethodNode extends XUnoNode { @@ -59,7 +58,7 @@ public interface XUnoMethodNode extends XUnoNode { public boolean isPrimitive(); - public Vector getMethodObjects(); + public java.util.List getMethodObjects(); public boolean isFoldable(); diff --git a/odk/examples/java/ToDo/ToDo.java b/odk/examples/java/ToDo/ToDo.java index fa457156978a..71854936f895 100644 --- a/odk/examples/java/ToDo/ToDo.java +++ b/odk/examples/java/ToDo/ToDo.java @@ -32,37 +32,37 @@ * *************************************************************************/ -import com.sun.star.lib.uno.helper.Factory; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.GregorianCalendar; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; import com.sun.star.lang.XMultiComponentFactory; -import com.sun.star.lang.XSingleComponentFactory; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lang.XServiceInfo; +import com.sun.star.lang.XSingleComponentFactory; +import com.sun.star.lib.uno.helper.Factory; import com.sun.star.lib.uno.helper.WeakBase; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XComponentContext; -// addintional interfaces used by the implementation -import com.sun.star.sheet.XSpreadsheetDocument; -import com.sun.star.sheet.XSpreadsheet; import com.sun.star.sheet.XCellRangeMovement; import com.sun.star.sheet.XFunctionAccess; -import com.sun.star.container.XIndexAccess; -import com.sun.star.table.XCellRange; -import com.sun.star.table.XCell; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; import com.sun.star.table.CellAddress; import com.sun.star.table.CellRangeAddress; +import com.sun.star.table.XCell; +import com.sun.star.table.XCellRange; import com.sun.star.table.XColumnRowRange; import com.sun.star.table.XTableRows; -import com.sun.star.beans.XPropertySet; -import com.sun.star.text.XTextRange; import com.sun.star.text.XSimpleText; -import com.sun.star.text.XTextCursor; import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; import com.sun.star.text.XTextField; - -import java.util.GregorianCalendar; -import java.util.Calendar; -import java.util.Vector; -import java.util.Arrays; +import com.sun.star.text.XTextRange; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +// addintional interfaces used by the implementation /** This class capsulates the class, that implements the minimal component, a * factory for creating the service (__getServiceFactory) and a @@ -208,7 +208,7 @@ public class ToDo { objectFunctionAccess ); // Creating vector for holidays - Vector vectorHolidays = new Vector(); + ArrayList vectorHolidays = new ArrayList(); // Get the Official Holidays this.getOfficialHolidays( vectorHolidays, xcellrange, @@ -706,7 +706,7 @@ public class ToDo { * @param intYear Year to calculate the official holidays. */ public void getOfficialHolidays( - Vector vectorHolidays, + ArrayList vectorHolidays, XCellRange xcellrange, XFunctionAccess xfunctionaccess, int intYear ) { @@ -729,7 +729,7 @@ public class ToDo { dEasterSunday.doubleValue()); // New-year - vectorHolidays.addElement( xfunctionaccess.callFunction( + vectorHolidays.add( xfunctionaccess.callFunction( "DATE", new Object[] { new Integer( intYear ), @@ -737,15 +737,15 @@ public class ToDo { new Integer( 1 ) } )); // Good Friday - vectorHolidays.addElement( + vectorHolidays.add( new Double( intEasterSunday - 2 ) ); // Easter monday - vectorHolidays.addElement( + vectorHolidays.add( new Double( intEasterSunday + 1 ) ); // Labour Day - vectorHolidays.addElement( xfunctionaccess.callFunction( + vectorHolidays.add( xfunctionaccess.callFunction( "DATE", new Object[] { new Integer( intYear ), @@ -753,13 +753,13 @@ public class ToDo { new Integer( 1 ) } )); // Ascension Day - vectorHolidays.addElement(new Double(intEasterSunday + 39 )); + vectorHolidays.add(new Double(intEasterSunday + 39 )); // Pentecost monday - vectorHolidays.addElement(new Double(intEasterSunday + 50 )); + vectorHolidays.add(new Double(intEasterSunday + 50 )); // German Unification - vectorHolidays.addElement( xfunctionaccess.callFunction( + vectorHolidays.add( xfunctionaccess.callFunction( "DATE", new Object[] { new Integer( intYear ), @@ -767,7 +767,7 @@ public class ToDo { new Integer( 3 ) } )); // Christmas Day First - vectorHolidays.addElement( xfunctionaccess.callFunction( + vectorHolidays.add( xfunctionaccess.callFunction( "DATE", new Object[] { new Integer( intYear ), @@ -775,7 +775,7 @@ public class ToDo { new Integer( 25 ) } )); // Christmas Day Second - vectorHolidays.addElement( xfunctionaccess.callFunction( + vectorHolidays.add( xfunctionaccess.callFunction( "DATE", new Object[] { new Integer( intYear ), @@ -841,7 +841,7 @@ public class ToDo { * @param xcellrange Providing the cells. * @param xfunctionaccess Provides the access to functions of the Calc. */ - public void getPrivateHolidays( Vector vectorHolidays, + public void getPrivateHolidays( ArrayList vectorHolidays, XCellRange xcellrange, XFunctionAccess xfunctionaccess ) { try { @@ -856,7 +856,7 @@ public class ToDo { while ( dHolidayStart != 0 ) { if ( dHolidayEnd == 0 ) { - vectorHolidays.addElement( + vectorHolidays.add( new Integer( (int) Math.round( dHolidayStart ) ) ); } @@ -865,7 +865,7 @@ public class ToDo { dHolidayStart ); intHoliday <= (int) Math.round( dHolidayEnd ); intHoliday++ ) { - vectorHolidays.addElement( new Double( intHoliday ) ); + vectorHolidays.add( new Double( intHoliday ) ); } } -- cgit