?? propertyutils.java
字號:
/* * $Header: /cvs/osworkflow/src/designer/com/opensymphony/workflow/designer/beanutils/PropertyUtils.java,v 1.1 2003/12/06 18:05:58 hani Exp $ * $Revision: 1.1 $ * $Date: 2003/12/06 18:05:58 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgement may appear in the software itself, * if and wherever such third-party acknowledgements normally appear. * * 4. The names "Apache", "The Jakarta Project", "Commons", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * "Apache" nor may "Apache" appear in their names without prior * written permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */package com.opensymphony.workflow.designer.beanutils;import java.beans.PropertyDescriptor;import java.lang.reflect.InvocationTargetException;import java.lang.reflect.Method;import java.util.Map;/** * <p>Utility methods for using Java Reflection APIs to facilitate generic * property getter and setter operations on Java objects.</p> * * <p>The implementations for these methods are provided by <code>PropertyUtilsBean</code>. * For more details see {@link PropertyUtilsBean}.</p> * * @author Craig R. McClanahan * @author Ralph Schaer * @author Chris Audley * @author Rey Fran鏾is * @author Gregor Ra齧an * @author Jan Sorensen * @author Scott Sanders * @version $Revision: 1.1 $ $Date: 2003/12/06 18:05:58 $ * @see PropertyUtilsBean */public class PropertyUtils { // ----------------------------------------------------- Manifest Constants /** * The delimiter that preceeds the zero-relative subscript for an * indexed reference. */ public static final char INDEXED_DELIM = '['; /** * The delimiter that follows the zero-relative subscript for an * indexed reference. */ public static final char INDEXED_DELIM2 = ']'; /** * The delimiter that preceeds the key of a mapped property. */ public static final char MAPPED_DELIM = '('; /** * The delimiter that follows the key of a mapped property. */ public static final char MAPPED_DELIM2 = ')'; /** * The delimiter that separates the components of a nested reference. */ public static final char NESTED_DELIM = '.'; // ------------------------------------------------------- Static Variables // --------------------------------------------------------- Public Methods /** * Clear any cached property descriptors information for all classes * loaded by any class loaders. This is useful in cases where class * loaders are thrown away to implement class reloading. * * <p>For more details see <code>PropertyUtilsBean</code>.</p> * * @see PropertyUtilsBean#clearDescriptors */ public static void clearDescriptors() { PropertyUtilsBean.getInstance().clearDescriptors(); } /** * <p>Copy property values from the "origin" bean to the "destination" bean * for all cases where the property names are the same (even though the * actual getter and setter methods might have been customized via * <code>BeanInfo</code> classes).</p> * * <p>For more details see <code>PropertyUtilsBean</code>.</p> * * @see PropertyUtilsBean#copyProperties */ public static void copyProperties(Object dest, Object orig) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { PropertyUtilsBean.getInstance().copyProperties(dest, orig); } /** * <p>Return the entire set of properties for which the specified bean * provides a read method.</p> * * <p>For more details see <code>PropertyUtilsBean</code>.</p> * * @see PropertyUtilsBean#describe */ public static Map describe(Object bean) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return (PropertyUtilsBean.getInstance().describe(bean)); } /** * <p>Return the value of the specified indexed property of the specified * bean, with no type conversions.</p> * * <p>For more details see <code>PropertyUtilsBean</code>.</p> * * @see PropertyUtilsBean#getIndexedProperty(Object,String) */ public static Object getIndexedProperty(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return (PropertyUtilsBean.getInstance().getIndexedProperty(bean, name)); } /** * <p>Return the value of the specified indexed property of the specified * bean, with no type conversions.</p> * * <p>For more details see <code>PropertyUtilsBean</code>.</p> * * @see PropertyUtilsBean#getIndexedProperty(Object,String, int) */ public static Object getIndexedProperty(Object bean, String name, int index) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return (PropertyUtilsBean.getInstance().getIndexedProperty(bean, name, index)); } /** * <p>Return the value of the specified mapped property of the * specified bean, with no type conversions.</p> * * <p>For more details see <code>PropertyUtilsBean</code>.</p> * * @see PropertyUtilsBean#getMappedProperty(Object,String) */ public static Object getMappedProperty(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return (PropertyUtilsBean.getInstance().getMappedProperty(bean, name)); } /** * <p>Return the value of the specified mapped property of the specified * bean, with no type conversions.</p> * * <p>For more details see <code>PropertyUtilsBean</code>.</p> * * @see PropertyUtilsBean#getMappedProperty(Object,String, String) */ public static Object getMappedProperty(Object bean, String name, String key) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return PropertyUtilsBean.getInstance().getMappedProperty(bean, name, key); } /** * <p>Return the mapped property descriptors for this bean class.</p> * * <p>For more details see <code>PropertyUtilsBean</code>.</p> * * @see PropertyUtilsBean#getMappedPropertyDescriptors(Class) */ public static Map getMappedPropertyDescriptors(Class beanClass) { return PropertyUtilsBean.getInstance().getMappedPropertyDescriptors(beanClass); } /** * <p>Return the mapped property descriptors for this bean.</p> * * <p>For more details see <code>PropertyUtilsBean</code>.</p> * * @see PropertyUtilsBean#getMappedPropertyDescriptors(Object) */ public static Map getMappedPropertyDescriptors(Object bean) { return PropertyUtilsBean.getInstance().getMappedPropertyDescriptors(bean); } /** * <p>Return the value of the (possibly nested) property of the specified * name, for the specified bean, with no type conversions.</p> * * <p>For more details see <code>PropertyUtilsBean</code>.</p> * * @see PropertyUtilsBean#getNestedProperty */ public static Object getNestedProperty(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return PropertyUtilsBean.getInstance().getNestedProperty(bean, name); } /** * <p>Return the value of the specified property of the specified bean, * no matter which property reference format is used, with no * type conversions.</p> *
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -