コード例 #1
0
ファイル: _jarray.py プロジェクト: Eothred/jpype
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)
コード例 #2
0
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)
コード例 #3
0
ファイル: _jarray.py プロジェクト: 736907871/zyl
    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)
コード例 #4
0
    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)
コード例 #5
0
ファイル: _jarray.py プロジェクト: Sunyifan/jpype
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)
コード例 #6
0
ファイル: _jarray.py プロジェクト: originell/jpype
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)
コード例 #7
0
	def __setslice__(self, i, j, v) : 
		_jpype.setArraySlice(self.__javaobject__, i, j, v)
コード例 #8
0
ファイル: _jarray.py プロジェクト: Sunyifan/jpype
 def __setslice__(self, i, j, v):
     if j == sys.maxsize:
         j = _jpype.getArrayLength(self.__javaobject__)
     _jpype.setArraySlice(self.__javaobject__, i, j, v)
コード例 #9
0
ファイル: _jarray.py プロジェクト: originell/jpype
 def __setslice__(self, i, j, v):
     if j == sys.maxsize:
         j = _jpype.getArrayLength(self.__javaobject__)
     _jpype.setArraySlice(self.__javaobject__, i, j, v)
コード例 #10
0
ファイル: _jarray.py プロジェクト: ct1104/fileservices
 def __setslice__(self, i, j, v):
     _jpype.setArraySlice(self.__javaobject__, i, j, v)