Java Reflection (JAVA·´Éä)
Reflection ÊÇ Java ³ÌÐò¿ª·¢ÓïÑÔµÄÌØÕ÷Ö®Ò»£¬ËüÔÊÐíÔËÐÐÖÐµÄ Java ³ÌÐò¶Ô×ÔÉí½øÐмì²é£¬»òÕß˵“×ÔÉ󔣬²¢ÄÜÖ±½Ó²Ù×÷³ÌÐòµÄÄÚ²¿ÊôÐÔ¡£ÀýÈ磬ʹÓÃËüÄÜ»ñµÃ Java ÀàÖи÷³ÉÔ±µÄÃû³Æ²¢ÏÔʾ³öÀ´¡£
Java µÄÕâÒ»ÄÜÁ¦ÔÚʵ¼ÊÓ¦ÓÃÖÐÒ²ÐíÓõò»ÊǺܶ࣬µ«ÊÇÔÚÆäËüµÄ³ÌÐòÉè¼ÆÓïÑÔÖиù±¾¾Í²»´æÔÚÕâÒ»ÌØÐÔ¡£ÀýÈ磬Pascal¡¢C »òÕß C++ ÖоÍûÓа취ÔÚ³ÌÐòÖлñµÃº¯Êý¶¨ÒåÏà¹ØµÄÐÅÏ¢¡£
JavaBean ÊÇ reflection µÄʵ¼ÊÓ¦ÓÃÖ®Ò»£¬ËüÄÜÈÃһЩ¹¤¾ß¿ÉÊÓ»¯µÄ²Ù×÷Èí¼þ×é¼þ¡£ÕâЩ¹¤¾ßͨ¹ý reflection ¶¯Ì¬µÄÔØÈ벢ȡµÃ Java ×é¼þ(Àà) µÄÊôÐÔ¡£
1. Ò»¸ö¼òµ¥µÄÀý×Ó
¿¼ÂÇÏÂÃæÕâ¸ö¼òµ¥µÄÀý×Ó£¬ÈÃÎÒÃÇ¿´¿´ reflection ÊÇÈçºÎ¹¤×÷µÄ¡£
import java.lang.reflect.*;
public class DumpMethods {
public static void main(String args[]) {
try {
Class c = Class.forName(args[0]);
Method m[] = c.getDeclaredMethods();
for (int i = 0; i < m.length; i++)
System.out.println(m[i].toString());
} catch (Throwable e) {
System.err.println(e);
}
}
}
°´ÈçÏÂÓï¾äÖ´ÐУº
java DumpMethods java.util.Stack
ËüµÄ½á¹ûÊä³öΪ£º
public java.lang.Object java.util.Stack.push(java.lang.Object)
public synchronized java.lang.Object java.util.Stack.pop()
public synchronized java.lang.Object java.util.Stack.peek()
public boolean java.util.Stack.empty()
public synchronized int java.util.Stack.search(java.lang.Object)
ÕâÑù¾ÍÁгöÁËjava.util.Stack ÀàµÄ¸÷·½·¨ÃûÒÔ¼°ËüÃǵÄÏÞÖÆ·ûºÍ·µ»ØÀàÐÍ¡£
Õâ¸ö³ÌÐòʹÓà Class.forName ÔØÈëÖ¸¶¨µÄÀ࣬Ȼºóµ÷Óà getDeclaredMethods À´»ñÈ¡Õâ¸öÀàÖж¨ÒåÁ˵ķ½·¨ÁÐ±í¡£java.lang.reflect.Methods ÊÇÓÃÀ´ÃèÊöij¸öÀàÖÐ
Ïà¹ØÎĵµ£º
JXLµÄ´òÓ¡ÉèÖÃÔÚjxl.SheetSettingsÕâ¸öÀàÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ý·½·¨Sheet£¨»òÕßWritableSheet£©#getSettings()»ñÈ¡¡£
1.Ò³Ãæ
1.1·½Ïò
SheetSetting#setOrientation(PageOrientation po)£»
²ÎÊý£º PageOrientation#LANDSCAPE ºáÏò´òÓ¡
PageOrientation# PO ......
1¡¢Óï·¨£º±ØÐë±È½ÏÊìϤ£¬ÔÚд´úÂëµÄʱºòIDEµÄ±à¼Æ÷¶ÔijһÐб¨´íÓ¦¸ÃÄܹ»¸ù¾Ý±¨´íÐÅÏ¢ÖªµÀÊÇʲôÑùµÄÓï·¨´íÎó²¢ÇÒÖªµÀÈκÎÐÞÕý¡£
2¡¢ÃüÁ±ØÐëÊìϤJDK´øµÄһЩ³£ÓÃÃüÁî¼°Æä³£ÓÃÑ¡ÏÃüÁîÖÁÉÙÐèÒªÊìϤ£ºappletviewer¡¢ HtmlConverter¡¢jar¡¢ java¡¢javac¡¢javadoc¡¢javap¡¢javaw¡¢ ......
Java±à³ÌÄÇЩʶù1——ÐòÑÔ
Java±à³ÌÄÇЩʶù2——³ÌÐòÉè¼ÆÊÇʲô£¿
Java±à³ÌÄÇЩʶù3——ÄãÊʺÏѧϰ³ÌÐòÉè¼ÆÂð£¿
Java±à³ÌÄÇЩʶù4——ÈçºÎѧºÃ³ÌÐòÉè¼Æ£¿
Java±à³ÌÄÇЩʶù5——³ÌÐòÉè¼Æ½éÉÜС½á
Java±à³ÌÄÇЩʶù6——¼ÆËã»úÈí¼þ»ù±¾¸ÅÄî
Java±à ......
±¾ÎÄÀ´×Ô£ºhttp://www.javaeye.com/topic/130025 1 ¼ò½é<o:p></o:p> ¶ÔÏóÐòÁл¯(Serializable)ÊÇÖ¸½«¶ÔÏóת»»Îª×Ö½ÚÐòÁеĹý³Ì£¬¶ø·´ÐòÁл¯ÔòÊǸù¾Ý×Ö½ÚÐòÁлָ´¶ÔÏóµÄ¹ý³Ì¡£<o:p></o:p> ÐòÁл¯Ò»°ãÓÃÓÚÒÔϳ¡¾°£º<o:p></o:p> 1. ÓÀ¾ÃÐÔ±£´æ¶ÔÏ󣬱£´æ¶ÔÏóµÄ×Ö½ÚÐòÁе½±¾µ ......