File: //lib/fm-agent/dependencies/linux/python3.9/jpype/__pycache__/_jarray.cpython-39.pyc
a
��i/ � @ s� d dl Z ddlmZ dgZG dd� de jdd�ZG dd � d e�Zd
d� ZG dd
� d
e�Z e�
d�e�
d�G dd� de���Ze�e j
e� ee _dS )� N� )�_jcustomizer�JArrayc @ s( e Zd ZdZddd�Zed dd��ZdS )
r a� Creates a Java array class for a Java type of a given dimension.
This serves as a base type and factory for all Java array classes.
The resulting Java array class can be used to construct a new
array with a given size or specified members.
JPype arrays support Python operators for iterating, length, equals,
not equals, subscripting, and slicing. They also support Java
object methods, clone, and length property. Java arrays may not
be resized, and as such elements cannot be added nor deleted. Currently,
applying the slice operator produces a new Python sequence.
Example:
.. code-block:: python
# Define a new array class for ``int[]``
IntArrayCls = JArray(JInt)
# Create an array holding 10 elements
# equivalent to Java ``int[] x=new int[10]``
x = IntArrayCls(10)
# Create a length 3 array initialized with [1,2,3]
# equivalent to Java ``int[] x = new int[]{1,2,3};``
x = IntArrayCls([1,2,3])
# Operate on an array
print(len(x))
print(x[0])
print(x[:-2])
x[1:]=(5,6)
if isinstance(x, JArray):
print("object is a java array")
if issubclass(IntArrayCls, JArray):
print("class is a java array type.")
Args:
javaClass (str,type): Is the type of element to hold in
the array.
ndims (Optional,int): the number of dimensions of the array
(default=1)
Returns:
A new Python class that representing a Java array class.
Raises:
TypeError: if the component class is invalid or could not be found.
Note:
javaClass can be specified in three ways:
- as a string with the name of a java class.
- as a Java primitive type such as ``jpype.JInt``.
- as a Java class type such as ``java.lang.String``.
r c C s$ | t krtd��t|�}t�||�S )Nz$Arrays factory can't be used as type)r � TypeError�_toJavaClass�_jpype�
_newArrayType)�cls�tpZdims�jc� r �?/usr/lib/fm-agent/dependencies/linux/python3.9/jpype/_jarray.py�__new__U s zJArray.__new__Nc C s t �||�S �N)r �arrayFromBuffer)r �arrayZdtyper r r
�of[ s z JArray.of)r )N)�__name__�
__module__�__qualname__�__doc__r �classmethodr r r r r
r s ;
T)�internalc @ s, e Zd Zdd� Zdd� Zdd� Zdd� Zd S )
�_JArrayProtoc C s t t| ��S r )�str�list��selfr r r
�__str__b s z_JArrayProto.__str__c C s t | �S r )�_JavaArrayIterr r r r
�__iter__e s z_JArrayProto.__iter__c c s | d d d� D ]
}|V qd S �N���r )r �elemr r r
�__reversed__h s z_JArrayProto.__reversed__c C s t �d��| t| ��S )af Clone the Java array.
Create a "shallow" copy of a Java array. For a
single dimensional array of primitives, the cloned array is
complete independent copy of the original. For objects or
multidimensional arrays, the new array is a copy which points
to the same members as the original.
To obtain a deep copy of a Java array, use Java serialize and
deserialize operations to duplicate the entire array and
contents. In order to deep copy, the objects must be
Serializable.
Returns:
A shallow copy of the array.
zjava.util.Arrays)r �JClassZcopyOf�lenr r r r
�clonel s z_JArrayProto.cloneN)r r r r r r$ r'