def PositiveInteger(some_number): '''Return an instance of ome.xml.model.primitives.PositiveInteger some_number - the number to be wrapped up in the class ''' return jutil.make_instance('ome/xml/model/primitives/PositiveInteger', '(Ljava/lang/Integer;)V', some_number)
def get_metadata_options(level): '''Get an instance of the MetadataOptions interface level - MINIMUM, NO_OVERLAYS or ALL to set the metadata retrieval level The object returned can be used in setMetadataOptions in a format reader. ''' jlevel = jutil.get_static_field('loci/formats/in/MetadataLevel', level, 'Lloci/formats/in/MetadataLevel;') return jutil.make_instance('loci/formats/in/DefaultMetadataOptions', '(Lloci/formats/in/MetadataLevel;)V', jlevel)
def test_02_03_death_and_resurrection(self): '''Put an object into another in Java, delete it in Python and recover it''' np.random.seed(24) my_value = np.random.randint(0, 1000) jobj = J.make_instance("java/lang/Integer", "(I)V", my_value) integer_klass = self.env.find_class("java/lang/Integer") jcontainer = self.env.make_object_array(1, integer_klass) self.env.set_object_array_element(jcontainer, 0, jobj) del jobj gc.collect() jobjs = self.env.get_object_array_elements(jcontainer) jobj = jobjs[0] self.assertEqual(J.call(jobj, "intValue", "()I"), my_value)
def test_01_02_make_instance(self): jobject = J.make_instance("java/lang/Object", "()V") self.assertTrue(J.to_string(jobject).startswith("java.lang.Object"))
def test_03_01_cw_from_class(self): '''Get a class wrapper from a class''' c = J.get_class_wrapper(J.make_instance('java/lang/Integer', '(I)V', 14))