Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
giscience
big-data
ohsome
helpers
oshdb database driver
Commits
36a34271
Commit
36a34271
authored
Jun 09, 2020
by
Rafael Troilo
Browse files
change map to properties
parent
c19e8894
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/heigit/ohsome/oshdb/helpers/OSHDBDriver.java
View file @
36a34271
...
...
@@ -2,7 +2,7 @@ package org.heigit.ohsome.oshdb.helpers;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.util.
Map
;
import
java.util.
Properties
;
import
java.util.function.Consumer
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
...
...
@@ -45,7 +45,7 @@ public class OSHDBDriver {
* multithreading=true
* }</pre>
*/
public
static
void
connect
(
Map
<
String
,
String
>
props
,
Consumer
<
OSHDBConnection
>
connect
)
public
static
void
connect
(
Properties
props
,
Consumer
<
OSHDBConnection
>
connect
)
throws
Exception
{
String
oshdb
=
getInterpolated
(
props
,
"oshdb"
);
if
(
oshdb
==
null
)
{
...
...
@@ -133,13 +133,13 @@ public class OSHDBDriver {
private
static
final
Pattern
substitute
=
Pattern
.
compile
(
"\\$\\{(\\w+)\\}"
);
private
static
String
getInterpolated
(
Map
<
String
,
String
>
props
,
String
key
)
{
private
static
String
getInterpolated
(
Properties
props
,
String
key
)
{
return
getInterpolated
(
props
,
key
,
null
);
}
private
static
String
getInterpolated
(
Map
<
String
,
String
>
props
,
String
key
,
private
static
String
getInterpolated
(
Properties
props
,
String
key
,
String
defaultValue
)
{
String
value
=
props
.
get
(
key
);
String
value
=
props
.
get
Property
(
key
);
if
(
value
==
null
)
{
return
defaultValue
;
}
...
...
@@ -147,7 +147,7 @@ public class OSHDBDriver {
StringBuffer
sb
=
new
StringBuffer
();
while
(
matcher
.
find
())
{
String
sub
=
matcher
.
group
(
1
);
matcher
.
appendReplacement
(
sb
,
props
.
get
OrDefault
(
sub
,
"\\${"
+
sub
+
"}"
));
matcher
.
appendReplacement
(
sb
,
props
.
get
Property
(
sub
,
"\\${"
+
sub
+
"}"
));
}
matcher
.
appendTail
(
sb
);
return
sb
.
toString
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment