亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? reflectionmanager.java

?? JDBF是一個實現o/r mapping 的軟件
?? JAVA
字號:
/*
* 03/12/2002 - 09:56:11
*
* $RCSfile: ReflectionManager.java,v $ - JDBF Object Relational mapping system
* Copyright (C) 2002 JDBF Development Team
* 
* http://jdbf.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*

 $Id: ReflectionManager.java,v 1.12 2004/05/20 22:41:02 gmartone Exp $

*/

package org.jdbf.engine.reflection;

import java.beans.*;
import java.lang.reflect.*;
import java.util.*;

import org.jdbf.engine.basic.ObjectMapped;
import org.jdbf.engine.mapping.MappingException;



/**
 * <code>ReflectionManager</code> is the class that handles via reflection all 
 * operationa to object that has been mapped on repository.
 * These operations are the:<br>
 * <UL>
 *	<LI>creation of object
 *	<LI>return value of particular property
 *      <LI>set value of particular property
 *      <LI>return type of particular property
 * </UL>
 * 
 * This class is very important when a set of result is returned from result set, because this set of data
 * is needed to create a object that will be return in Cursor object.
 *
 * @author Giovanni Martone
 * @version $Revision: 1.12 $
 * last changed by $Author: gmartone $
 *
 */
public class ReflectionManager{

    /**
     * Class name
     */
    private static String CLASS_NAME = "org.jdbf.engine.reflection.ReflectionManager";

    

    /**
     * Create a ObjectMapped by a name and a hashmap that contains
     * a list with the names of the properties and relative values.
     * If props is null the object created is null.
     *
     * @param name  name fo class
     * @param props list property/value
     * @return      ObjectMapped
     * @throws MappingException
     */
    public static ObjectMapped createBean(String name, HashMap props)
    	throws MappingException {

		Class oBeanClass = null;
        ObjectMapped oBean = null;
        Method oMethod = null;

        String sProp;
	
	
        try {
            if(props == null){
				oBeanClass = Class.forName(name);
				oBean = (ObjectMapped)oBeanClass.newInstance();
	    	}
	    	else{
				Iterator eKeys = props.keySet().iterator();
				oBeanClass = Class.forName(name);
				oBean = (ObjectMapped)oBeanClass.newInstance();
				while (eKeys.hasNext()) {
		    		sProp = (String) eKeys.next();
		    		oMethod = ReflectionManager.getWriteMethod(oBean, sProp);

		    		ReflectionManager.invokeWriteMethod(oBean, oMethod,
														(String) props.get(sProp)
									   );		    
				}
	    	}
	    
        }
		catch (ClassNotFoundException e) {
      
			throw new MappingException("class.notFound",name);
		         
	    
        }
        catch (Exception e) {
	    
	    	throw new MappingException(e);
        }
        return oBean;
    }


    /**
     * Create a non primitive type for value
     *
     * @param  cls   Class object (primitive type)
     * @param  value Value
     * @return       Not primitive type
     *
     */
    public static Object createNotPrimitiveObject(Class cls,String value) {

		Object oValue = null;
        if (cls == Boolean.TYPE) {
            oValue = new Boolean(value);
        } else if (cls == Byte.TYPE) {
            oValue = new Byte(value);
        } else if (cls == Character.TYPE) {
            if ((value != null) && (value.length() > 0)) {
                oValue = new Character(value.charAt(0));
            }
	    else {		
			   throw new IllegalArgumentException("missing char");		          
            }
        } else if (cls == Short.TYPE) {
            oValue = new Short(value);
        } else if (cls == Integer.TYPE) {
            oValue = new Integer(value);
        } else if (cls == Long.TYPE) {
            oValue = new Long(value);
        } else if (cls == Float.TYPE) {
            oValue = new Float(value);
        } else if (cls == Double.TYPE) {
            oValue = new Double(value);
        }
        return oValue;
    }


    /**
     * Return the name of properties of ObjectMapped object.
     * Array contains the name of properties of the superclass only.
     *
     * @param  object    ObjectMapped object
     * @return String[]  Array that cotains the properties of superclass
     *
     */
    public static String[] getDeclaredFieldsName(ObjectMapped object) {
        return getPropertyNames(object, true);
    }


    /**
     * Return the name of properties of ObjectMapped object.
     * Array contains the name of properties of ObjectMapped object
     *
     * @param  object    ObjectMapped object
     * @return String[]  Array that contains the properties
     *
     */
    public static String[] getFieldsNames(ObjectMapped object) {
        return getPropertyNames(object, false);
    }


