?? localebeanutils.java
字號:
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.commons.beanutils.locale;
import org.apache.commons.beanutils.BeanUtils;
import java.lang.reflect.InvocationTargetException;
import java.util.Locale;
/**
* <p>Utility methods for populating JavaBeans properties
* via reflection in a locale-dependent manner.</p>
*
* <p>The implementations for these methods are provided by <code>LocaleBeanUtilsBean</code>.
* For more details see {@link LocaleBeanUtilsBean}.</p>
*
* @author Craig R. McClanahan
* @author Ralph Schaer
* @author Chris Audley
* @author Rey Francois
* @author Gregor Rayman
* @author Yauheny Mikulski
*/
public class LocaleBeanUtils extends BeanUtils {
// ----------------------------------------------------- Instance Variables
/**
* <p>Gets the locale used when no locale is passed.</p>
*
* <p>For more details see <code>LocaleBeanUtilsBean</code></p>
*
* @return the default locale
* @see LocaleBeanUtilsBean#getDefaultLocale()
*/
public static Locale getDefaultLocale() {
return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getDefaultLocale();
}
/**
* <p>Sets the locale used when no locale is passed.</p>
*
* <p>For more details see <code>LocaleBeanUtilsBean</code></p>
*
* @param locale the default locale
* @see LocaleBeanUtilsBean#setDefaultLocale(Locale)
*/
public static void setDefaultLocale(Locale locale) {
LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().setDefaultLocale(locale);
}
/**
* <p>Gets whether the pattern is localized or not.</p>
*
* <p>For more details see <code>LocaleBeanUtilsBean</code></p>
*
* @return <code>true</code> if pattern is localized,
* otherwise <code>false</code>
* @see LocaleBeanUtilsBean#getApplyLocalized()
*/
public static boolean getApplyLocalized() {
return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getApplyLocalized();
}
/**
* <p>Sets whether the pattern is localized or not.</p>
*
* <p>For more details see <code>LocaleBeanUtilsBean</code></p>
*
* @param newApplyLocalized <code>true</code> if pattern is localized,
* otherwise <code>false</code>
* @see LocaleBeanUtilsBean#setApplyLocalized(boolean)
*/
public static void setApplyLocalized(boolean newApplyLocalized) {
LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().setApplyLocalized(newApplyLocalized);
}
// --------------------------------------------------------- Public Methods
/**
* <p>Return the value of the specified locale-sensitive indexed property
* of the specified bean, as a String.</p>
*
* <p>For more details see <code>LocaleBeanUtilsBean</code></p>
*
* @param bean Bean whose property is to be extracted
* @param name <code>propertyname[index]</code> of the property value
* to be extracted
* @param pattern The conversion pattern
* @return The indexed property's value, converted to a String
*
* @exception IllegalAccessException if the caller does not have
* access to the property accessor method
* @exception InvocationTargetException if the property accessor method
* throws an exception
* @exception NoSuchMethodException if an accessor method for this
* propety cannot be found
*
* @see LocaleBeanUtilsBean#getIndexedProperty(Object, String, String)
*/
public static String getIndexedProperty(Object bean, String name, String pattern)
throws IllegalAccessException, InvocationTargetException,
NoSuchMethodException {
return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getIndexedProperty(bean, name, pattern);
}
/**
* Return the value of the specified locale-sensitive indexed property
* of the specified bean, as a String using the default conversion pattern of
* the corresponding {@link LocaleConverter}.
*
* <p>For more details see <code>LocaleBeanUtilsBean</code></p>
*
* @param bean Bean whose property is to be extracted
* @param name <code>propertyname[index]</code> of the property value
* to be extracted
* @return The indexed property's value, converted to a String
*
* @exception IllegalAccessException if the caller does not have
* access to the property accessor method
* @exception InvocationTargetException if the property accessor method
* throws an exception
* @exception NoSuchMethodException if an accessor method for this
* propety cannot be found
*
* @see LocaleBeanUtilsBean#getIndexedProperty(Object, String)
*/
public static String getIndexedProperty(Object bean, String name)
throws IllegalAccessException, InvocationTargetException,
NoSuchMethodException {
return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getIndexedProperty(bean, name);
}
/**
* <p>Return the value of the specified locale-sensetive indexed property
* of the specified bean, as a String using the specified conversion pattern.</p>
*
* <p>For more details see <code>LocaleBeanUtilsBean</code></p>
*
* @param bean Bean whose property is to be extracted
* @param name Simple property name of the property value to be extracted
* @param index Index of the property value to be extracted
* @param pattern The conversion pattern
* @return The indexed property's value, converted to a String
*
* @exception IllegalAccessException if the caller does not have
* access to the property accessor method
* @exception InvocationTargetException if the property accessor method
* throws an exception
* @exception NoSuchMethodException if an accessor method for this
* propety cannot be found
*
* @see LocaleBeanUtilsBean#getIndexedProperty(Object, String, int, String)
*/
public static String getIndexedProperty(Object bean,
String name, int index, String pattern)
throws IllegalAccessException, InvocationTargetException,
NoSuchMethodException {
return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getIndexedProperty(bean, name, index, pattern);
}
/**
* <p>Return the value of the specified locale-sensetive indexed property
* of the specified bean, as a String using the default conversion pattern of
* the corresponding {@link LocaleConverter}.</p>
*
* <p>For more details see <code>LocaleBeanUtilsBean</code></p>
*
* @param bean Bean whose property is to be extracted
* @param name Simple property name of the property value to be extracted
* @param index Index of the property value to be extracted
* @return The indexed property's value, converted to a String
*
* @exception IllegalAccessException if the caller does not have
* access to the property accessor method
* @exception InvocationTargetException if the property accessor method
* throws an exception
* @exception NoSuchMethodException if an accessor method for this
* propety cannot be found
*
* @see LocaleBeanUtilsBean#getIndexedProperty(Object, String, int)
*/
public static String getIndexedProperty(Object bean,
String name, int index)
throws IllegalAccessException, InvocationTargetException,
NoSuchMethodException {
return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getIndexedProperty(bean, name, index);
}
/**
* <p>Return the value of the specified simple locale-sensitive property
* of the specified bean, converted to a String using the specified
* conversion pattern.</p>
*
* <p>For more details see <code>LocaleBeanUtilsBean</code></p>
*
* @param bean Bean whose property is to be extracted
* @param name Name of the property to be extracted
* @param pattern The conversion pattern
* @return The property's value, converted to a String
*
* @exception IllegalAccessException if the caller does not have
* access to the property accessor method
* @exception InvocationTargetException if the property accessor method
* throws an exception
* @exception NoSuchMethodException if an accessor method for this
* propety cannot be found
*
* @see LocaleBeanUtilsBean#getSimpleProperty(Object, String, String)
*/
public static String getSimpleProperty(Object bean, String name, String pattern)
throws IllegalAccessException, InvocationTargetException,
NoSuchMethodException {
return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getSimpleProperty(bean, name, pattern);
}
/**
* <p>Return the value of the specified simple locale-sensitive property
* of the specified bean, converted to a String using the default
* conversion pattern of the corresponding {@link LocaleConverter}.</p>
*
* <p>For more details see <code>LocaleBeanUtilsBean</code></p>
*
* @param bean Bean whose property is to be extracted
* @param name Name of the property to be extracted
* @return The property's value, converted to a String
*
* @exception IllegalAccessException if the caller does not have
* access to the property accessor method
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -