當前位置: 首頁>>代碼示例>>Java>>正文


Java Introspector.decapitalize方法代碼示例

本文整理匯總了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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:TmpPattern.java

示例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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:BasicPropertyAccessor.java

示例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);
}
 
開發者ID:lubang,項目名稱:black-reflection,代碼行數:23,代碼來源:BlackReflectionUtil.java

示例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;
    }

}
 
開發者ID:weld,項目名稱:weld-junit,代碼行數:12,代碼來源:MockResourceInjectionServices.java

示例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();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:28,代碼來源:CommonAnnotationBeanPostProcessor.java

示例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;
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:35,代碼來源:JandexHelper.java

示例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);
}
 
開發者ID:FermioCloud,項目名稱:java-code-templates,代碼行數:9,代碼來源:BeanProperty.java

示例8: camelize

import java.beans.Introspector; //導入方法依賴的package包/類
private static String camelize(String s) {
    return Introspector.decapitalize(s);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:4,代碼來源:GetterSetterPropertySeed.java

示例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 );
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:6,代碼來源:TmpPattern.java

示例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" : "");
}
 
開發者ID:bamartinezd,項目名稱:traccar-service,代碼行數:5,代碼來源:DataManager.java

示例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));
}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:7,代碼來源:DefaultInstanceManager.java

示例12: inferName

import java.beans.Introspector; //導入方法依賴的package包/類
private static String inferName(Class clazz) {
    return Introspector.decapitalize(clazz.getSimpleName());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:4,代碼來源:JAXB.java

示例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();
}
 
開發者ID:Dactilo,項目名稱:spring-spreadsheet,代碼行數:6,代碼來源:ObjectToSpreadsheetConverter.java

示例14: getTail

import java.beans.Introspector; //導入方法依賴的package包/類
public String getTail(String input)
{
    return Introspector.decapitalize(input.substring(_len));
}
 
開發者ID:JetBrains,項目名稱:intellij-deps-ini4j,代碼行數:5,代碼來源:AbstractBeanInvocationHandler.java

示例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);
}
 
開發者ID:xsonorg,項目名稱:tangyuan2,代碼行數:15,代碼來源:ClassUtils.java


注:本文中的java.beans.Introspector.decapitalize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。