All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.pgclient.impl.PgDatabaseMetadata Maven / Gradle / Ivy

There is a newer version: 5.0.0.CR3
Show newest version
package io.vertx.pgclient.impl;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import io.vertx.sqlclient.spi.DatabaseMetadata;

public class PgDatabaseMetadata implements DatabaseMetadata {

  private static final Pattern VERSION_PATTERN = Pattern.compile(
    "^(\\d+)(?:\\.(\\d+))?");

  private final String fullVersion;
  private int majorVersion;
  private int minorVersion;

  public PgDatabaseMetadata(String serverVersion) {
    fullVersion = serverVersion;
    Matcher matcher = VERSION_PATTERN.matcher(serverVersion);
    if (matcher.find()) {
      majorVersion = Integer.parseInt(matcher.group(1));
      String minorPart = matcher.group(2);
      if (minorPart != null) {
        minorVersion = Integer.parseInt(minorPart);
      }
    }
  }

  @Override
  public String productName() {
    return "PostgreSQL";
  }

  @Override
  public String fullVersion() {
    return fullVersion;
  }

  @Override
  public int majorVersion() {
    return majorVersion;
  }

  @Override
  public int minorVersion() {
    return minorVersion;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy