Пример #1
0
    def testProxyWithArguments(self):
        itf2 = JPackage("jpype.proxy").ITestInterface2
        Test3 = JPackage("jpype.proxy").Test3

        c = C()
        proxy = JProxy(itf2, inst=c)
        Test3().testCallbackWithParameters(proxy)
Пример #2
0
    def testProxyWithInst(self):
        itf2 = JPackage("jpype.proxy").ITestInterface3
        Test3 = JPackage("jpype.proxy").Test3

        c = C()
        proxy = JProxy(itf2, inst=c)
        Test3.testProxy(proxy)
Пример #3
0
    def testThrowException3(self):
        d = {
            "throwIOException": throwByJavaException,
        }
        p = JProxy(self.jpype.exc.ExceptionThrower, dict=d)

        self.assertTrue(self.jpype.exc.ExceptionTest.delegateThrow(p))
Пример #4
0
    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))
Пример #5
0
 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
Пример #6
0
    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)
Пример #7
0
    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)
Пример #8
0
    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)
Пример #9
0
    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)
Пример #10
0
def toEvaluable(function):
    return JProxy("jisa.experiment.ResultTable.Evaluable",
                  dict={"evaluate": function})
Пример #11
0
def toPredicate(function):
    return JProxy("java.util.function.Predicate", dict={"test": function})
Пример #12
0
def toRunnable(function):
    from jisa.control import SRunnable
    return SRunnable.fromJProxy(
        JProxy("java.lang.Runnable", dict={"run": function}))
Пример #13
0
        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()