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

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

?? classinfo.java

?? 本套系統采用了業界當前最為流行的beanAction組件
?? JAVA
字號:
/*
 *  Copyright 2004 Clinton Begin
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.ibatis.common.beans;

import com.ibatis.common.logging.Log;
import com.ibatis.common.logging.LogFactory;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.UndeclaredThrowableException;
import java.lang.reflect.ReflectPermission;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

/**
 * This class represents a cached set of class definition information that
 * allows for easy mapping between property names and getter/setter methods.
 */
public class ClassInfo {
  
  private static final Log log = LogFactory.getLog(ClassInfo.class);

  private static boolean cacheEnabled = true;
  private static final String[] EMPTY_STRING_ARRAY = new String[0];
  private static final Set SIMPLE_TYPE_SET = new HashSet();
  private static final Map CLASS_INFO_MAP = Collections.synchronizedMap(new HashMap());

  private String className;
  private String[] readablePropertyNames = EMPTY_STRING_ARRAY;
  private String[] writeablePropertyNames = EMPTY_STRING_ARRAY;
  private HashMap setMethods = new HashMap();
  private HashMap getMethods = new HashMap();
  private HashMap setTypes = new HashMap();
  private HashMap getTypes = new HashMap();

  static {
    SIMPLE_TYPE_SET.add(String.class);
    SIMPLE_TYPE_SET.add(Byte.class);
    SIMPLE_TYPE_SET.add(Short.class);
    SIMPLE_TYPE_SET.add(Character.class);
    SIMPLE_TYPE_SET.add(Integer.class);
    SIMPLE_TYPE_SET.add(Long.class);
    SIMPLE_TYPE_SET.add(Float.class);
    SIMPLE_TYPE_SET.add(Double.class);
    SIMPLE_TYPE_SET.add(Boolean.class);
    SIMPLE_TYPE_SET.add(Date.class);
    SIMPLE_TYPE_SET.add(Class.class);
    SIMPLE_TYPE_SET.add(BigInteger.class);
    SIMPLE_TYPE_SET.add(BigDecimal.class);

    SIMPLE_TYPE_SET.add(Collection.class);
    SIMPLE_TYPE_SET.add(Set.class);
    SIMPLE_TYPE_SET.add(Map.class);
    SIMPLE_TYPE_SET.add(List.class);
    SIMPLE_TYPE_SET.add(HashMap.class);
    SIMPLE_TYPE_SET.add(TreeMap.class);
    SIMPLE_TYPE_SET.add(ArrayList.class);
    SIMPLE_TYPE_SET.add(LinkedList.class);
    SIMPLE_TYPE_SET.add(HashSet.class);
    SIMPLE_TYPE_SET.add(TreeSet.class);
    SIMPLE_TYPE_SET.add(Vector.class);
    SIMPLE_TYPE_SET.add(Hashtable.class);
    SIMPLE_TYPE_SET.add(Enumeration.class);
  }

  private ClassInfo(Class clazz) {
    className = clazz.getName();
    addMethods(clazz);
    readablePropertyNames = (String[]) getMethods.keySet().toArray(new String[getMethods.keySet().size()]);
    writeablePropertyNames = (String[]) setMethods.keySet().toArray(new String[setMethods.keySet().size()]);
  }

  private void addMethods(Class cls) {
    Method[] methods = getAllMethodsForClass(cls);
    for (int i = 0; i < methods.length; i++) {
      String name = methods[i].getName();
      if (name.startsWith("set") && name.length() > 3) {
        if (methods[i].getParameterTypes().length == 1) {
          name = dropCase(name);
          if (setMethods.containsKey(name)) {
            // TODO(JGB) - this should probably be a RuntimeException at some point???
            log.error("Illegal overloaded setter method for property " + name + " in class " + cls.getName() +
                ".  This breaks the JavaBeans specification and can cause unpredicatble results.");
          }
          setMethods.put(name, methods[i]);
          setTypes.put(name, methods[i].getParameterTypes()[0]);
        }
      } else if (name.startsWith("get") && name.length() > 3) {
        if (methods[i].getParameterTypes().length == 0) {
          name = dropCase(name);
          getMethods.put(name, methods[i]);
          getTypes.put(name, methods[i].getReturnType());
        }
      } else if (name.startsWith("is") && name.length() > 2) {
        if (methods[i].getParameterTypes().length == 0) {
          name = dropCase(name);
          getMethods.put(name, methods[i]);
          getTypes.put(name, methods[i].getReturnType());
        }
      }
      name = null;
    }
  }

  private Method[] getAllMethodsForClass(Class cls) {
    if (cls.isInterface()) {
      // interfaces only have public methods - so the
      // simple call is all we need (this will also get superinterface methods)
      return cls.getMethods();
    } else {
      // need to get all the declared methods in this class
      // and any super-class - then need to set access appropriatly
      // for private methods
      return getClassMethods(cls);
    }
  }
  
