Class ConnectionParameters

java.lang.Object
scriptella.spi.ConnectionParameters

public class ConnectionParameters extends Object
Represents connection parameters.
Version:
1.0
Author:
Fyodor Kupolov
  • Constructor Details

    • ConnectionParameters

      protected ConnectionParameters()
      For testing purposes.
    • ConnectionParameters

      public ConnectionParameters(ConnectionEl conf, DriverContext context)
      Creates connection parameters based on <connection> element..
      Parameters:
      conf - connection declaration element.
      context - driver context.
  • Method Details

    • getProperties

      public Map<String,?> getProperties()
      This method returns properties for connection specified inside <connection> element
      Returns:
      properties map.
    • getProperty

      public Object getProperty(String name)
      Convenience method which returns property by name.
      Parameters:
      name - property name
      Returns:
      property value
      See Also:
    • getStringProperty

      public String getStringProperty(String name)
      Returns string value of the property.
      Parameters:
      name - property name.
      Returns:
      property value.
    • getIntegerProperty

      public Integer getIntegerProperty(String name, int defaultValue) throws ConfigurationException
      Returns the value of integer property.
      Parameters:
      name - name of the property.
      defaultValue - default value if property is absent.
      Returns:
      property value.
      Throws:
      ConfigurationException - if parsing failed.
      See Also:
    • getIntegerProperty

      public Integer getIntegerProperty(String name) throws ConfigurationException
      Throws:
      ConfigurationException
    • getNumberProperty

      public Number getNumberProperty(String name, Number defaultValue) throws ConfigurationException
      Returns numeric value of the property.

      Accepts decimal, hexadecimal, and octal numbers if property is String.

      Parameters:
      name - property name.
      defaultValue - default value to use when property omitted.
      Returns:
      numeric property value.
      Throws:
      ConfigurationException - if parsing failed.
      See Also:
    • getBooleanProperty

      public boolean getBooleanProperty(String name) throws ConfigurationException
      Parses property value as boolean flag. Default value is false.
      Parameters:
      name - property name.
      Returns:
      boolean property value.
      Throws:
      ConfigurationException - if property has unrecognized value.
      See Also:
    • getBooleanProperty

      public boolean getBooleanProperty(String name, boolean defaultValue) throws ConfigurationException
      Parses property value as a boolean flag.
      Parameters:
      name - property name.
      defaultValue - default value to use if connection has no such property.
      Returns:
      boolean property value.
      Throws:
      ConfigurationException - if property has unrecognized value.
    • getCharsetProperty

      public String getCharsetProperty(String name) throws ConfigurationException
      Parses property value as a charset encoding name.
      Parameters:
      name - property name.
      Returns:
      value of the property or null if connection has no such property.
      Throws:
      ConfigurationException - if charset name is unsupported.
    • getUrlProperty

      public URL getUrlProperty(String name) throws ConfigurationException
      Parses property value as URL parameter.

      Relative URIs are resolved using a script file location as a base.

      Parameters:
      name - property name
      Returns:
      value of the property or null if connection has no such property.
      Throws:
      ConfigurationException - if URL is malformed.
    • getUrl

      public String getUrl()
      Returns connection URL.

      URL format is arbitrary and specified by Service Provider.

      Returns:
      connection URL
    • getUrlQueryMap

      public Map<String,String> getUrlQueryMap()
      Convenience method which parses URL string, extracts a query string and returns a map of URL query parameters.

      The query is assumed to have the following syntax: ?param=value&param2=value&param3

      If parameter is declared twice, only the last value is returned in a map. If parameter has only a key, but no value part than the returned map would contain key=key mapping, e.g. jdbc:url?readonly produces a map of 1 entry readonly=readonly.

      The drivers may use this method to support overriding connection parameters in an URL string.

      Returns:
      map of parsed parameters.
    • getResolvedUrl

      public URL getResolvedUrl() throws ConfigurationException
      Returns the url property resolved relative to a script location.
      Returns:
      resolved URL.
      Throws:
      ConfigurationException - if connection URL is malformed or null.
    • getUser

      public String getUser()
      Optional user name for connection.
      Returns:
      user name
    • getPassword

      public String getPassword()
      Optional user password for connection.
      Returns:
      user password
    • getSchema

      public String getSchema()
      Returns:
      optional schema name
    • getCatalog

      public String getCatalog()
      Returns:
      optional catalog name
    • getContext

      public DriverContext getContext()
      Get a drivers context.
      Returns:
      script context.
    • toString

      public String toString()
      Overrides:
      toString in class Object