本文整理匯總了Java中org.apache.commons.lang3.StringUtils.capitalize方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.capitalize方法的具體用法?Java StringUtils.capitalize怎麽用?Java StringUtils.capitalize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.capitalize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDisplayName
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* @param locale ISO Language identifier
* @return Human readable language name in the target language
*/
public String getDisplayName(final String locale) {
java.util.Locale l;
if(StringUtils.contains(locale, "_")) {
l = new java.util.Locale(locale.split("_")[0], locale.split("_")[1]);
}
else {
l = new java.util.Locale(locale);
}
return StringUtils.capitalize(l.getDisplayName(l));
}
示例2: buildSearchTermQuery
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* Returns a {@link BooleanQuery} for the given search text.
*
* @param indexType the type in which should be searched.
* @param search the search text.
* @param baseBoost highest possible boost of the query. The more the match is exact
* than a bigger boost will be used.
*/
private static BooleanQuery buildSearchTermQuery(final IIndexTypeConf indexType, final String search,
final float baseBoost) {
final BooleanQuery subQuery = new BooleanQuery();
final String lowerCase = StringUtils.lowerCase(search);
final String capitalized = StringUtils.capitalize(search);
addSearchTermQueries(indexType, search, subQuery, baseBoost);
if(!lowerCase.equals(search)) {
addSearchTermQueries(indexType, lowerCase, subQuery, 0.8f*baseBoost);
}
if(!capitalized.equals(search)) {
addSearchTermQueries(indexType, capitalized, subQuery, 0.8f*baseBoost);
}
return subQuery;
}
示例3: process
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@Override
public void process(final ExecutionContext executionContext, TemplateContentModel contentModel)
throws ProcessException {
try {
SlingHttpServletRequest request = (SlingHttpServletRequest) executionContext.get(SLING_HTTP_REQUEST);
if (contentModel.has(CONFIG_GLOBAL_IMAGE_KEY)) {
String globalImageName = contentModel.getAsString(CONFIG_GLOBAL_IMAGE_KEY);
if (contentModel.has(COMPONENT_GLOBAL_DIALOG_PATH) && StringUtils.isNotEmpty(globalImageName)) {
String imageResourcePath = contentModel.getAsString(COMPONENT_GLOBAL_DIALOG_PATH) + SLASH + globalImageName;
Resource imageResource = request.getResourceResolver().getResource(request.getResource(),
imageResourcePath);
if (null != imageResource) {
String imagePath = assetPathService.getComponentImagePath(imageResource);
String globalImagePathPropertyName = globalImageName + StringUtils.capitalize(IMAGE_PATH);
contentModel.set(GLOBAL_PROPERTIES_KEY + DOT + globalImagePathPropertyName, imagePath);
}
}
}
} catch (Exception e) {
throw new ProcessException(e);
}
}
示例4: populate
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
public static <T> T populate(final Properties properties, final T obj) {
Class<?> clazz = obj.getClass();
try {
Set<Map.Entry<Object, Object>> entries = properties.entrySet();
for (Map.Entry<Object, Object> entry : entries) {
String entryKey = entry.getKey().toString();
String[] keyGroup = entryKey.split("\\.");
for (int i = 0; i < keyGroup.length; i++) {
keyGroup[i] = keyGroup[i].toLowerCase();
keyGroup[i] = StringUtils.capitalize(keyGroup[i]);
}
String beanFieldNameWithCapitalization = StringUtils.join(keyGroup);
try {
setProperties(clazz, obj, "set" + beanFieldNameWithCapitalization, entry.getValue());
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
//ignored...
}
}
} catch (RuntimeException e) {
log.warn("Error occurs !", e);
}
return obj;
}
示例5: transformCase
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* @param description
* @return
*/
private static String transformCase(String description, Options options) {
String descTemp = description;
switch (options.getCasingType()) {
case Sentence:
descTemp = StringUtils.upperCase("" + descTemp.charAt(0)) + descTemp.substring(1);
break;
case Title:
descTemp = StringUtils.capitalize(descTemp);
break;
default:
descTemp = descTemp.toLowerCase();
break;
}
return descTemp;
}
示例6: updatePost
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@RequestMapping(value = "/update/{postId}", method = GET)
public String updatePost(@PathVariable("postId") Long postId,
Model model, HttpServletRequest request) throws PostNotFoundException {
Post post = postService.getPostById(postId);
String postType = StringUtils.capitalize(post.getPostType().name().toLowerCase());
String pageTitle = webUI.getMessage(MESSAGE_ADMIN_UPDATE_POSTLINK_TITLE, postType);
String pageHeading = webUI.getMessage(MESSAGE_ADMIN_UPDATE_POSTLINK_HEADING, postType);
PostDTO postDTO = getUpdatedPostDTO(post);
if (post.getPostType() == PostType.LINK) {
postDTO.setHasImages(post.getPostImage() != null);
postDTO.setPostImage(post.getPostImage());
if (postDTO.getHasImages()) {
model.addAttribute("hasLinkImage", true);
}
}
model.addAttribute("postName", post.getPostName());
model.addAttribute("postDTO", postDTO);
model.addAttribute("pageTitle", pageTitle);
model.addAttribute("pageHeading", pageHeading);
model.addAttribute("categories", postService.getAdminSelectionCategories());
model.addAllAttributes(getPostLinkAttributes(request, post.getPostType()));
return ADMIN_POSTLINK_UPDATE_VIEW;
}
示例7: invokeSetter
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* 調用Setter方法, 僅匹配方法名。
* 支持多級,如:對象名.對象名.方法
*/
public static void invokeSetter(Object obj, String propertyName, Object value) {
Object object = obj;
String[] names = StringUtils.split(propertyName, ".");
for (int i = 0; i < names.length; i++) {
if (i < names.length - 1) {
String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]);
object = invokeMethod(object, getterMethodName, new Class[]{}, new Object[]{});
} else {
String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]);
invokeMethodByName(object, setterMethodName, new Object[]{value});
}
}
}
示例8: invokeSetter
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* 調用Setter方法, 僅匹配方法名。
* 支持多級,如:對象名.對象名.方法
*
* @param obj the obj
* @param propertyName the property name
* @param value the value
*/
public static void invokeSetter(Object obj, String propertyName, Object value) {
Object object = obj;
String[] names = StringUtils.split(propertyName, ".");
for (int i = 0; i < names.length; i++) {
if (i < names.length - 1) {
String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]);
object = invokeMethod(object, getterMethodName, new Class[]{}, new Object[]{});
} else {
String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]);
invokeMethodByName(object, setterMethodName, new Object[]{value});
}
}
}
示例9: toCamelCase
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
private static String toCamelCase(String value, boolean startWithLowerCase) {
String[] strings = StringUtils.split(value.toLowerCase(), "_");
for (int i = startWithLowerCase ? 1 : 0; i < strings.length; i++) {
strings[i] = StringUtils.capitalize(strings[i]);
}
return StringUtils.join(strings);
}
示例10: invokeGetter
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* 調用Getter方法.
* 支持多級,如:對象名.對象名.方法
*/
public static Object invokeGetter(Object obj, String propertyName) {
Object object = obj;
for (String name : StringUtils.split(propertyName, ".")){
String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name);
object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
}
return object;
}
示例11: invokeGetter
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* 調用Getter方法.
* 支持多級,如:對象名.對象名.方法
*/
public static Object invokeGetter(Object obj, String propertyName) {
Object object = obj;
for (String name : StringUtils.split(propertyName, ".")){
String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name);
object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
}
return object;
}
示例12: WoodMaterial
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
public WoodMaterial(String name, float hardness, float strength, int meta) {
this.hardness = hardness;
this.strength = strength;
this.identifier = name;
this.titleName = StringUtils.capitalize(name);
this.enumName = (GotWood.ID + "_" + name).toUpperCase(Locale.ENGLISH);
this.blastResistance = 2.5f * this.strength;
this.meta = meta;
}
示例13: invokeSetter
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* 調用Setter方法, 僅匹配方法名。
* 支持多級,如:對象名.對象名.方法
* @param obj 執行對象
* @param propertyName 屬性名稱
* @param value 屬性值
*/
public static void invokeSetter(Object obj, String propertyName, Object value) {
Object object = obj;
String[] names = StringUtils.split(propertyName, ".");
for (int i=0; i<names.length; i++){
if(i<names.length-1){
String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]);
object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
}else{
String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]);
invokeMethodByName(object, setterMethodName, new Object[] { value });
}
}
}
示例14: getGetterMethod
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* 循環遍曆,按屬性名獲取前綴為set的函數,並設為可訪問
*/
public static Method getGetterMethod(Class<?> clazz, String propertyName) {
String getterMethodName = ClassUtil.GETTER_PREFIX + StringUtils.capitalize(propertyName);
Method method = ClassUtil.getAccessibleMethod(clazz, getterMethodName);
// retry on another name
if (method == null) {
getterMethodName = ClassUtil.IS_PREFIX + StringUtils.capitalize(propertyName);
method = ClassUtil.getAccessibleMethod(clazz, getterMethodName);
}
return method;
}
示例15: invokeGetter
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* 調用Getter方法.
* 支持多級,如:對象名.對象名.方法
*/
public static Object invokeGetter(Object obj, String propertyName) {
Object object = obj;
for (String name : StringUtils.split(propertyName, ".")) {
String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name);
object = invokeMethod(object, getterMethodName, new Class[]{}, new Object[]{});
}
return object;
}