Java.use(better, Tips);

《前の記事|記事一覧|次の記事》
Java.use(better, Tips);


Tips#080

java.lang.Class



この世のすべては謎
そして謎を解く鍵は、新たなる謎だ
Ralph Waldo Emerson - Wikipedia, Ralph Waldo Emerson

《関連記事》

■ INDEX
$ jython
Jython 2.5.0 (Release_2_5_0:6476, Jun 16 2009, 13:33:26) 
...
>>> dir(java.lang.Class)
['__base__', '__bases__', '__call__', '__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__flags__', '__getattribute__', '__hash__', '__init__', '__module__', '__mro__', '__name__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__subclasses__', 'annotation', 'annotations', 'anonymousClass', 'array', 'asSubclass', 'canonicalName', 'cast', 'class', 'classLoader', 'classes', 'componentType', 'constructors', 'declaredAnnotations', 'declaredClasses', 'declaredConstructors', 'declaredFields', 'declaredMethods', 'declaringClass', 'desiredAssertionStatus', 'enclosingClass', 'enclosingConstructor', 'enclosingMethod', 'enum', 'enumConstants', 'equals', 'fields', 'forName', 'genericInterfaces', 'genericSuperclass', 'getAnnotation', 'getAnnotations', 'getCanonicalName', 'getClass', 'getClassLoader', 'getClasses', 'getComponentType', 'getConstructor', 'getConstructors', 'getDeclaredAnnotations', 'getDeclaredClasses', 'getDeclaredConstructor', 'getDeclaredConstructors', 'getDeclaredField', 'getDeclaredFields', 'getDeclaredMethod', 'getDeclaredMethods', 'getDeclaringClass', 'getEnclosingClass', 'getEnclosingConstructor', 'getEnclosingMethod', 'getEnumConstants', 'getField', 'getFields', 'getGenericInterfaces', 'getGenericSuperclass', 'getInterfaces', 'getMethod', 'getMethods', 'getModifiers', 'getName', 'getPackage', 'getProtectionDomain', 'getResource', 'getResourceAsStream', 'getSigners', 'getSimpleName', 'getSuperclass', 'getTypeParameters', 'hashCode', 'interface', 'interfaces', 'isAnnotation', 'isAnnotationPresent', 'isAnonymousClass', 'isArray', 'isAssignableFrom', 'isEnum', 'isInstance', 'isInterface', 'isLocalClass', 'isMemberClass', 'isPrimitive', 'isSynthetic', 'localClass', 'memberClass', 'methods', 'modifiers', 'mro', 'name', 'newInstance', 'notify', 'notifyAll', 'package', 'primitive', 'protectionDomain', 'signers', 'simpleName', 'superclass', 'synthetic', 'toString', 'typeParameters', 'wait']

 ↑ TOP

■ 事例
$ jython
Jython 2.5.0 (Release_2_5_0:6476, Jun 16 2009, 13:33:26) 
...
>>> # ---------------------------------------- Class
>>> from java.lang import Class
>>> 
>>> # ---------------------------------------- Dimension
>>> from java.awt import Dimension
>>> d = Dimension()
>>> 
>>> # ---------------------------------------- getClass
>>> c = d.getClass(); c

>>> c.getPackage()
package java.awt, Java Platform API Specification, version 1.5
>>> _.getName()
u'java.awt'
>>> c.getModifiers()
1
>>> c.getInterfaces()
array(java.lang.Class, ...
>>> for e in _: print e
... 

>>> c.getSuperclass()

>>> 
>>> c.isPrimitive()
False
>>> c.isArray()
False
>>> 
>>> # ---------------------------------------- getMethods
>>> c.getMethods()
array(java.lang.reflect.Method, ...
>>> for e in _: print e
... 
public int java.awt.Dimension.hashCode()
public boolean java.awt.Dimension.equals(java.lang.Object)
public java.lang.String java.awt.Dimension.toString()
public java.awt.Dimension java.awt.Dimension.getSize()
public void java.awt.Dimension.setSize(java.awt.Dimension)
public void java.awt.Dimension.setSize(int,int)
public void java.awt.Dimension.setSize(double,double)
public double java.awt.Dimension.getWidth()
public double java.awt.Dimension.getHeight()
public java.lang.Object java.awt.geom.Dimension2D.clone()
public void java.awt.geom.Dimension2D.setSize(java.awt.geom.Dimension2D)
public final native java.lang.Class java.lang.Object.getClass()
public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException
public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException
public final void java.lang.Object.wait() throws java.lang.InterruptedException
public final native void java.lang.Object.notify()
public final native void java.lang.Object.notifyAll()
>>> 
>>> dir(Dimension)
['__class__', '__delattr__', '__doc__', '__eq__', '__getattribute__', '__hash__', '__init__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'class', 'clone', 'equals', 'getClass', 'getHeight', 'getSize', 'getWidth', 'hashCode', 'height', 'notify', 'notifyAll', 'setSize', 'size', 'toString', 'wait', 'width']
>>> len(_)
30
>>> 
>>> # ---------------------------------------- getConstructors
>>> c.getConstructors()
array(java.lang.reflect.Constructor, ...
>>> for e in _: print e
... 
public java.awt.Dimension(int,int)
public java.awt.Dimension()
public java.awt.Dimension(java.awt.Dimension)
>>> 
>>> # ---------------------------------------- EOF

 ↑ TOP

》作業中です《

update*13/03/04 19:53:22