def testProxyWithArguments(self): itf2 = JPackage("jpype.proxy").ITestInterface2 Test3 = JPackage("jpype.proxy").Test3 c = C() proxy = JProxy(itf2, inst=c) Test3().testCallbackWithParameters(proxy)
def testProxyWithInst(self): itf2 = JPackage("jpype.proxy").ITestInterface3 Test3 = JPackage("jpype.proxy").Test3 c = C() proxy = JProxy(itf2, inst=c) Test3.testProxy(proxy)
def testThrowException3(self): d = { "throwIOException": throwByJavaException, } p = JProxy(self.jpype.exc.ExceptionThrower, dict=d) self.assertTrue(self.jpype.exc.ExceptionTest.delegateThrow(p))
def testThrowException3(self): exthrow = JClass('jpype.exc.ExceptionThrower') extest = JClass('jpype.exc.ExceptionTest') d = {"throwIOException": throwByJavaException, } p = JProxy(exthrow, dict=d) self.assertTrue(extest.delegateThrow(p))
def predictAsync(self, inputs: List[PredictionInput]) -> CompletableFuture: """Python implementation of the predictAsync interface method""" supplier = InnerSupplier(inputs, self.predict_fun) proxy = JProxy("java.util.function.Supplier", inst=supplier) future = CompletableFuture.supplyAsync(proxy, ForkJoinPool.commonPool()) return future
def testProxyWithMultipleInterface(self): itf2 = JPackage("jpype.proxy").ITestInterface2 itf3 = JPackage("jpype.proxy").ITestInterface3 Test3 = JPackage("jpype.proxy").Test3 c = C() proxy = JProxy([itf2, itf3], inst=c) Test3().testCallbackWithParameters(proxy)
def testProxyWithThread(self): itf2 = JPackage("jpype.proxy").ITestInterface3 Test3 = JPackage("jpype.proxy").Test3 c = C() proxy = JProxy(itf2, inst=c) t3 = Test3() t3.testProxyWithThread(proxy)
def testProxyWithDict(self): d = { 'testMethod': _testMethod, 'testMethod2': _testMethod2, } itf2 = JPackage("jpype.proxy").ITestInterface3 Test3 = JPackage("jpype.proxy").Test3 proxy = JProxy(itf2, dictionary=d) Test3.testProxy(proxy)
def __init__(self, cb, name=None, icon=None): object.__init__(self) self.__proxy = JProxy(javax.swing.Action, inst=self) self.__values = {} self.__cb = cb self.__listeners = [] self.__enabled = True if name is not None: self.putValue(AbstractAction.NAME, name) if icon is not None: self.putValue(AbstractAction.SMALL_ICON, icon)
def toEvaluable(function): return JProxy("jisa.experiment.ResultTable.Evaluable", dict={"evaluate": function})
def toPredicate(function): return JProxy("java.util.function.Predicate", dict={"test": function})
def toRunnable(function): from jisa.control import SRunnable return SRunnable.fromJProxy( JProxy("java.lang.Runnable", dict={"run": function}))
pass def startDocument(self, ): pass def startElement(self, namespaceURI, localName, qName, atts): pass def startPrefixMapping(self, prefix, uri): pass # Compute the XML file path xml_file = os.path.join(root, "sample", "big.xml") t1 = time.time() count = 30 for i in range(count): DelegateHandler = JPackage("jpype.xml").DelegateHandler dh = DelegateHandler( None, None, JProxy("org.xml.sax.ContentHandler", inst=ContentHandler()), None) build = javax.xml.parsers.SAXParserFactory.newInstance().newSAXParser() build.parse(xml_file, dh) t2 = time.time() print(count, "iterations in", t2 - t1, "seconds") shutdownJVM()