    /**
     * Return name of every property of ObjectMapped object.
     * This method return the properties of superclass also.
     *
     * @param  object    ObjectMapped object
     * @param   pk    <tt>true</tt> if properties of superclass,false otherwise
     * @return String[]       Array that contains every property
     *
     */
    public static String[] getPropertyNames(ObjectMapped object, boolean pk) {

        Object params[] = {object.getClassName(),new Boolean(pk)};
	
		boolean bPkProp;
        ArrayList vProp = new ArrayList();
        String[] aProp;
        String sName;

		Field[] fields = null;
		if(pk){
  	    	fields = object.getClass().getDeclaredFields();
		}
		else{
	    	fields = object.getClass().getFields();
		}

        //converts in array the vector that
		//contains then names of properties
        aProp = new String[fields.length];
        for (int i = 0; i < fields.length; ++i) {
            Field f = fields[i];	    
	    	aProp[i] = f.getName();
	    }
        return aProp;
    }


    /**
     * Return the type of property di un ObjectMapped object, 
     * specified the name of property.
     * This method returns the type returned by get method of propName
     *
     * @param  object    ObjectMapped object
     * @param  propName  name of property
     * @return Class     type of property
     * @throws MappingException
     */
    public static Class getPropertyType(ObjectMapped object, String propName)
    	throws MappingException {

        Class c = null;
		Object params[] = {object.getClassName(),propName};
        
		try{
  	    	PropertyDescriptor pd = new PropertyDescriptor(propName,object.getClass());
	    	c =  pd.getPropertyType();
        }
        catch(IntrospectionException e){            
			throw new MappingException(e);
        }
		return c;
    }


    /**
     * Return the Method object.This object is the get method of property
     * specified in propName.
     *
     * @param  object    ObjectMapped object
     * @param  propName  name of property
     * @return           Method object
     * @throws MappingException
     *
     */
    public static Method getReadMethod(ObjectMapped object,String propName)
		throws MappingException {

		Method method = null;
		Object params[] = {object.getClassName(),propName};
        
		try{
 	    	//Return the Method object
	    	PropertyDescriptor pd = new PropertyDescriptor(propName,object.getClass());
	    	method = pd.getReadMethod();
		}
		catch (IntrospectionException e) {
	    
			throw new MappingException(e);
		}
		return method;
    }


    /**
     * Return value of property of the ObjectMapped object.
     *
     * @param  object    ObjectMapped object
     * @param  propName  name of property
     * @return           value of property specified in propName;
     * @throws MappingException
     */
    public static Object getValueByName(ObjectMapped object, String propName)
    	throws MappingException {
        
        Object value = null;
        Method method = null;
		
		try {

	    	method = ReflectionManager.getReadMethod(object, propName);
	    	value = method.invoke(object, null);
		}
		catch (InvocationTargetException e) {
	    	throw new MappingException("field.invokeTarget",method.getName());
		}
		catch (Exception e) {
	    	throw new MappingException(e);
		}
		return value;
    }


    /**
     * Return the Method object.This object is the set method of property
     * specified in propName.
     *
     * @param  object    ObjectMapped object
     * @param  propName  name of property
     * @return           Method object
     * @throws MappingException
     *
     */
    public static Method getWriteMethod(ObjectMapped object,String propName)
		throws MappingException{
	
		Method method = null;
		Object params[] = {object.getClassName(),propName};
        
        try{
            //Return the Method object
  	    	PropertyDescriptor pd = new PropertyDescriptor(propName,object.getClass());
	    	method = pd.getWriteMethod();
        }
        catch(IntrospectionException e){
            throw new MappingException(e);
        }
		
		return method;
    }


    /**
     * Invoke setter method of a property
     *
     * @param  object    ObjectMapped object
     * @param  method    Mehod object
     * @param  value   	 value to set
     * @throws MappingException
     *
     */
    public static void invokeWriteMethod(ObjectMapped object, Method method, Object value)
		throws MappingException {

		try {
	    	//invoke the setter method
            method.invoke(object, new Object[]{value});
        }
		catch (InvocationTargetException e) {
            throw new MappingException("mapping.noSuchMethod",
	    		       object.getClass().getName(),method.getName()
	    			      );
	    }
        catch (Exception e) {
            throw new MappingException(e);
        }
    }


