diff options
Diffstat (limited to 'kdejava/koala/org/kde/koala/Invocation.java')
-rw-r--r-- | kdejava/koala/org/kde/koala/Invocation.java | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/kdejava/koala/org/kde/koala/Invocation.java b/kdejava/koala/org/kde/koala/Invocation.java new file mode 100644 index 00000000..a3814ef2 --- /dev/null +++ b/kdejava/koala/org/kde/koala/Invocation.java @@ -0,0 +1,69 @@ +/*************************************************************************** + Invocation.java - description + ------------------- + begin : Tue Oct 31 06:12:14 2000 + copyright : (C) Gert-Jan van der Heiden. All rights reserved. + written by : Gert-Jan van der Heiden. + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as published by* + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +package org.kde.koala; + +import java.util.*; +import java.lang.reflect.*; +import org.kde.qt.qtjava; + +/** A utility class for creating a closure to invoke later +*/ +class Invocation{ +public static ArrayList invokeInterfaces(long qtObject){ + return invokeArrayOperation(qtObject, "interfaces"); + } + public static ArrayList invokeFunctions(long qtObject){ + return invokeArrayOperation(qtObject, "functions"); + } + public static ArrayList invokeArrayOperation(long qtObject, String operationName){ + try{ + Object onThis = qtjava.objectForQtKey(qtObject, "java.lang.object", true); + if(onThis != null){ + Object[] arguments = new Object[0]; + Class[] objectTypes = new Class[0]; + Method method = onThis.getClass().getMethod(operationName, objectTypes); + return (ArrayList) method.invoke(onThis,arguments); + }else { + System.out.println("Invocation.invokeArrayOperation() : object not found!"); + } + }catch(Exception e){ + e.printStackTrace(); + } + return new ArrayList(); + } + public static DCOPAnswer invokeProcess(long qtObject, String fun, byte[] data){ + try{ + Object onThis = qtjava.objectForQtKey(qtObject, "java.lang.object", true); + if(onThis != null){ + Object[] arguments = {fun, data}; + Class[] objectTypes = { String.class, + data.getClass()}; + + Method method = onThis.getClass().getMethod("javaProcess", objectTypes); + return (DCOPAnswer) method.invoke(onThis,arguments); + }else { + System.out.println("Invocation.invokeArrayOperation() : object not found!"); + } + }catch(Exception e){ + e.printStackTrace(); + } + DCOPAnswer answer = new DCOPAnswer(); + answer.setSucces(false); + return answer; + } +} |