diff options
author | Noel Grandin <noel@peralex.com> | 2012-09-07 09:42:15 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-09-10 23:43:37 +0200 |
commit | a5ff5aad59bbe70cfaa0b18ec9df6f787a7160ca (patch) | |
tree | 6313b316dc96b82e5cafec866631d15b01a04e52 /odk/examples/DevelopersGuide | |
parent | e3d9ff3fd0b753a6712e86703e5f69392d241508 (diff) |
Java5 update, Convert ArrayList and Vector code to use generics
Change-Id: I6cf6fa8e55005ffdc1d173aeee1e374efbb214fd
Diffstat (limited to 'odk/examples/DevelopersGuide')
13 files changed, 68 insertions, 68 deletions
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IOnewayLink.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IOnewayLink.java index 7127cd8043a8..99c26e7c9f40 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IOnewayLink.java +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IOnewayLink.java @@ -65,5 +65,5 @@ public interface IOnewayLink * Note: Atomic types (e.g. int, long) will be transported as objects * too (Integer, Long)! */ - public abstract void execOneway( int nRequest, Vector lParams ); + public abstract void execOneway( int nRequest, Vector<?> lParams ); } diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java index 66ab24d41512..42d01cf1e679 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java @@ -161,7 +161,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*/ Vector<?> lParams ) { synchronized(this) { @@ -338,7 +338,7 @@ public class Interceptor implements com.sun.star.frame.XFrameActionListener, xFrame = m_xFrame; } - com.sun.star.frame.XDispatchProviderInterception xRegistration = (com.sun.star.frame.XDispatchProviderInterception)UnoRuntime.queryInterface( + com.sun.star.frame.XDispatchProviderInterception xRegistration = UnoRuntime.queryInterface( com.sun.star.frame.XDispatchProviderInterception.class, xFrame); @@ -650,7 +650,7 @@ public class Interceptor implements com.sun.star.frame.XFrameActionListener, if (bIsRegistered) { - com.sun.star.frame.XDispatchProviderInterception xRegistration = (com.sun.star.frame.XDispatchProviderInterception)UnoRuntime.queryInterface( + com.sun.star.frame.XDispatchProviderInterception xRegistration = UnoRuntime.queryInterface( com.sun.star.frame.XDispatchProviderInterception.class, xFrame); diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java index 132ee897e2be..c549c4883a73 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java @@ -77,7 +77,7 @@ class OnewayExecutor extends Thread */ private IOnewayLink m_rLink ; private int m_nRequest ; - private Vector m_lParams ; + private Vector<?> m_lParams ; // _______________________________ @@ -103,7 +103,7 @@ class OnewayExecutor extends Thread */ public OnewayExecutor( IOnewayLink rLink , int nRequest , - Vector lParams ) + Vector<?> lParams ) { m_rLink = rLink ; m_nRequest = nRequest; @@ -148,7 +148,7 @@ class OnewayExecutor extends Thread { if (bEncode) { - lParams[0] = new Vector(1); + lParams[0] = new Vector<Object>(1); lParams[0].add( (Object)(aAction[0]) ); } else @@ -166,7 +166,7 @@ class OnewayExecutor extends Thread { if (bEncode) { - lParams[0] = new Vector(1); + lParams[0] = new Vector<Object>(1); lParams[0].add( (Object)aStatus[0] ); } else @@ -185,7 +185,7 @@ class OnewayExecutor extends Thread { if (bEncode) { - lParams[0] = new Vector(2); + lParams[0] = new Vector<Object>(2); lParams[0].add( (Object)xListener[0] ); lParams[0].add( (Object)aURL[0] ); } @@ -208,7 +208,7 @@ class OnewayExecutor extends Thread { int nLength = lArgs.length+1; int nPos = 0; - lParams[0] = new Vector(nLength); + lParams[0] = new Vector<Object>(nLength); lParams[0].add( (Object)aURL[0] ); --nLength; diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java index 5bb20d3fe149..ac5d429ba08a 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java @@ -166,7 +166,7 @@ class StatusListener implements com.sun.star.frame.XStatusListener, * @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*/ Vector<?> lParams ) { synchronized(this) { diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java index 451593f9a634..fb3e675820ae 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java @@ -75,8 +75,8 @@ public class ViewContainer extends Thread */ private ViewContainer() { - mlViews = new Vector(); - mlListener = new Vector(); + mlViews = new Vector<Object>(); + mlListener = new Vector<IShutdownListener>(); mbShutdownActive = false ; Runtime.getRuntime().addShutdownHook(this); } @@ -259,7 +259,7 @@ public class ViewContainer extends Thread */ public static boolean mbInplace = false ; private static ViewContainer maSingleton = null ; - private Vector mlViews ; - private Vector mlListener ; + private Vector<Object> mlViews ; + private Vector<IShutdownListener> mlListener ; private boolean mbShutdownActive ; } diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper.java index 87b1ea3b5b3b..498a8919b20c 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper.java +++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper.java @@ -50,7 +50,7 @@ public class PropChgHelper implements XInterface xEvtSource; String[] aPropNames; XPropertySet xPropSet; - ArrayList aLngSvcEvtListeners; + ArrayList<XLinguServiceEventListener> aLngSvcEvtListeners; public PropChgHelper( XInterface xEvtSource, @@ -59,7 +59,7 @@ public class PropChgHelper implements this.xEvtSource = xEvtSource; this.aPropNames = aPropNames; xPropSet = null; - aLngSvcEvtListeners = new ArrayList(); + aLngSvcEvtListeners = new ArrayList<XLinguServiceEventListener>(); } public XInterface GetEvtSource() diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java index 8008fcd5affd..e28fe57a8dd7 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java +++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java @@ -77,7 +77,7 @@ public class SampleHyphenator extends ComponentBase implements XServiceInfo { PropChgHelper_Hyph aPropChgHelper; - ArrayList aEvtListeners; + ArrayList<?> aEvtListeners; boolean bDisposing; public SampleHyphenator() @@ -93,7 +93,7 @@ public class SampleHyphenator extends ComponentBase implements "HyphMinWordLength" }; aPropChgHelper = new PropChgHelper_Hyph( (XHyphenator) this, aProps ); - aEvtListeners = new ArrayList();; + aEvtListeners = new ArrayList<Object>();; bDisposing = false; } diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java index 6d28867a3e1d..e7dd243c6dc2 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java +++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java @@ -77,7 +77,7 @@ public class SampleSpellChecker extends ComponentBase implements XServiceInfo { PropChgHelper_Spell aPropChgHelper; - ArrayList aEvtListeners; + ArrayList<?> aEvtListeners; boolean bDisposing; public SampleSpellChecker() @@ -93,7 +93,7 @@ public class SampleSpellChecker extends ComponentBase implements "IsSpellCapitalization" }; aPropChgHelper = new PropChgHelper_Spell( (XSpellChecker) this, aProps ); - aEvtListeners = new ArrayList(); + aEvtListeners = new ArrayList<Object>(); bDisposing = false; } diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java index fd56a5683882..824ed09a0562 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java +++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java @@ -72,7 +72,7 @@ public class SampleThesaurus extends ComponentBase implements XServiceInfo { PropChgHelper aPropChgHelper; - ArrayList aEvtListeners; + ArrayList<?> aEvtListeners; boolean bDisposing; public SampleThesaurus() @@ -91,7 +91,7 @@ public class SampleThesaurus extends ComponentBase implements // 'GetValueToUse' function aPropChgHelper = new PropChgHelper( (XThesaurus) this, aProps ); - aEvtListeners = new ArrayList(); + aEvtListeners = new ArrayList<Object>(); bDisposing = false; } diff --git a/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java b/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java index 8c827d0cc2f8..b7299d16595b 100644 --- a/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java +++ b/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java @@ -50,8 +50,8 @@ class ExampleSettings } public int nMemberCount = 3; - public java.util.List aColDimensions = new java.util.ArrayList(); - public java.util.List aRowDimensions = new java.util.ArrayList(); + public java.util.List<Integer> aColDimensions = new java.util.ArrayList<Integer>(); + public java.util.List<Integer> aRowDimensions = new java.util.ArrayList<Integer>(); } // XPropertySetInfo implementation for getPropertySetInfo @@ -839,7 +839,7 @@ public class ExampleDataPilotSource int nRowResult = 0; for (int nRowDim=0; nRowDim<nRowDimCount; nRowDim++) { - int nDim = ((Integer)aSettings.aRowDimensions.get(nRowDimCount-nRowDim-1)).intValue(); + int nDim = aSettings.aRowDimensions.get(nRowDimCount-nRowDim-1).intValue(); nRowResult += ( nRowVal % nMemberCount ) * nDigits[nDim]; nRowVal /= nMemberCount; } @@ -851,7 +851,7 @@ public class ExampleDataPilotSource int nResult = nRowResult; for (int nColDim=0; nColDim<nColDimCount; nColDim++) { - int nDim = ((Integer)aSettings.aColDimensions.get(nColDimCount-nColDim-1)).intValue(); + int nDim = aSettings.aColDimensions.get(nColDimCount-nColDim-1).intValue(); nResult += ( nColVal % nMemberCount ) * nDigits[nDim]; nColVal /= nMemberCount; } diff --git a/odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java b/odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java index 24d627111f38..f33e71d4cfd5 100644 --- a/odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java +++ b/odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java @@ -57,7 +57,7 @@ public class ChildrenRetriever { private Helper m_helper; private XContent m_content; private String m_contenturl = ""; - private Vector m_propnames = new Vector(); + private Vector<String> m_propnames = new Vector<String>(); /** * Constructor. Create a new connection with the specific args to a running office @@ -92,9 +92,9 @@ public class ChildrenRetriever { *@exception com.sun.star.ucb.CommandAbortedException *@exception com.sun.star.uno.Exception */ - public Vector getChildren() + public Vector<Vector<Object>> getChildren() throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception { - Vector properties = getProperties(); + Vector<String> properties = getProperties(); return getChildren ( properties ); } @@ -107,10 +107,10 @@ public class ChildrenRetriever { *@exception com.sun.star.ucb.CommandAbortedException *@exception com.sun.star.uno.Exception */ - public Vector getChildren( Vector properties ) + public Vector<Vector<Object>> getChildren( Vector<String> properties ) throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception { - Vector result = null; + Vector<Vector<Object>> result = null; if ( m_content != null ) { int size = 0; if ( properties != null && !properties.isEmpty()) { @@ -122,7 +122,7 @@ public class ChildrenRetriever { // Define property sequence. Property prop = new Property(); - prop.Name = ( String )properties.get( index ); + prop.Name = properties.get( index ); prop.Handle = -1; // n/a props[ index ] = prop; } @@ -136,11 +136,11 @@ public class ChildrenRetriever { XDynamicResultSet set; // Execute command "open". - set = ( XDynamicResultSet )UnoRuntime.queryInterface( + set = UnoRuntime.queryInterface( XDynamicResultSet.class, m_helper.executeCommand( m_content, "open", arg )); XResultSet resultSet = ( XResultSet )set.getStaticResultSet(); - result = new Vector(); + result = new Vector<Vector<Object>>(); ///////////////////////////////////////////////////////////////////// // Iterate over children, access children and property values... @@ -148,12 +148,12 @@ public class ChildrenRetriever { // Move to begin. if ( resultSet.first() ) { - XContentAccess contentAccess = ( XContentAccess )UnoRuntime.queryInterface( + XContentAccess contentAccess = UnoRuntime.queryInterface( XContentAccess.class, resultSet ); - XRow row = ( XRow )UnoRuntime.queryInterface( XRow.class, resultSet ); + XRow row = UnoRuntime.queryInterface( XRow.class, resultSet ); do { - Vector propsValues = new Vector(); + Vector<Object> propsValues = new Vector<Object>(); // Obtain URL of child. String id = contentAccess.queryContentIdentifierString(); @@ -187,7 +187,7 @@ public class ChildrenRetriever { * *@return String That contains the properties */ - public Vector getProperties() { + public Vector<String> getProperties() { return m_propnames; } @@ -243,7 +243,7 @@ public class ChildrenRetriever { * *@param Vector */ - public void printLine( Vector props ) { + public void printLine( Vector<Object> props ) { int limit; while ( !props.isEmpty() ) { String print = ""; @@ -305,7 +305,7 @@ public class ChildrenRetriever { ChildrenRetriever access = new ChildrenRetriever( args ); // Get the properties Title and IsFolder for the children. - Vector result = access.getChildren(); + Vector<Vector<Object>> result = access.getChildren(); String tempPrint = "\nChildren of resource " + access.getContentURL(); int size = tempPrint.length(); @@ -318,9 +318,9 @@ public class ChildrenRetriever { if ( result != null && !result.isEmpty() ) { - Vector cont = new Vector(); + Vector<Object> cont = new Vector<Object>(); cont.add("URL:"); - Vector props = access.getProperties(); + Vector<String> props = access.getProperties(); size = props.size(); for ( int i = 0; i < size; i++ ) { Object obj = props.get( i ); @@ -329,8 +329,8 @@ public class ChildrenRetriever { } access.printLine(cont); System.out.println( "\n" ); - for ( Enumeration e = result.elements(); e.hasMoreElements(); ) { - Vector propsV = ( Vector )e.nextElement(); + for ( Enumeration<Vector<Object>> e = result.elements(); e.hasMoreElements(); ) { + Vector<Object> propsV = e.nextElement(); access.printLine( propsV ); } } diff --git a/odk/examples/DevelopersGuide/UCB/PropertiesComposer.java b/odk/examples/DevelopersGuide/UCB/PropertiesComposer.java index 739ba7b2e687..794502262ff2 100644 --- a/odk/examples/DevelopersGuide/UCB/PropertiesComposer.java +++ b/odk/examples/DevelopersGuide/UCB/PropertiesComposer.java @@ -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 Vector<String> m_propNames = new Vector<String>(); + private Vector<String> m_propValues = new Vector<String>(); /** * Constructor. @@ -89,8 +89,8 @@ public class PropertiesComposer { */ public Object[] setProperties() throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception { - Vector properties = getProperties(); - Vector propertyValues = getPropertyValues(); + Vector<String> properties = getProperties(); + Vector<String> propertyValues = getPropertyValues(); return setProperties( properties, propertyValues ); } @@ -104,7 +104,7 @@ public class PropertiesComposer { *@exception com.sun.star.ucb.CommandAbortedException *@exception com.sun.star.uno.Exception */ - public Object[] setProperties( Vector properties, Vector propertiesValues ) + public Object[] setProperties( Vector<String> properties, Vector<String> propertiesValues ) throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception { Object[] result = null; @@ -127,7 +127,7 @@ public class PropertiesComposer { int size = properties.size(); PropertyValue[] props = new PropertyValue[ size ]; for ( int index = 0 ; index < size; index++ ) { - String propName = ( String )properties.get( index ); + String propName = properties.get( index ); Object propValue = propertiesValues.get( index ); /* @@ -161,7 +161,7 @@ public class PropertiesComposer { * *@return Vector That contains the properties names */ - public Vector getProperties() { + public Vector<String> getProperties() { return m_propNames; } @@ -170,7 +170,7 @@ public class PropertiesComposer { * *@return Vector That contains the properties values */ - public Vector getPropertyValues() { + public Vector<String> 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(); + Vector<String> properties = setProp.getProperties(); + Vector<String> 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 2d000c1a3b90..49f0fa2a3604 100644 --- a/odk/examples/DevelopersGuide/UCB/PropertiesRetriever.java +++ b/odk/examples/DevelopersGuide/UCB/PropertiesRetriever.java @@ -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 Vector<String> m_propNames = new Vector<String>(); /** * Constructor. @@ -87,9 +87,9 @@ public class PropertiesRetriever { *@exception com.sun.star.ucb.CommandAbortedException *@exception com.sun.star.uno.Exception */ - public Vector getPropertyValues() + public Vector<Object> getPropertyValues() throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception { - Vector properties = getProperties(); + Vector<String> 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 Vector<Object> getPropertyValues( Vector<String> properties ) throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception { - Vector m_propValues = null; + Vector<Object> m_propValues = null; if ( m_content != null && properties != null && !properties.isEmpty() ) { int size = properties.size(); @@ -114,17 +114,17 @@ public class PropertiesRetriever { // Define property sequence. Property prop = new Property(); - prop.Name = ( String )properties.get( index ); + prop.Name = properties.get( index ); prop.Handle = -1; // n/a props[ index ] = prop; } // Execute command "getPropertyValues". XRow values = - ( XRow )UnoRuntime.queryInterface( - XRow.class, m_helper.executeCommand( m_content,"getPropertyValues", props )); + UnoRuntime.queryInterface( + XRow.class, m_helper.executeCommand( m_content,"getPropertyValues", props )); - m_propValues = new Vector(); + m_propValues = new Vector<Object>(); /* 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 Vector<String> 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 ); + Vector<String> properties = obtProperty.getProperties(); + Vector<Object> propertiesValues = obtProperty.getPropertyValues( properties ); String tempPrint = "\nProperties of resource " + obtProperty.getContentURL(); int size = tempPrint.length(); @@ -237,7 +237,7 @@ public class PropertiesRetriever { if ( properties != null && propertiesValues != null ) { size = properties.size(); for (int index = 0; index < size ; index++ ) { - String property = ( String )properties.get( index ); + String property = properties.get( index ); Object propValue = propertiesValues.get( index ); System.out.println( property + " : " + propValue ); } |