org.geoserver.wms.GetLegendGraphicRequest.getLocale()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(1.4k)|赞(0)|评价(0)|浏览(82)

本文整理了Java中org.geoserver.wms.GetLegendGraphicRequest.getLocale()方法的一些代码示例,展示了GetLegendGraphicRequest.getLocale()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GetLegendGraphicRequest.getLocale()方法的具体详情如下:
包路径:org.geoserver.wms.GetLegendGraphicRequest
类名称:GetLegendGraphicRequest
方法名:getLocale

GetLegendGraphicRequest.getLocale介绍

[英]Gets the locale to be used for text in output (null to use default locale).
[中]获取要用于输出中文本的区域设置(null表示使用默认区域设置)。

代码示例

代码示例来源:origin: org.geoserver/gs-wms

static String getRuleLabel(Rule rule, GetLegendGraphicRequest req) {
    // What's the label on this rule? We prefer to use
    // the 'title' if it's available, but fall-back to 'name'
    final Description description = rule.getDescription();

    String label = "";
    if (description != null && description.getTitle() != null) {
      final InternationalString title = description.getTitle();
      if (req.getLocale() != null) {
        label = title.toString(req.getLocale());
      } else {
        label = title.toString();
      }
    } else if (rule.getName() != null) {
      label = rule.getName();
    }
    return label;
  }
}

代码示例来源:origin: org.geoserver/gs-wms

@org.junit.Test
public void testLanguage() throws Exception {
  GetLegendGraphicRequest request;
  request =
      requestReader.read(
          new GetLegendGraphicRequest(), requiredParameters, requiredParameters);
  assertNull(request.getLocale());
  request = requestReader.read(new GetLegendGraphicRequest(), allParameters, allParameters);
  assertEquals(Locale.ENGLISH, request.getLocale());
}

相关文章