public class ConnectStringParser extends Object
This code was adapted from Mondrian's mondrian.olap.Util class. The primary differences between this and its Mondrian progenitor are:
Properties
for compatibility with the JDBC API
(replaces Mondrian's use of its own order-preserving and case-insensitive
PropertyList)parse(java.lang.String)
a pre-existing Properties object into
which properties are to be parsed, possibly overriding prior valuesSQLException
s rather than unchecked
RuntimeException
sConnectStringParser has a private constructor. Callers use the static members:
parse(String)
parse(String, Properties)
getParamString(Properties)
Modifier and Type | Method and Description |
---|---|
static String |
getParamString(Properties props)
Returns a param string, quoted and escaped as needed, to represent the
supplied name-value pairs.
|
static Properties |
parse(String s)
Parses the connect string into a new Properties object.
|
static Properties |
parse(String s,
Properties props)
Parses the connect string into an existing Properties object.
|
static Map<String,String> |
toMap(Properties properties)
Converts a
Properties object to a . |
public static Properties parse(String s) throws SQLException
s
- connect string to parseSQLException
- error parsing name-value pairspublic static Properties parse(String s, Properties props) throws SQLException
s
- connect string to parseprops
- optional properties object, may be null
props
was supplied, any duplicate properties will have been
replaced by those from the connect string.SQLException
- error parsing name-value pairspublic static String getParamString(Properties props)
props
- name-value pairsnull
public static Map<String,String> toMap(Properties properties)
Properties
object to a Map
<String,
String>
.
This is necessary because Properties
is a dinosaur class. It
ought to extend Map<String,String>
, but instead
extends
.
Hashtable
<Object,Object>
Typical usage, to iterate over a Properties
:
Properties properties;
for (Map.Entry<String, String> entry =
Util.toMap(properties).entrySet()) {
println("key=" + entry.getKey() + ", value=" + entry.getValue());
}
Copyright © 2012-2024 Apache Software Foundation. All Rights Reserved.