def _jarrayInit(self, *args) : if len(args) == 2 and args[0] == _jclass._SPECIAL_CONSTRUCTOR_KEY : _JavaArrayClass.__init__(self, args[1]) elif len(args) != 1 : raise ParameterException, "Array classes only take 2 parameters, %s given" % (len(args)+1,) else: values = None if operator.isSequenceType(args[0]) : sz = len(args[0]) values = args[0] else : sz = args[0] _JavaArrayClass.__init__(self, _jpype.newArray(self.__class__.__javaclass__, sz)) if values is not None : _jpype.setArraySlice(self.__javaobject__, 0, sz, values)
def _jarrayInit(self, *args): if len(args) == 2 and args[0] == _jclass._SPECIAL_CONSTRUCTOR_KEY: _JavaArrayClass.__init__(self, args[1]) elif len(args) != 1: raise ParameterException, "Array classes only take 2 parameters, %s given" % ( len(args) + 1, ) else: values = None if operator.isSequenceType(args[0]): sz = len(args[0]) values = args[0] else: sz = args[0] _JavaArrayClass.__init__( self, _jpype.newArray(self.__class__.__javaclass__, sz)) if values is not None: _jpype.setArraySlice(self.__javaobject__, 0, sz, values)
def __setitem__(self, ndx, val): if type(ndx) is not slice: # Simple index _jpype.setArrayItem(self.__javaobject__, ndx, val) return # Slice start = ndx.start if ndx.start is not None else 0 stop = ndx.stop if ndx.stop is not None else 0 if stop >= start and ndx.step in (None, 1): # Normal slice _jpype.setArraySlice(self.__javaobject__, start, stop, val) else: # Complex slice start, stop, step = ndx.indices(self.__len__()) indices = range(start, stop, step) for value in val: _jpype.setArrayItem(self.__javaobject__, next(indices), value)
def _jarrayInit(self, *args): if len(args) == 2 and args[0] == _jclass._SPECIAL_CONSTRUCTOR_KEY: _JavaArrayClass.__init__(self, args[1]) elif len(args) != 1: raise TypeError( "Array classes only take 2 parameters, {0} given".format( len(args) + 1)) else: values = None if isinstance(args[0], collections.Sequence): sz = len(args[0]) values = args[0] else: sz = args[0] _JavaArrayClass.__init__( self, _jpype.newArray(self.__class__.__javaclass__, sz)) if values is not None: _jpype.setArraySlice(self.__javaobject__, 0, sz, values)
def _jarrayInit(self, *args): if len(args) == 2 and args[0] == _jclass._SPECIAL_CONSTRUCTOR_KEY: _JavaArrayClass.__init__(self, args[1]) elif len(args) != 1: raise TypeError( "Array classes only take 2 parameters, {0} given" .format(len(args) + 1)) else: values = None if _isIterable(args[0]): sz = len(args[0]) values = args[0] else: sz = args[0] _JavaArrayClass.__init__( self, _jpype.newArray(self.__class__.__javaclass__, sz)) if values is not None: _jpype.setArraySlice(self.__javaobject__, 0, sz, values)
def __setslice__(self, i, j, v) : _jpype.setArraySlice(self.__javaobject__, i, j, v)
def __setslice__(self, i, j, v): if j == sys.maxsize: j = _jpype.getArrayLength(self.__javaobject__) _jpype.setArraySlice(self.__javaobject__, i, j, v)
def __setslice__(self, i, j, v): _jpype.setArraySlice(self.__javaobject__, i, j, v)