当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.capitalize方法代码示例

本文整理汇总了Java中org.springframework.util.StringUtils.capitalize方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.capitalize方法的具体用法?Java StringUtils.capitalize怎么用?Java StringUtils.capitalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.util.StringUtils的用法示例。


在下文中一共展示了StringUtils.capitalize方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateApplicationName

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * Generate a suitable application name based on the specified name. If no suitable
 * application name can be generated from the specified {@code name}, the
 * {@link Env#fallbackApplicationName} is used instead.
 * <p>
 * No suitable application name can be generated if the name is {@code null} or if it
 * contains an invalid character for a class identifier.
 * @see Env#fallbackApplicationName
 * @see Env#invalidApplicationNames
 */
public String generateApplicationName(String name) {
	if (!StringUtils.hasText(name)) {
		return env.fallbackApplicationName;
	}
	String text = splitCamelCase(name.trim());
	// TODO: fix this
	String result = unsplitWords(text);
	if (!result.endsWith("Application")) {
		result = result + "Application";
	}
	String candidate = StringUtils.capitalize(result);
	if (hasInvalidChar(candidate)
			|| env.invalidApplicationNames.contains(candidate)) {
		return env.fallbackApplicationName;
	}
	else {
		return candidate;
	}
}
 
开发者ID:rvillars,项目名称:edoras-one-initializr,代码行数:30,代码来源:InitializrConfiguration.java

示例2: replaceVariables

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
public String replaceVariables(String message, Entity self, Entity target) {
    if (message == null) {
        return null;
    }

    if (self.equals(target)) {
        message = message.replace("%self%", self.getName());
        message = message.replace("%target%", target.getName());
    } else {
        message = message.replace("%self%", self.getName());
        message = message.replace("%target%", (target == null ? "NULL" : target.getName()));
    }

    message = message.replace("%him%", "him");
    message = message.replace("%selfpos%", self.getName() + "'s");
    message = message.replace("%targetpos%", (target == null ? "NULL" : target.getName()) + "'s");
    message = message.replace("%his%", "his");
    message = message.replace("%he%", "he");
    message = message.replace("%himself%", "himself");
    message = message.replace("%hispos%", "his");

    return StringUtils.capitalize(message);
}
 
开发者ID:scionaltera,项目名称:emergentmud,代码行数:24,代码来源:Emote.java

示例3: canRead

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
@Override
public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException {
	if (target == null) {
		return false;
	}
	Class<?> type = (target instanceof Class ? (Class<?>) target : target.getClass());
	if (type.isArray()) {
		return false;
	}
	if (this.member instanceof Method) {
		Method method = (Method) this.member;
		String getterName = "get" + StringUtils.capitalize(name);
		if (getterName.equals(method.getName())) {
			return true;
		}
		getterName = "is" + StringUtils.capitalize(name);
		return getterName.equals(method.getName());
	}
	else {
		Field field = (Field) this.member;
		return field.getName().equals(name);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:ReflectivePropertyAccessor.java

示例4: toCamelCaseFormat

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * Return a camel cased representation of this instance.
 */
public String toCamelCaseFormat() {
	String[] tokens = this.property.split("\\-|\\.");
	StringBuilder sb = new StringBuilder();
	for (int i  = 0; i < tokens.length; i++) {
		String part = tokens[i];
		if (i > 0) {
			part = StringUtils.capitalize(part);
		}
		sb.append(part);
	}
	return sb.toString();
}
 
开发者ID:rvillars,项目名称:edoras-one-initializr,代码行数:16,代码来源:VersionProperty.java

示例5: invokeSetter

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * 调用Setter方法.
 * 
 * @param propertyType
 *            用于查找Setter方法,为空时使用value的Class替代.
 */
public static void invokeSetter(Object obj, String propertyName,
		Object value, Class<?> propertyType) {
	Class<?> type = propertyType != null ? propertyType : value.getClass();
	String setterMethodName = "set" + StringUtils.capitalize(propertyName);
	invokeMethod(obj, setterMethodName, new Class[] { type },
			new Object[] { value });
}
 
开发者ID:jiangzongyao,项目名称:kettle_support_kettle8.0,代码行数:14,代码来源:Reflection.java

示例6: getBeanClassName

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
@Override
protected String getBeanClassName(Element element) {
    String elementName
            = Conventions.attributeNameToPropertyName(
                    element.getLocalName());
    return RedissonNamespaceParserSupport.IMPL_CLASS_PATH_PREFIX
            + StringUtils.capitalize(elementName);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:9,代码来源:RedissonMultiLockDefinitionParser.java

示例7: findSetter

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
private AnnotatedMethod findSetter(BeanDescription beanDesc,
                                   BeanPropertyWriter writer) {
    String name = "set" + StringUtils.capitalize(writer.getName());
    Class<?> type = writer.getPropertyType();
    AnnotatedMethod setter = beanDesc.findMethod(name, new Class<?>[] { type });
    // The enabled property of endpoints returns a boolean primitive but is set
    // using a Boolean class
    if (setter == null && type.equals(Boolean.TYPE)) {
        setter = beanDesc.findMethod(name, new Class<?>[] { Boolean.class });
    }
    return setter;
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:13,代码来源:Gatherer.java

示例8: getPropertyMethodSuffixes

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * Return the method suffixes for a given property name. The default implementation
 * uses JavaBean conventions with additional support for properties of the form 'xY'
 * where the method 'getXY()' is used in preference to the JavaBean convention of
 * 'getxY()'.
 */
protected String[] getPropertyMethodSuffixes(String propertyName) {
	String suffix = getPropertyMethodSuffix(propertyName);
	if (suffix.length() > 0 && Character.isUpperCase(suffix.charAt(0))) {
		return new String[] { suffix };
	}
	return new String[] { suffix, StringUtils.capitalize(suffix) };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:ReflectivePropertyAccessor.java

示例9: getPropertyMethodSuffix

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * Return the method suffix for a given property name. The default implementation
 * uses JavaBean conventions.
 */
protected String getPropertyMethodSuffix(String propertyName) {
	if (propertyName.length() > 1 && Character.isUpperCase(propertyName.charAt(1))) {
		return propertyName;
	}
	return StringUtils.capitalize(propertyName);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:ReflectivePropertyAccessor.java

示例10: invokeGetter

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * 调用Getter方法.
 */
public static Object invokeGetter(Object obj, String propertyName) {
	String getterMethodName = "get" + StringUtils.capitalize(propertyName);
	return invokeMethod(obj, getterMethodName, new Class[] {},
			new Object[] {});
}
 
开发者ID:jiangzongyao,项目名称:kettle_support_kettle8.0,代码行数:9,代码来源:Reflection.java

示例11: getResourceKey

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * Return composite resource key for specified extension key.
 * If extension has no resource or extension with specified key doesn't exist the method
 * returns {@code null}.
 *
 * @param extensionKey             the extension key
 * @param extensionResourceVersion ignored in current implementation
 * @return composite resource key or {@code null} if not found
 */
@Override
public LepResourceKey getResourceKey(LepKey extensionKey, Version extensionResourceVersion) {
    if (extensionKey == null) {
        return null;
    }

    LepKey groupKey = extensionKey.getGroupKey();
    String extensionKeyId = extensionKey.getId();
    String extensionName;
    String[] groupSegments;
    if (groupKey == null) {
        groupSegments = EMPTY_GROUP_SEGMENTS;
        extensionName = extensionKeyId;
    } else {
        groupSegments = groupKey.getId().split(EXTENSION_KEY_SEPARATOR_REGEXP);

        // remove group from id
        extensionName = extensionKeyId.replace(groupKey.getId(), "");
        if (extensionName.startsWith(XmLepConstants.EXTENSION_KEY_SEPARATOR)) {
            extensionName = extensionName.substring(XmLepConstants.EXTENSION_KEY_SEPARATOR.length());
        }
    }

    // change script name: capitalize first character & add script type extension
    String scriptName = extensionName.replaceAll(EXTENSION_KEY_SEPARATOR_REGEXP, SCRIPT_NAME_SEPARATOR_REGEXP);
    scriptName = StringUtils.capitalize(scriptName);

    String urlPath = URL_DELIMITER;
    if (groupSegments.length > 0) {
        urlPath += String.join(URL_DELIMITER, groupSegments) + URL_DELIMITER;
    }
    urlPath += scriptName + SCRIPT_EXTENSION_SEPARATOR + SCRIPT_EXTENSION_GROOVY;

    // TODO if possible add check that returned resourceKey contains resources (for speed up executor reaction)
    // Check example : return isResourceExists(resourceKey) ? resourceKey : null;
    UrlLepResourceKey urlLepResourceKey = UrlLepResourceKey.valueOfUrlResourcePath(urlPath);

    if (extensionResourceVersion == null) {
        log.debug("LEP extension key: '{}' translated to --> composite resource key: '{}'", extensionKey, urlLepResourceKey);
    } else {
        log.debug("LEP extension 'key: {}, v{}' translated to --> composite resource key: '{}'", extensionKey,
                  extensionResourceVersion, urlLepResourceKey);
    }
    return urlLepResourceKey;
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:55,代码来源:XmExtensionService.java

示例12: getResourceKey

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * Return composite resource key for specified extension key.
 * If extension has no resource or extension with specified key doesn't exist the method
 * returns {@code null}.
 *
 * @param extensionKey             the extension key
 * @param extensionResourceVersion ignored in current implementation
 * @return composite resource key or {@code null} if not found
 */
@Override
public LepResourceKey getResourceKey(LepKey extensionKey, Version extensionResourceVersion) {
    if (extensionKey == null) {
        return null;
    }

    LepKey groupKey = extensionKey.getGroupKey();
    String extensionKeyId = extensionKey.getId();
    String extensionName;
    String[] groupSegments;
    if (groupKey == null) {
        groupSegments = EMPTY_GROUP_SEGMENTS;
        extensionName = extensionKeyId;
    } else {
        groupSegments = groupKey.getId().split(EXTENSION_KEY_SEPARATOR_REGEXP);

        // remove group from id
        extensionName = extensionKeyId.replace(groupKey.getId(), "");
        if (extensionName.startsWith(EXTENSION_KEY_SEPARATOR)) {
            extensionName = extensionName.substring(EXTENSION_KEY_SEPARATOR.length());
        }
    }

    // change script name: capitalize first character & add script type extension
    String scriptName = extensionName.replaceAll(EXTENSION_KEY_SEPARATOR_REGEXP, SCRIPT_NAME_SEPARATOR_REGEXP);
    scriptName = StringUtils.capitalize(scriptName);

    String urlPath = URL_DELIMITER;
    if (groupSegments.length > 0) {
        urlPath += String.join(URL_DELIMITER, groupSegments) + URL_DELIMITER;
    }
    urlPath += scriptName + SCRIPT_EXTENSION_SEPARATOR + XmLepConstants.SCRIPT_EXTENSION_GROOVY;


    // TODO if possible add check that returned resourceKey contains resources (for speed up executor reaction)
    // Check example : return isResourceExists(resourceKey) ? resourceKey : null;
    UrlLepResourceKey urlLepResourceKey = UrlLepResourceKey.valueOfUrlResourcePath(urlPath);

    if (extensionResourceVersion == null) {
        log.debug("LEP extension key: '{}' translated to --> composite resource key: '{}'", extensionKey, urlLepResourceKey);
    } else {
        log.debug("LEP extension 'key: {}, v{}' translated to --> composite resource key: '{}'", extensionKey,
                  extensionResourceVersion, urlLepResourceKey);
    }
    return urlLepResourceKey;
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:56,代码来源:XmExtensionService.java

示例13: pretty

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
private String pretty(String type) {
	return StringUtils.capitalize(type) + "s";
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:4,代码来源:QualifiedApplicationNameConverter.java

示例14: getAttributeName

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * Return the JMX attribute name to use for the given JavaBeans property.
 * <p>When using strict casing, a JavaBean property with a getter method
 * such as {@code getFoo()} translates to an attribute called
 * {@code Foo}. With strict casing disabled, {@code getFoo()}
 * would translate to just {@code foo}.
 * @param property the JavaBeans property descriptor
 * @param useStrictCasing whether to use strict casing
 * @return the JMX attribute name to use
 */
public static String getAttributeName(PropertyDescriptor property, boolean useStrictCasing) {
	if (useStrictCasing) {
		return StringUtils.capitalize(property.getName());
	}
	else {
		return property.getName();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:JmxUtils.java


注:本文中的org.springframework.util.StringUtils.capitalize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。