scriptella.spi
Class ConnectionParameters

java.lang.Object
  extended by scriptella.spi.ConnectionParameters

public class ConnectionParameters
extends java.lang.Object

Represents connection parameters.

Version:
1.0
Author:
Fyodor Kupolov

Constructor Summary
protected ConnectionParameters()
          For testing purposes.
  ConnectionParameters(ConnectionEl conf, DriverContext context)
          Creates connection parameters based on <connection> element..
 
Method Summary
 boolean getBooleanProperty(java.lang.String name)
          Parses property value as boolean flag.
 boolean getBooleanProperty(java.lang.String name, boolean defaultValue)
          Parses property value as a boolean flag.
 java.lang.String getCatalog()
           
 java.lang.String getCharsetProperty(java.lang.String name)
          Parses property value as a charset encoding name.
 DriverContext getContext()
          Get a drivers context.
 java.lang.Integer getIntegerProperty(java.lang.String name)
           
 java.lang.Integer getIntegerProperty(java.lang.String name, int defaultValue)
          Returns the value of integer property.
 java.lang.Number getNumberProperty(java.lang.String name, java.lang.Number defaultValue)
          Returns numeric value of the property.
 java.lang.String getPassword()
          Optional user password for connection.
 java.util.Map<java.lang.String,?> getProperties()
          This method returns properties for connection specified inside <connection> element
 java.lang.Object getProperty(java.lang.String name)
          Convenience method which returns property by name.
 java.net.URL getResolvedUrl()
          Returns the url property resolved relative to a script location.
 java.lang.String getSchema()
           
 java.lang.String getStringProperty(java.lang.String name)
          Returns string value of the property.
 java.lang.String getUrl()
          Returns connection URL.
 java.net.URL getUrlProperty(java.lang.String name)
          Parses property value as URL parameter.
 java.util.Map<java.lang.String,java.lang.String> getUrlQueryMap()
          Convenience method which parses URL string, extracts a query string and returns a map of URL query parameters.
 java.lang.String getUser()
          Optional user name for connection.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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 Detail

getProperties

public java.util.Map<java.lang.String,?> getProperties()
This method returns properties for connection specified inside <connection> element

Returns:
properties map.

getProperty

public java.lang.Object getProperty(java.lang.String name)
Convenience method which returns property by name.

Parameters:
name - property name
Returns:
property value
See Also:
getProperties()

getStringProperty

public java.lang.String getStringProperty(java.lang.String name)
Returns string value of the property.

Parameters:
name - property name.
Returns:
property value.

getIntegerProperty

public java.lang.Integer getIntegerProperty(java.lang.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:
getNumberProperty(String,Number)

getIntegerProperty

public java.lang.Integer getIntegerProperty(java.lang.String name)
                                     throws ConfigurationException
Throws:
ConfigurationException

getNumberProperty

public java.lang.Number getNumberProperty(java.lang.String name,
                                          java.lang.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:
Long.decode(String)

getBooleanProperty

public boolean getBooleanProperty(java.lang.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(String,boolean)

getBooleanProperty

public boolean getBooleanProperty(java.lang.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 java.lang.String getCharsetProperty(java.lang.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 java.net.URL getUrlProperty(java.lang.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 java.lang.String getUrl()
Returns connection URL.

URL format is arbitrary and specified by Service Provider.

Returns:
connection URL

getUrlQueryMap

public java.util.Map<java.lang.String,java.lang.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¶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

public java.net.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 java.lang.String getUser()
Optional user name for connection.

Returns:
user name

getPassword

public java.lang.String getPassword()
Optional user password for connection.

Returns:
user password

getSchema

public java.lang.String getSchema()
Returns:
optional schema name

getCatalog

public java.lang.String getCatalog()
Returns:
optional catalog name

getContext

public DriverContext getContext()
Get a drivers context.

Returns:
script context.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © Copyright 2006-2009 The Scriptella Project Team.