    /**
     * Invoke the setter method. It converts the value as parameter.
     * <tt>String</tt>   nothing
     * <tt>int</tt>      Integer.parseInt(value)
     * <tt>double</tt>   Double.parseDouble(value)
     * Finally if value is primitive type , it tries to wrapper it into on primitive type.
     *
     * @param  object    ObjectMapped object
     * @param  method    Mehod object
     * @param  newValue   	 value to set
     * @throws InvocationTargetException
     *
     */
    public static void invokeWriteMethod(ObjectMapped object, Method method,String newValue)
		throws MappingException {

		Object value = newValue;
        Constructor oConstr = null;
	
	    Class oPClass = method.getParameterTypes()[0];

        try {
            if (oPClass.isPrimitive()) {
	        	value = createNotPrimitiveObject(oPClass, newValue);
            }
	    	else{
	        	if (oPClass != String.class) {
                    oConstr = oPClass.getConstructor(new Class[]{String.class});
                    value = oConstr.newInstance(new Object[]{newValue});
                }
            }
            // invoke the settter method
            method.invoke(object, new Object[]{value});
        }
        catch (NoSuchMethodException e) {
            
			throw new MappingException("mapping.noSuchMethod",
				       object.getClass().getName(),method.getName());		    
        }
        catch (InvocationTargetException e) {
            
			throw new MappingException("field.invokeTarget",
		                        method.getName());	    
        }
        catch (Exception e) {            
			throw new MappingException(e);	    
        }
    }


    /**
     * Return true if field specified in propertyName is primitive,
     * false otherwise
     *
     * @param object
     * @param propertyName
     * @return true if primitive,false otherwise
     *
     */
    public static boolean isPrimitive(ObjectMapped object,String propertyName)
        throws MappingException{

        Class c = ReflectionManager.getPropertyType(object, propertyName);
        return c.isPrimitive();
    }


   /**
     * Set the value of property of ObjectMapped object
     *
     * @param  object    ObjectMapped object
     * @param  propName  name of property
     * @param  value     value to set in the property
     * @return ObjectMapped
     * @throws MappingException
     */
    public static ObjectMapped  setValueByName(ObjectMapped object, String propName,
					       					   Object value)
		throws MappingException {
			
        Method method = null;
		try {	    
	    	method = ReflectionManager.getWriteMethod(object, propName);

	    	if (value instanceof String) {
                invokeWriteMethod(object, method, (String) value);
            }
	    	else{
                invokeWriteMethod(object, method, value);
            }
        }
        catch (Exception e) {
            
			throw new MappingException(e);
        }

        return object;
    }

}

