Package scriptella.spi
Class ConnectionParameters
java.lang.Object
scriptella.spi.ConnectionParameters
Represents connection parameters.
- Version:
- 1.0
- Author:
- Fyodor Kupolov
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFor testing purposes.ConnectionParameters(ConnectionEl conf, DriverContext context) Creates connection parameters based on <connection> element.. -
Method Summary
Modifier and TypeMethodDescriptionbooleangetBooleanProperty(String name) Parses property value as boolean flag.booleangetBooleanProperty(String name, boolean defaultValue) Parses property value as a boolean flag.getCharsetProperty(String name) Parses property value as a charset encoding name.Get a drivers context.getIntegerProperty(String name) getIntegerProperty(String name, int defaultValue) Returns the value of integer property.getNumberProperty(String name, Number defaultValue) Returns numeric value of the property.Optional user password for connection.This method returns properties for connection specified inside <connection> elementgetProperty(String name) Convenience method which returns property by name.Returns the url property resolved relative to a script location.getStringProperty(String name) Returns string value of the property.getUrl()Returns connection URL.getUrlProperty(String name) Parses property value as URL parameter.Convenience method which parses URL string, extracts a query string and returns a map of URL query parameters.getUser()Optional user name for connection.toString()
-
Constructor Details
-
ConnectionParameters
protected ConnectionParameters()For testing purposes. -
ConnectionParameters
Creates connection parameters based on <connection> element..- Parameters:
conf- connection declaration element.context- driver context.
-
-
Method Details
-
getProperties
This method returns properties for connection specified inside <connection> element- Returns:
- properties map.
-
getProperty
Convenience method which returns property by name.- Parameters:
name- property name- Returns:
- property value
- See Also:
-
getStringProperty
Returns string value of the property.- Parameters:
name- property name.- Returns:
- property value.
-
getIntegerProperty
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
- Throws:
ConfigurationException
-
getNumberProperty
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
Parses property value as boolean flag. Default value isfalse.- Parameters:
name- property name.- Returns:
- boolean property value.
- Throws:
ConfigurationException- if property has unrecognized value.- See Also:
-
getBooleanProperty
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
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
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
Returns connection URL.URL format is arbitrary and specified by Service Provider.
- Returns:
- connection URL
-
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¶m2=value¶m3
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
Returns the url property resolved relative to a script location.- Returns:
- resolved URL.
- Throws:
ConfigurationException- if connection URL is malformed or null.
-
getUser
Optional user name for connection.- Returns:
- user name
-
getPassword
Optional user password for connection.- Returns:
- user password
-
getSchema
- Returns:
- optional schema name
-
getCatalog
- Returns:
- optional catalog name
-
getContext
Get a drivers context.- Returns:
- script context.
-
toString
-