org.geotools.util.Version.getMajor()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(90)

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

Version.getMajor介绍

[英]Returns the major version number. This method returns an Integer if possible, or a String otherwise.
[中]返回主版本号。如果可能,此方法返回整数,否则返回字符串。

代码示例

代码示例来源:origin: geoserver/geoserver

/**
 * Normalize the version, handling cases like forcing "x.y" to "x.y.z".
 *
 * @param version
 * @return normalized version
 */
public static String normalizeVersion(String version) {
  if (version == null) {
    return null;
  }
  Version v = new Version(version);
  if (v.getMajor() == null) {
    return null;
  }
  if (v.getMinor() == null) {
    return String.format("%d.0.0", ((Number) v.getMajor()).intValue());
  }
  if (v.getRevision() == null) {
    return String.format(
        "%d.%d.0",
        ((Number) v.getMajor()).intValue(), ((Number) v.getMinor()).intValue());
  }
  // version ok
  return version;
}

代码示例来源:origin: org.geoserver.community/gs-nsg-wfs-profile

private boolean isNSGProfileApplicable(Version version) {
  return Integer.valueOf(2).equals(version.getMajor());
}

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

/**
 * Returns the WFS3 featureId, or null if it's missing or the request is not a WFS3 one
 *
 * @return
 */
private String getWFS3FeatureId() {
  Request dr = Dispatcher.REQUEST.get();
  String featureId = null;
  if (dr != null && (new Version(dr.getVersion()).getMajor().equals(3))) {
    Object featureIdValue = dr.getKvp().get("featureId");
    if (featureIdValue instanceof List) {
      featureId = (String) ((List) featureIdValue).get(0);
    }
  }
  return featureId;
}

代码示例来源:origin: org.geoserver.community/gs-nsg-wfs-profile

@Override
  public void onApplicationEvent(ContextRefreshedEvent event) {
    // configure the extra operation in WFS 2.0
    List<Service> services = GeoServerExtensions.extensions(Service.class);
    for (Service s : services) {
      if ("wfs".equals(s.getId().toLowerCase())
          && Integer.valueOf(2).equals(s.getVersion().getMajor())) {
        if (!s.getOperations().contains(PAGE_RESULTS)) {
          s.getOperations().add(PAGE_RESULTS);
        }
      }
    }
  }
}

相关文章