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


Java StringUtils.capitalize方法代碼示例

本文整理匯總了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));
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:15,代碼來源:Preferences.java

示例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;
}
 
開發者ID:XMBomb,項目名稱:InComb,代碼行數:28,代碼來源:QueryUtil.java

示例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);
    }
}
 
開發者ID:DantaFramework,項目名稱:AEM,代碼行數:26,代碼來源:AddTransformedImagePathFromGlobalContextProcessor.java

示例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;
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:25,代碼來源:BeanUtils.java

示例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;
}
 
開發者ID:quanticc,項目名稱:sentry,代碼行數:20,代碼來源:CronExpressionDescriptor.java

示例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;
}
 
開發者ID:mintster,項目名稱:nixmash-blog,代碼行數:27,代碼來源:AdminPostsController.java

示例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});
        }
    }
}
 
開發者ID:wxiaoqi,項目名稱:ace-cache,代碼行數:18,代碼來源:ReflectionUtils.java

示例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});
        }
    }
}
 
開發者ID:ruyangit,項目名稱:angit,代碼行數:22,代碼來源:Reflections.java

示例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);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:8,代碼來源:SystemMetricsCollectorWebResource.java

示例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;
}
 
開發者ID:thebeastshop,項目名稱:liteBatch,代碼行數:13,代碼來源:Reflections.java

示例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;
}
 
開發者ID:sombie007,項目名稱:ExcelHandle,代碼行數:13,代碼來源:Reflections.java

示例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;
}
 
開發者ID:MinecraftModDevelopmentMods,項目名稱:Got-Wood,代碼行數:10,代碼來源:WoodMaterial.java

示例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 });
		}
	}
}
 
開發者ID:javahaohao,項目名稱:gen_code,代碼行數:21,代碼來源:AnalysisObject.java

示例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;
}
 
開發者ID:zhangjunfang,項目名稱:util,代碼行數:16,代碼來源:ClassUtil.java

示例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;
}
 
開發者ID:wxiaoqi,項目名稱:ace-cache,代碼行數:13,代碼來源:ReflectionUtils.java


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