  /**
   * This method returns an array containing all methods
   * declared in this class and any superclass.
   * We use this method, instead of the simpler Class.getMethods(),
   * because we want to look for private methods as well. 
   * 
   * @param cls
   * @return
   */
  private Method[] getClassMethods(Class cls) {
    HashMap uniqueMethods = new HashMap();
    Class currentClass = cls;
    while (currentClass != null) {
      addUniqueMethods(uniqueMethods, currentClass.getDeclaredMethods());
      
      // we also need to look for interface methods - 
      // because the class may be abstract
      Class[] interfaces = currentClass.getInterfaces();
      for (int i = 0; i < interfaces.length; i++) {
        addUniqueMethods(uniqueMethods, interfaces[i].getMethods());
      }
      
      currentClass = currentClass.getSuperclass();
    }
    
    Collection methods = uniqueMethods.values();
    
    return (Method[]) methods.toArray(new Method[methods.size()]);
  }

  private void addUniqueMethods(HashMap uniqueMethods, Method[] methods) {
    for (int i = 0; i < methods.length; i++) {
      Method currentMethod = methods[i];
      String signature = getSignature(currentMethod);
      // check to see if the method is already known
      // if it is known, then an extended class must have
      // overridden a method
      if (!uniqueMethods.containsKey(signature)) {
        if (canAccessPrivateMethods()) {
          try {
            currentMethod.setAccessible(true);
          } catch (Exception e) {
            // Ignored. This is only a final precaution, nothing we can do.
          }
        }
        
        uniqueMethods.put(signature, currentMethod);
      }
    }
  }
  
  private String getSignature(Method method) {
    StringBuffer sb = new StringBuffer();
    sb.append(method.getName());
    Class[] parameters = method.getParameterTypes();
    
    for (int i = 0; i < parameters.length; i++) {
      if (i == 0) {
        sb.append(':');
      } else {
        sb.append(',');
      }
      sb.append(parameters[i].getName());
    }
    
    return sb.toString();
  }

  private boolean canAccessPrivateMethods() {
    try {
      System.getSecurityManager().checkPermission(new ReflectPermission("suppressAccessChecks"));
      return true;
    } catch (SecurityException e) {
      return false;
    } catch (NullPointerException e) {
      return true;
    }
  }

  private static String dropCase(String name) {
    if (name.startsWith("is")) {
      name = name.substring(2);
    } else if (name.startsWith("get") || name.startsWith("set")) {
      name = name.substring(3);
    } else {
      throw new ProbeException("Error parsing property name '" + name + "'.  Didn't start with 'is', 'get' or 'set'.");
    }

    if (name.length() == 1 || (name.length() > 1 && !Character.isUpperCase(name.charAt(1)))) {
      name = name.substring(0, 1).toLowerCase(Locale.US) + name.substring(1);
    }

    return name;
  }

  /**
   * Gets the name of the class the instance provides information for
   *
   * @return The class name
   */
  public String getClassName() {
    return className;
  }

  /**
   * Gets the setter for a property as a Method object
   *
   * @param propertyName - the property
   * @return The Method
   */
  public Method getSetter(String propertyName) {
    Method method = (Method) setMethods.get(propertyName);
    if (method == null) {
      throw new ProbeException("There is no WRITEABLE property named '" + propertyName + "' in class '" + className + "'");
    }
    return method;
  }

  /**
   * Gets the getter for a property as a Method object
   *
   * @param propertyName - the property
   * @return The Method
   */
  public Method getGetter(String propertyName) {
    Method method = (Method) getMethods.get(propertyName);
    if (method == null) {
      throw new ProbeException("There is no READABLE property named '" + propertyName + "' in class '" + className + "'");
    }
    return method;
  }

  /**
   * Gets the type for a property setter
   *
   * @param propertyName - the name of the property
   * @return The Class of the propery setter
   */
  public Class getSetterType(String propertyName) {
    Class clazz = (Class) setTypes.get(propertyName);
    if (clazz == null) {
      throw new ProbeException("There is no WRITEABLE property named '" + propertyName + "' in class '" + className + "'");
    }
    return clazz;
  }

  /**
   * Gets the type for a property getter
   *
   * @param propertyName - the name of the property
   * @return The Class of the propery getter
   */
  public Class getGetterType(String propertyName) {
    Class clazz = (Class) getTypes.get(propertyName);
    if (clazz == null) {
      throw new ProbeException("There is no READABLE property named '" + propertyName + "' in class '" + className + "'");
    }
    return clazz;
  }

  /**
   * Gets an array of the readable properties for an object
   *
   * @return The array
   */
  public String[] getReadablePropertyNames() {
    return readablePropertyNames;
  }

