Exemple #1
0
    def __init__(self, intf, dict=None, inst=None) :
        actualIntf = None
        
        if isinstance(intf, str) or isinstance(intf, unicode) :
            actualIntf = [ _jclass.JClass(intf) ]
        elif isinstance(intf, _jclass._JavaClass) :
            actualIntf = [ intf ]
        elif operator.isSequenceType(intf) :
            actualIntf = []
            for i in intf :            
                if isinstance(i, str) or isinstance(i, unicode) :
                    actualIntf.append(_jclass.JClass(i))
                elif isinstance(i, _jclass._JavaClass) :
                    actualIntf.append(i)
                else:
                    raise TypeError, "JProxy requires java interface classes or the names of java interfaces classes"                
        else:
            raise TypeError, "JProxy requires java interface classes or the names of java interfaces classes"
                
        for i in actualIntf :
            if not JClassUtil.isInterface(i) :
                raise TypeError, "JProxy requires java interface classes or the names of java interfaces classes : "+i.__name__                 

        if dict is not None and inst is not None :
            raise RuntimeError, "Specify only one of dict and inst"

        self._dict = dict
        self._inst = inst
        
        self._proxy = _jpype.createProxy(self, actualIntf)
Exemple #2
0
	def stacktrace(self) :
		StringWriter = _jclass.JClass("java.io.StringWriter")
		PrintWriter = _jclass.JClass("java.io.PrintWriter")
		sw = StringWriter()
		pw = PrintWriter(sw)
		
		self.__javaobject__.printStackTrace(pw)
		pw.flush()
		r = sw.toString()
		sw.close()
		return r
Exemple #3
0
def _colRetainAll(self, v):
    if isPythonSequence(v):
        r = _jclass.JClass("java.util.ArrayList")(len(v))
        for i in v:
            r.add(i)
    else:
        r = v

    return self._retainAll(r)
Exemple #4
0
	def __init__(self, *data) :
		if isinstance(data[0], tuple) and data[0][0] is _jclass._SPECIAL_CONSTRUCTOR_KEY :
			# this is wrapped :
			self.__javaobject__ = data[0][1]
			self.__javaclass__ = self.__javaobject__.__class__
		else:
			self.__javaclass__ = _jclass.JClass(self.__class__.JAVACLASSNAME)
			self.__javaobject__ = self.__javaclass__(*data)
			
		Exception.__init__(self, self.__javaobject__)
Exemple #5
0
def setupGuiEnvironment(cb):
	if sys.platform == 'darwin' :
		from PyObjCTools import AppHelper
		m = {'run' : cb}
		proxy = _jproxy.JProxy('java.lang.Runnable', m)
		cbthread = _jclass.JClass("java.lang.Thread")(proxy)
		cbthread.start()
		AppHelper.runConsoleEventLoop()
	else:
		cb()
Exemple #6
0
def _byteArrayStr(self):
    s = _jclass.JClass('java.lang.String')(self)
    return s.toString()