本文整理汇总了Python中java.lang.Class.getDeclaredFields方法的典型用法代码示例。如果您正苦于以下问题:Python Class.getDeclaredFields方法的具体用法?Python Class.getDeclaredFields怎么用?Python Class.getDeclaredFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.Class
的用法示例。
在下文中一共展示了Class.getDeclaredFields方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: javaStaticFields
# 需要导入模块: from java.lang import Class [as 别名]
# 或者: from java.lang.Class import getDeclaredFields [as 别名]
def javaStaticFields(clazz):
"""Return names of static fields for a given Java class."""
static_fields = {}
for field in Class.getDeclaredFields(clazz):
modifiers = field.getModifiers()
if Modifier.isStatic(modifiers) and Modifier.isPublic(modifiers):
static_fields[field.name] = field
fields = static_fields.keys()
for base in clazz.__bases__:
if not ispython(base):
fields.extend(javaStaticFields(base))
return fields
示例2: staticFieldNames
# 需要导入模块: from java.lang import Class [as 别名]
# 或者: from java.lang.Class import getDeclaredFields [as 别名]
def staticFieldNames(clazz):
"""return a list of static field names for class"""
# TODO get static fields from base classes
static_fields = {}
declared_fields = Class.getDeclaredFields(clazz)
for field in declared_fields:
if Modifier.isStatic(field.getModifiers()) and Modifier.isPublic(field.getModifiers()):
static_fields[field.name] = field
fields = static_fields.keys()
for eachBase in clazz.__bases__:
fields.extend(staticFieldNames(eachBase))
return fields
示例3: foo
# 需要导入模块: from java.lang import Class [as 别名]
# 或者: from java.lang.Class import getDeclaredFields [as 别名]
"""
We want to create Jython wrappers for all public methods of PApplet except
those in "BAD_METHOD". Also, if we have both foo(int) and foo(char), we throw
away the char variant, and always call the int variant. Same with foo(byte).
Sadly, Java has no unisgned types, so the distinction is weird.
"""
WANTED_METHODS = [m for m in Class.getDeclaredMethods(PApplet)
if Modifier.isPublic(m.getModifiers())
and not BAD_METHOD.match(m.getName())
and not any(k in USELESS_TYPES for k in m.getParameterTypes())]
"""
We want to create Jython wrappers for all variables visible during the
Processing runtime.
"""
WANTED_FIELDS = [f for f in Class.getDeclaredFields(PApplet)
if Modifier.isPublic(f.getModifiers())
and not Modifier.isStatic(f.getModifiers())
and not BAD_FIELD.match(f.getName())]
class ClassConversionInfo(object):
"""
A structure to keep in one place all of the templates for generating
code for going back and forth between Python and Java.
"""
def __init__(self, to_python_prefix, to_java_format, typecheck_format):
self.to_python_prefix = to_python_prefix
self.to_java_format = to_java_format
self.typecheck_format = typecheck_format