  /**
   * Gets an array of the writeable properties for an object
   *
   * @return The array
   */
  public String[] getWriteablePropertyNames() {
    return writeablePropertyNames;
  }

  /**
   * Check to see if a class has a writeable property by name
   *
   * @param propertyName - the name of the property to check
   * @return True if the object has a writeable property by the name
   */
  public boolean hasWritableProperty(String propertyName) {
    return setMethods.keySet().contains(propertyName);
  }

  /**
   * Check to see if a class has a readable property by name
   *
   * @param propertyName - the name of the property to check
   * @return True if the object has a readable property by the name
   */
  public boolean hasReadableProperty(String propertyName) {
    return getMethods.keySet().contains(propertyName);
  }

  /**
   * Tells us if the class passed in is a knwon common type
   *
   * @param clazz The class to check
   * @return True if the class is known
   */
  public static boolean isKnownType(Class clazz) {
    if (SIMPLE_TYPE_SET.contains(clazz)) {
      return true;
    } else if (Collection.class.isAssignableFrom(clazz)) {
      return true;
    } else if (Map.class.isAssignableFrom(clazz)) {
      return true;
    } else if (List.class.isAssignableFrom(clazz)) {
      return true;
    } else if (Set.class.isAssignableFrom(clazz)) {
      return true;
    } else if (Iterator.class.isAssignableFrom(clazz)) {
      return true;
    } else {
      return false;
    }
  }

  /**
   * Gets an instance of ClassInfo for the specified class.
   *
   * @param clazz The class for which to lookup the method cache.
   * @return The method cache for the class
   */
  public static ClassInfo getInstance(Class clazz) {
    if (cacheEnabled) {
      synchronized (clazz) {
        ClassInfo cache = (ClassInfo) CLASS_INFO_MAP.get(clazz);
        if (cache == null) {
          cache = new ClassInfo(clazz);
          CLASS_INFO_MAP.put(clazz, cache);
        }
        return cache;
      }
    } else {
      return new ClassInfo(clazz);
    }
  }

  public static void setCacheEnabled(boolean cacheEnabled) {
    ClassInfo.cacheEnabled = cacheEnabled;
  }

  /**
   * Examines a Throwable object and gets it's root cause
   *
   * @param t - the exception to examine
   * @return The root cause
   */
  public static Throwable unwrapThrowable(Throwable t) {
    Throwable t2 = t;
    while (true) {
      if (t2 instanceof InvocationTargetException) {
        t2 = ((InvocationTargetException) t).getTargetException();
      } else if (t instanceof UndeclaredThrowableException) {
        t2 = ((UndeclaredThrowableException) t).getUndeclaredThrowable();
      } else {
        return t2;
      }
    }
  }


}



