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


Java LocalizationUtility.getSimpleName方法代码示例

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


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

示例1: testSimpleClassName

import net.sourceforge.stripes.localization.LocalizationUtility; //导入方法依赖的package包/类
@Test(groups = "fast")
public void testSimpleClassName() throws Exception {
    String output = LocalizationUtility.getSimpleName(TestEnum.class);
    Assert.assertEquals(output, "LocalizationUtilityTest.TestEnum");

    output = LocalizationUtility.getSimpleName(A.B.C.class);
    Assert.assertEquals(output, "LocalizationUtilityTest.A.B.C");
}
 
开发者ID:scarcher2,项目名称:stripes,代码行数:9,代码来源:LocalizationUtilityTest.java

示例2: doStartTag

import net.sourceforge.stripes.localization.LocalizationUtility; //导入方法依赖的package包/类
/**
 * Iterates through the collection and generates the list of Entry objects that can then
 * be sorted and rendered into options. It is assumed that each element in the collection
 * has non-null values for the properties specified for generating the label and value.
 *
 * @return SKIP_BODY in all cases
 * @throws JspException if either the label or value attributes specify properties that are
 *         not present on the beans in the collection
 */
@Override
public int doStartTag() throws JspException {
  if (this.collection == null)
    return SKIP_BODY;

    String labelProperty = getLabel();
    String valueProperty = getValue();
    String groupProperty = getGroup();


    try {
        Locale locale = getPageContext().getRequest().getLocale();
        boolean attemptToLocalizeLabels = isAttemptToLocalizeLabels();

        for (Object item : this.collection) {
            Class<? extends Object> clazz = item.getClass();

            // Lookup the bean properties for the label, value and group
            Object label = (labelProperty == null) ? item : BeanUtil.getPropertyValue(labelProperty, item);
            Object value = (valueProperty == null) ? item : BeanUtil.getPropertyValue(valueProperty, item);
            Object group = (groupProperty == null) ? null : BeanUtil.getPropertyValue(groupProperty, item);

            if (attemptToLocalizeLabels) {
                // Try to localize the label
                String packageName = clazz.getPackage() == null ? "" : clazz.getPackage().getName();
                String simpleName = LocalizationUtility.getSimpleName(clazz);
                String localizedLabel = null;
                if (label != null) {
                    localizedLabel = LocalizationUtility.getLocalizedFieldName
                        (simpleName + "."  + label, packageName, null, locale);
                }
                if (localizedLabel == null && value != null) {
                    localizedLabel = LocalizationUtility.getLocalizedFieldName
                        (simpleName + "."  + value, packageName, null, locale);
                }
                if (localizedLabel != null) label = localizedLabel;

                // Try to localize the group
                if (group != null) {
                    String localizedGroup = LocalizationUtility.getLocalizedFieldName(
                        simpleName + "." + group, packageName, null, locale);
                    if (localizedGroup != null) group = localizedGroup;
                }
            }
            addEntry(item, label, value, group);
        }
    }
    catch (ExpressionException ee) {
        throw new StripesJspException("A problem occurred generating an options-collection. " +
            "Most likely either [" + labelProperty + "] or ["+ valueProperty + "] is not a " +
            "valid property of the beans in the collection: " + this.collection, ee);
    }

    return SKIP_BODY;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:65,代码来源:InputOptionsCollectionTag.java


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