summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-09-07 10:17:58 +0200
committerMichael Stahl <mstahl@redhat.com>2012-09-10 23:43:38 +0200
commitb89ae706c2b959dd41e821abc2efe1d4ba79de81 (patch)
tree03224d32d8ad6ffe76d29cb23c498ed773bc30f6
parentef0e7694b884d3cd86295b733028101cc4713fa1 (diff)
Java cleanup, generic and simplify
The code here is passing stuff around in lists of Object, but even so, it was doing so in a very convoluted way. Change-Id: I608a066138bde2b659a52f6e6148ac754f75ac74
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IOnewayLink.java2
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java16
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java51
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java4
4 files changed, 35 insertions, 38 deletions
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IOnewayLink.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IOnewayLink.java
index 99c26e7c9f40..14a1018bbdf8 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<Object> lParams );
}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java
index 4c8626a7d2ef..7b2aa68a8e96 100644
--- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java
@@ -162,7 +162,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<Object> lParams )
{
synchronized(this)
{
@@ -181,11 +181,9 @@ public class Interceptor implements com.sun.star.frame.XFrameActionListener,
{
com.sun.star.util.URL[] lOutURL = new com.sun.star.util.URL[1];
com.sun.star.beans.PropertyValue[][] lOutProps = new com.sun.star.beans.PropertyValue[1][];
- Vector[] lInParams = new Vector[1];
- lInParams[0] = lParams;
- OnewayExecutor.codeDispatch( OnewayExecutor.DECODE_PARAMS ,
- lInParams ,
+ OnewayExecutor.decodeDispatch(
+ lParams ,
lOutURL ,
lOutProps );
impl_dispatch(lOutURL[0],lOutProps[0]);
@@ -238,7 +236,7 @@ public class Interceptor implements com.sun.star.frame.XFrameActionListener,
return;
// pack the event and start thread - which call us back later
- Vector<FrameActionEvent> lOutParams = new Vector<FrameActionEvent>();
+ Vector<Object> lOutParams = new Vector<Object>();
lOutParams.add(aEvent);
OnewayExecutor aExecutor = new OnewayExecutor( (IOnewayLink)this ,
@@ -271,19 +269,17 @@ public class Interceptor implements com.sun.star.frame.XFrameActionListener,
return;
}
- Vector[] lOutParams = new Vector[1];
com.sun.star.util.URL[] lInURL = new com.sun.star.util.URL[1];
com.sun.star.beans.PropertyValue[][] lInArguments = new com.sun.star.beans.PropertyValue[1][];
lInURL[0] = aURL ;
lInArguments[0] = lArguments;
- OnewayExecutor.codeDispatch( OnewayExecutor.ENCODE_PARAMS ,
- lOutParams ,
+ Vector<Object> lOutParams = OnewayExecutor.encodeDispatch(
lInURL ,
lInArguments );
OnewayExecutor aExecutor = new OnewayExecutor( (IOnewayLink)this ,
OnewayExecutor.REQUEST_DISPATCH ,
- lOutParams[0] );
+ lOutParams );
aExecutor.start();
}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java
index 4250cfe08ea2..54b58309538e 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<Object> m_lParams ;
// _______________________________
@@ -103,7 +103,7 @@ class OnewayExecutor extends Thread
*/
public OnewayExecutor( IOnewayLink rLink ,
int nRequest ,
- Vector<?> lParams )
+ Vector<Object> lParams )
{
m_rLink = rLink ;
m_nRequest = nRequest;
@@ -138,48 +138,49 @@ class OnewayExecutor extends Thread
/**
* static helper!
- * To make convertion of the generic parameter list to the original
- * one easier - you can use this helper methods. They know how suchlist
+ * To make conversion of the generic parameter list to the original
+ * one easier - you can use this helper methods. They know how such list
* must be coded. It's not a must to use it - but you can ...
*/
// _______________________________
- public static void codeDispatch(
- boolean bEncode, Vector[] lParams,
+ public static Vector<Object> encodeDispatch(
com.sun.star.util.URL[] aURL,
com.sun.star.beans.PropertyValue[][] lArgs)
{
- if (bEncode)
- {
- int nLength = lArgs.length+1;
- int nPos = 0;
- lParams[0] = new Vector<Object>(nLength);
+ int nLength = lArgs.length+1;
+ int nPos = 0;
+ Vector<Object> lParams = new Vector<Object>(nLength);
- lParams[0].add( (Object)aURL[0] );
- --nLength;
+ lParams.add( aURL[0] );
+ --nLength;
- while (nLength>0)
- {
- lParams[0].add( (Object)lArgs[0][nPos] );
- --nLength;
- ++nPos ;
- }
- }
- else
+ while (nLength>0)
{
- int nLength = lParams[0].size()-1;
+ lParams.add( lArgs[0][nPos] );
+ --nLength;
+ ++nPos ;
+ }
+ return lParams;
+ }
+
+ public static void decodeDispatch(
+ Vector<Object> lParams,
+ com.sun.star.util.URL[] aURL,
+ com.sun.star.beans.PropertyValue[][] lArgs)
+ {
+ int nLength = lParams.size()-1;
int nPos = 0;
lArgs[0] = new com.sun.star.beans.PropertyValue[nLength];
- aURL[0] = (com.sun.star.util.URL)(lParams[0].elementAt(0));
+ aURL[0] = (com.sun.star.util.URL) lParams.elementAt(0);
while (nPos<nLength)
{
lArgs[0][nPos] = (com.sun.star.beans.PropertyValue)
- (lParams[0].elementAt(nPos+1));
+ (lParams.elementAt(nPos+1));
++nPos;
}
- }
}
}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java
index 753249d4ab09..b6dec65544a4 100644
--- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java
@@ -167,7 +167,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<Object> lParams )
{
synchronized(this)
{
@@ -214,7 +214,7 @@ class StatusListener implements com.sun.star.frame.XStatusListener,
if (! bHandle)
return;
- Vector<FrameActionEvent> lOutParams = new Vector<FrameActionEvent>();
+ Vector<Object> lOutParams = new Vector<Object>();
lOutParams.add(aEvent);
OnewayExecutor aExecutor = new OnewayExecutor( (IOnewayLink)this ,