Class PostGISConnectionOptions

java.lang.Object
nz.org.riskscape.postgis.PostGISConnectionOptions

public class PostGISConnectionOptions extends Object

Contains values to use when connecting to the PostGIS database.

  • Field Details

    • URI_SCHEME

      public static final String URI_SCHEME

      URI scheme for RiskScape's postgis URIs

      See Also:
    • ENV_PGPASSWORD

      public static final String ENV_PGPASSWORD

      Name of environment variable containing a password

      See Also:
    • DEFAULT_PSQL_PORT

      public static final int DEFAULT_PSQL_PORT

      Postgres listens on this port by default

      See Also:
  • Constructor Details

    • PostGISConnectionOptions

      public PostGISConnectionOptions()
  • Method Details

    • setLocation

      public void setLocation(URI fromLocation)

      Parse the given location as a RiskScape specific-ish postgis URI.

      The given URI is expected to be of the form 'postgis://USER[:PASSWORD]@HOST[:PORT]/DATABASE'. Any warnings from parsing the URI are preserved for validation later.

      Parameters:
      fromLocation - to parse
    • setEnvironment

      public void setEnvironment(Map<String,String> env)
    • validate

      public nz.org.riskscape.problem.ResultOrProblems<PostGISConnectionOptions> validate()

      Validate this set of connection options, including any issues with the location (if specified)

      Returns:
      this options object, wrapped up with any warnings, if the options are good enough to generate a valid jdbc uri. Will return a failed result if there are missing fields.
    • toJdbcUri

      public String toJdbcUri()
      Returns:
      a uri suitable for use with constructing a JDBC datasource. Note that this might do terrible things if the options are not valid.
    • toLocation

      public URI toLocation()

      Get a location URI that is broadly equivalent to point to the same DB. Exceptions are that the password is never included, but the port is always included.

    • getLocation

      public URI getLocation()
    • getHost

      public String getHost()
    • setHost

      public void setHost(String host)
    • getPort

      public int getPort()
    • setPort

      public void setPort(int port)
    • getDatabase

      public String getDatabase()
    • setDatabase

      public void setDatabase(String database)
    • getUser

      public String getUser()
    • setUser

      public void setUser(String user)
    • getPassword

      public String getPassword()
    • setPassword

      public void setPassword(String password)