本文整理汇总了Java中java.beans.Introspector.decapitalize方法的典型用法代码示例。如果您正苦于以下问题:Java Introspector.decapitalize方法的具体用法?Java Introspector.decapitalize怎么用?Java Introspector.decapitalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.beans.Introspector
的用法示例。
在下文中一共展示了Introspector.decapitalize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findIndexedPropertyName
import java.beans.Introspector; //导入方法依赖的package包/类
/** Based on names of indexedGetter and indexedSetter resolves the name
* of the indexed property.
* @return Name of the indexed property
*/
String findIndexedPropertyName() {
String superName = findPropertyName();
if ( superName == null ) {
String methodName = null;
if ( indexedGetterMethod != null )
methodName = nameAsString(indexedGetterMethod);
else if ( indexedSetterMethod != null )
methodName = nameAsString(indexedSetterMethod);
else
throw new InternalError( "Indexed property with all methods == null" ); // NOI18N
return methodName.startsWith( IS_PREFIX ) ? // NOI18N
Introspector.decapitalize( methodName.substring(2) ) :
Introspector.decapitalize( methodName.substring(3) );
}
else
return superName;
}
示例2: setterMethod
import java.beans.Introspector; //导入方法依赖的package包/类
private static Method setterMethod(Class theClass, String propertyName) {
BasicGetter getter = getGetterOrNull(theClass, propertyName);
Class returnType = (getter==null) ? null : getter.getReturnType();
Method[] methods = theClass.getDeclaredMethods();
Method potentialSetter = null;
for ( Method method : methods ) {
final String methodName = method.getName();
if ( method.getParameterTypes().length == 1 && methodName.startsWith( "set" ) ) {
String testStdMethod = Introspector.decapitalize( methodName.substring( 3 ) );
String testOldMethod = methodName.substring( 3 );
if ( testStdMethod.equals( propertyName ) || testOldMethod.equals( propertyName ) ) {
potentialSetter = method;
if ( returnType == null || method.getParameterTypes()[0].equals( returnType ) ) {
return potentialSetter;
}
}
}
}
return potentialSetter;
}
示例3: getBeanName
import java.beans.Introspector; //导入方法依赖的package包/类
/**
* get name of Bean by getter function.
*
* @param clazz Class type
* @param getter Function
* @param <T> Class type
* @param <R> Return type
* @return Bean name
*/
public static <T, R> String getBeanName(Class<?> clazz, Function<T, R> getter) {
final Method method = getMethod(clazz, getter);
final String methodName = method.getName();
if (methodName.startsWith("get") || methodName.startsWith("set")) {
return Introspector.decapitalize(methodName.substring(3));
}
if (methodName.startsWith("is")) {
return Introspector.decapitalize(methodName.substring(2));
}
throw new BlackReflectionException("Method is not bean style: " + methodName);
}
示例4: getPropertyName
import java.beans.Introspector; //导入方法依赖的package包/类
private static String getPropertyName(Method method) {
String methodName = method.getName();
if (methodName.matches("^(get).*") && method.getParameterTypes().length == 0) {
return Introspector.decapitalize(methodName.substring(3));
} else if (methodName.matches("^(is).*") && method.getParameterTypes().length == 0) {
return Introspector.decapitalize(methodName.substring(2));
} else {
return null;
}
}
示例5: ResourceElement
import java.beans.Introspector; //导入方法依赖的package包/类
public ResourceElement(Member member, PropertyDescriptor pd) {
super(member, pd);
AnnotatedElement ae = (AnnotatedElement) member;
Resource resource = ae.getAnnotation(Resource.class);
String resourceName = resource.name();
Class<?> resourceType = resource.type();
this.isDefaultName = !StringUtils.hasLength(resourceName);
if (this.isDefaultName) {
resourceName = this.member.getName();
if (this.member instanceof Method && resourceName.startsWith("set") && resourceName.length() > 3) {
resourceName = Introspector.decapitalize(resourceName.substring(3));
}
}
else if (beanFactory instanceof ConfigurableBeanFactory){
resourceName = ((ConfigurableBeanFactory) beanFactory).resolveEmbeddedValue(resourceName);
}
if (resourceType != null && !Object.class.equals(resourceType)) {
checkResourceType(resourceType);
}
else {
// No resource type specified... check field/method.
resourceType = getResourceType();
}
this.name = resourceName;
this.lookupType = resourceType;
this.mappedName = resource.mappedName();
}
示例6: getPropertyName
import java.beans.Introspector; //导入方法依赖的package包/类
/**
* Expects a method or field annotation target and returns the property name for this target
*
* @param target the annotation target
*
* @return the property name of the target. For a field it is the field name and for a method name it is
* the method name stripped of 'is', 'has' or 'get'
*/
public static String getPropertyName(AnnotationTarget target) {
if ( !( target instanceof MethodInfo || target instanceof FieldInfo ) ) {
throw new AssertionFailure( "Unexpected annotation target " + target.toString() );
}
if ( target instanceof FieldInfo ) {
return ( (FieldInfo) target ).name();
}
else {
final String methodName = ( (MethodInfo) target ).name();
String propertyName;
if ( methodName.startsWith( "is" ) ) {
propertyName = Introspector.decapitalize( methodName.substring( 2 ) );
}
else if ( methodName.startsWith( "has" ) ) {
propertyName = Introspector.decapitalize( methodName.substring( 3 ) );
}
else if ( methodName.startsWith( "get" ) ) {
propertyName = Introspector.decapitalize( methodName.substring( 3 ) );
}
else {
throw new AssertionFailure( "Expected a method following the Java Bean notation" );
}
return propertyName;
}
}
示例7: propertyName
import java.beans.Introspector; //导入方法依赖的package包/类
static String propertyName(String method) {
if (method.startsWith("get") || method.startsWith("set")) {
method = method.substring(3);
} else if (method.startsWith("is")) {
method = method.substring(2);
}
return Introspector.decapitalize(method);
}
示例8: camelize
import java.beans.Introspector; //导入方法依赖的package包/类
private static String camelize(String s) {
return Introspector.decapitalize(s);
}
示例9: findEventSetName
import java.beans.Introspector; //导入方法依赖的package包/类
/** Decides about the name of the event set from names of the methods */
private String findEventSetName() {
String compound = nameAsString(addListenerMethod).substring(3);
return name = Introspector.decapitalize( compound );
}
示例10: makeNameId
import java.beans.Introspector; //导入方法依赖的package包/类
private static String makeNameId(Class<?> clazz) {
String name = clazz.getSimpleName();
return Introspector.decapitalize(name) + (!name.contains("Id") ? "Id" : "");
}
示例11: getName
import java.beans.Introspector; //导入方法依赖的package包/类
@Deprecated
public static String getName(Method setter) {
// Note: method signature has already been checked for correctness.
// The method name always starts with "set".
return Introspector.decapitalize(setter.getName().substring(3));
}
示例12: inferName
import java.beans.Introspector; //导入方法依赖的package包/类
private static String inferName(Class clazz) {
return Introspector.decapitalize(clazz.getSimpleName());
}
示例13: getPropertyName
import java.beans.Introspector; //导入方法依赖的package包/类
private String getPropertyName(Method method) {
SpreadsheetColumnName spreadsheetColumnName = method.getAnnotation(SpreadsheetColumnName.class);
final String methodName = method.getName();
return spreadsheetColumnName == null ? Introspector.decapitalize(methodName.substring(methodName.startsWith("is") ? 2 : 3)) : spreadsheetColumnName.name();
}
示例14: getTail
import java.beans.Introspector; //导入方法依赖的package包/类
public String getTail(String input)
{
return Introspector.decapitalize(input.substring(_len));
}
示例15: getShortNameAsProperty
import java.beans.Introspector; //导入方法依赖的package包/类
/**
* Return the short string name of a Java class in uncapitalized JavaBeans property format. Strips the outer class name in case of an inner class.
*
* @param clazz
* the class
* @return the short name rendered in a standard JavaBeans property format
* @see java.beans.Introspector#decapitalize(String)
*/
public static String getShortNameAsProperty(Class<?> clazz) {
String shortName = ClassUtils.getShortName(clazz);
int dotIndex = shortName.lastIndexOf(PACKAGE_SEPARATOR);
shortName = (dotIndex != -1 ? shortName.substring(dotIndex + 1) : shortName);
return Introspector.decapitalize(shortName);
}