?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
天堂精品中文字幕在线| 欧美精品一区二区久久久| 日日夜夜精品免费视频| 久久影院午夜论| 欧美日韩国产美| www.欧美色图| 国产呦精品一区二区三区网站 | 亚洲另类色综合网站| 欧美电影免费提供在线观看| 91免费国产在线| 国产精品一区二区三区四区| 丝袜美腿亚洲色图| 一区二区三区四区在线| 国产日本一区二区| 欧美成人乱码一区二区三区| 欧美日韩精品一区二区三区四区| 成人一区在线观看| 国产综合久久久久久鬼色 | 日韩精品1区2区3区| 亚洲日本护士毛茸茸| 国产婷婷色一区二区三区四区| 欧美电影一区二区| 欧美三级三级三级爽爽爽| 97久久久精品综合88久久| 懂色av中文字幕一区二区三区 | 亚洲人吸女人奶水| 国产日韩欧美精品综合| 精品美女在线观看| 日韩美女视频在线| 中文字幕中文字幕中文字幕亚洲无线| 久久国产麻豆精品| 国产日本亚洲高清| 久久久影视传媒| 久久在线观看免费| 久久综合资源网| 亚洲精品v日韩精品| 日韩理论片中文av| 亚洲欧洲三级电影| 一区视频在线播放| 一色桃子久久精品亚洲| 亚洲天堂成人网| 亚洲视频香蕉人妖| 一区二区三区中文字幕电影| 一区二区免费在线播放| **网站欧美大片在线观看| 国产精品麻豆欧美日韩ww| 国产亚洲欧美一区在线观看| 国产亚洲精品aa| 亚洲国产电影在线观看| 国产精品久久久久桃色tv| 国产精品久久影院| 亚洲欧美日韩中文字幕一区二区三区 | 成人一区二区三区视频| www.欧美精品一二区| 色综合一区二区三区| 91福利在线观看| 在线成人免费视频| 精品国产污网站| 国产日韩精品一区二区三区在线| 国产欧美一区二区三区网站| 国产精品欧美久久久久一区二区| 亚洲激情综合网| 日本午夜精品一区二区三区电影| 美女免费视频一区二区| 国产精品原创巨作av| 99在线精品免费| 欧美军同video69gay| 欧美日韩在线亚洲一区蜜芽| 国产尤物一区二区| 日韩免费观看高清完整版| 一本到不卡精品视频在线观看| 色婷婷激情综合| 久久一夜天堂av一区二区三区| 欧美无砖专区一中文字| 欧美日韩二区三区| 欧美r级在线观看| 国产精品乱码人人做人人爱| 一区二区高清视频在线观看| 免费观看一级欧美片| 国v精品久久久网| 欧美日韩一区三区| 久久丝袜美腿综合| 亚洲精品乱码久久久久久黑人| 美女一区二区三区| 91农村精品一区二区在线| 3d动漫精品啪啪一区二区竹菊 | 国产欧美日韩卡一| 亚洲一区二区三区四区的 | 色婷婷综合久久久久中文一区二区 | 蜜桃视频第一区免费观看| 成人黄色免费短视频| 337p亚洲精品色噜噜| 欧美国产精品专区| 日韩电影一区二区三区四区| 成人网男人的天堂| 欧美性欧美巨大黑白大战| 亚洲国产岛国毛片在线| 天天综合色天天| 欧美大片日本大片免费观看| 日韩一区二区三区视频在线观看| 精品国产一区二区亚洲人成毛片 | 久久99最新地址| 成人视屏免费看| 日韩三级免费观看| 亚洲综合精品自拍| 豆国产96在线|亚洲| 日韩美女在线视频 | 亚洲少妇最新在线视频| 麻豆国产精品视频| 欧美在线观看视频一区二区 | 久久99精品网久久| 欧美日韩国产免费一区二区| 最新热久久免费视频| 国内精品自线一区二区三区视频| 欧美精品 国产精品| 亚洲欧美一区二区久久| 成人一区二区三区中文字幕| 欧美成人a在线| 青娱乐精品视频在线| 欧美午夜精品一区二区蜜桃| 亚洲情趣在线观看| 大陆成人av片| 久久精品免视看| 91国产福利在线| 有码一区二区三区| 91女人视频在线观看| 国产精品狼人久久影院观看方式| 国产精品99久久久久久似苏梦涵| 欧美电视剧免费观看| 日韩国产精品久久久久久亚洲| 欧美在线视频你懂得| 亚洲影视在线观看| 在线亚洲欧美专区二区| 亚洲一区在线观看网站| 91成人免费在线| 亚洲丶国产丶欧美一区二区三区| 91久久精品日日躁夜夜躁欧美| 亚洲欧洲精品一区二区三区| 成人动漫视频在线| 国产精品网站在线观看| 从欧美一区二区三区| 欧美激情一区三区| 97精品电影院| 一二三四社区欧美黄| 欧美性videosxxxxx| 亚洲国产中文字幕| 555夜色666亚洲国产免| 首页国产欧美久久| 欧美一级淫片007| 麻豆精品久久精品色综合| 欧美成人猛片aaaaaaa| 国产剧情一区二区三区| 国产精品午夜免费| 91亚洲精品久久久蜜桃| 亚洲一级二级三级| 正在播放一区二区| 国产一区二区主播在线| 国产情人综合久久777777| 不卡的电影网站| 午夜日韩在线电影| 26uuu亚洲综合色欧美| 成人精品免费网站| 亚洲一区二区三区美女| 欧美一区二区三区四区久久 | www.激情成人| 亚洲一级不卡视频| 欧美成人一区二区| 99久久精品一区| 午夜久久福利影院| 欧美极品xxx| 欧美日韩在线三区| 国产一区二区三区最好精华液| 国产精品国产三级国产普通话99| 欧美三级在线视频| 国产一区二区按摩在线观看| 最新高清无码专区| 欧美一级欧美一级在线播放| 国产精品88888| 亚洲国产精品一区二区www在线 | 中文字幕乱码亚洲精品一区| 一本大道综合伊人精品热热| 蜜臀av一区二区在线观看| 国产精品丝袜一区| 欧美一区二区三区免费视频 | 精品国产免费久久| 91亚洲资源网| 久久99九九99精品| 一区二区三区中文字幕精品精品 | 丝袜a∨在线一区二区三区不卡| 久久久久久久一区| 色婷婷国产精品综合在线观看| 激情深爱一区二区| 亚洲黄网站在线观看| 久久麻豆一区二区| 欧美精品久久久久久久多人混战| 成人ar影院免费观看视频| 久久国产尿小便嘘嘘尿| 91日韩一区二区三区| 国产在线不卡一区| 图片区小说区国产精品视频|