/*
  $Log: ReflectionManager.java,v $
  Revision 1.12  2004/05/20 22:41:02  gmartone
  Changed for task 99073 (Coverage Javadocs)

  Revision 1.11  2004/05/18 18:07:20  gmartone
  removed logs

  Revision 1.9  2004/02/10 00:24:11  gmartone
  task 66484 (logging system) and corrections on javadocs comments

  Revision 1.2  2004/02/08 22:43:14  gmartone
  remove blank characters for some cvs keyword

*/

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产视频一区二区在线| 国产在线不卡一区| 91精品办公室少妇高潮对白| 国产午夜精品久久久久久免费视| 国内精品免费**视频| 欧美变态tickling挠脚心| 日韩激情av在线| 久久综合久久久久88| 国产一区不卡在线| 国产精品人妖ts系列视频| 色综合天天性综合| 一区av在线播放| 欧美精三区欧美精三区| 国产又黄又大久久| 欧美性大战久久久久久久| 日韩国产精品久久久| 亚洲成人av资源| 高清不卡一区二区| 国产日韩欧美精品电影三级在线 | av一区二区三区黑人| 亚洲天堂福利av| 在线视频欧美精品| 亚洲国产精品久久人人爱蜜臀| 这里只有精品视频在线观看| 麻豆精品在线看| 国产日韩影视精品| 色综合久久中文综合久久97| 一区二区三区精密机械公司| 在线成人午夜影院| 国产传媒久久文化传媒| 亚洲一区影音先锋| 欧美成人福利视频| 免费人成精品欧美精品| 中文幕一区二区三区久久蜜桃| 在线亚洲一区二区| 日本美女一区二区三区视频| 中文字幕不卡在线观看| 欧美日韩在线三级| 肉丝袜脚交视频一区二区| 国产精品色呦呦| 日本丰满少妇一区二区三区| 亚洲天天做日日做天天谢日日欢| 日韩欧美成人一区二区| 本田岬高潮一区二区三区| 亚洲另类春色校园小说| 国产日韩三级在线| 欧美日韩一二三| 国产一区二区日韩精品| 奇米精品一区二区三区在线观看| 国产精品天干天干在观线| 在线观看www91| 91麻豆swag| 黑人巨大精品欧美一区| 伊人性伊人情综合网| 欧美tk—视频vk| 欧美日韩久久久一区| 97精品国产97久久久久久久久久久久| 美脚の诱脚舐め脚责91| 一区二区三区精品| 1000精品久久久久久久久| 精品久久久久久无| 欧美日韩一级黄| 欧美日韩一区二区三区免费看 | 亚洲欧美日韩国产成人精品影院| 7777精品伊人久久久大香线蕉完整版 | 蜜乳av一区二区| 亚洲国产婷婷综合在线精品| 欧美激情在线看| 亚洲精品在线免费观看视频| 精品久久久久av影院| 精品视频1区2区3区| www.亚洲国产| eeuss影院一区二区三区| 国产一区二区三区久久悠悠色av| 一区二区国产视频| 亚洲高清视频中文字幕| 国产精品小仙女| 91亚洲男人天堂| 亚洲成人免费av| 亚洲欧洲精品一区二区三区不卡| 日韩精品自拍偷拍| 中文字幕亚洲精品在线观看| 在线观看一区不卡| av在线不卡观看免费观看| 99re成人精品视频| 欧美一级夜夜爽| 欧美国产日韩精品免费观看| 亚洲成人av免费| 国内欧美视频一区二区| 97aⅴ精品视频一二三区| 欧美一区二区三区四区视频| 国产三级三级三级精品8ⅰ区| 亚洲天堂成人网| 国产精品原创巨作av| 在线观看亚洲专区| 久久久久久久久久久久久夜| 亚洲一区二区欧美| 国产麻豆91精品| 欧美亚洲日本一区| 国产精品动漫网站| 蜜臀av国产精品久久久久| 精品综合久久久久久8888| 色播五月激情综合网| 精品少妇一区二区三区视频免付费| 国产精品香蕉一区二区三区| 在线播放91灌醉迷j高跟美女| 国产亚洲1区2区3区| 午夜精品久久一牛影视| 一本色道综合亚洲| 国产午夜精品一区二区三区四区| 亚洲免费观看高清完整| 成人伦理片在线| 日韩精品一区二区三区四区| 亚洲欧洲色图综合| 国产99久久久国产精品免费看 | 亚洲蜜臀av乱码久久精品蜜桃| 九色porny丨国产精品| 欧美午夜一区二区三区免费大片| 最新久久zyz资源站| 精品中文字幕一区二区小辣椒| 欧美午夜影院一区| 亚洲小说欧美激情另类| 9i看片成人免费高清| 欧美一二三区精品| 蜜臀精品久久久久久蜜臀 | 成人精品免费看| 在线视频中文字幕一区二区| 亚洲欧美激情在线| 国产精品99久久久| 欧美丰满少妇xxxbbb| 丝袜a∨在线一区二区三区不卡| eeuss影院一区二区三区| 欧美精品一区二区三区蜜桃| 久久成人免费电影| 91精品国产品国语在线不卡| 欧美激情自拍偷拍| 成人一区二区三区视频在线观看| 精品日韩成人av| 日韩精品乱码免费| 日韩精品一区二区三区视频| 日本在线不卡视频一二三区| 日韩欧美综合一区| 免费美女久久99| 欧美一区二区三区四区高清| 免费精品视频最新在线| 欧美一区日本一区韩国一区| 亚洲444eee在线观看| 日韩一本二本av| 麻豆专区一区二区三区四区五区| 欧美亚洲一区二区在线| 免费观看日韩电影| 日韩精品一区二区三区蜜臀| 午夜激情久久久| 欧美一区二区三区四区久久| 青草av.久久免费一区| 9久草视频在线视频精品| 亚洲精品免费一二三区| 欧美亚洲综合一区| 亚洲欧美怡红院| 欧美日韩一区二区三区四区| 日韩综合在线视频| www.色综合.com| 肉色丝袜一区二区| 欧美xxxxxxxxx| 国产一区欧美二区| 亚洲激情成人在线| 91精品婷婷国产综合久久| 日韩精品电影在线观看| 日韩欧美在线不卡| 国产美女一区二区| 国产精品狼人久久影院观看方式| 欧美视频第二页| 免费亚洲电影在线| 欧美成人精品1314www| 波波电影院一区二区三区| 亚洲综合网站在线观看| 欧美三级日韩在线| 国产成人精品综合在线观看| 亚洲天堂中文字幕| 欧美亚洲一区二区在线| 久久精品国产亚洲a| 中文一区在线播放| 91精品国产欧美一区二区成人| 国产iv一区二区三区| 亚洲一区精品在线| 日本一区二区视频在线| 欧美色图在线观看| 国产一区二区三区美女| 天天影视网天天综合色在线播放| 精品久久久久久久人人人人传媒| 99国产精品久久久久久久久久| 久久国产精品色| 午夜精品成人在线| 亚洲色图20p| 日本一区免费视频| 日韩欧美成人一区| 欧美日韩日日骚| 色综合久久久久综合体| 国产sm精品调教视频网站| 奇米色一区二区|