Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
da2ab0d2
Commit
da2ab0d2
authored
16 years ago
by
ribeaudc
Browse files
Options
Downloads
Patches
Plain Diff
change: - Parameters in 'datamover' refactored.
SVN: 6055
parent
f86221ba
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/source/java/ch/systemsx/cisd/common/utilities/PropertyUtils.java
+31
-8
31 additions, 8 deletions
...java/ch/systemsx/cisd/common/utilities/PropertyUtils.java
with
31 additions
and
8 deletions
common/source/java/ch/systemsx/cisd/common/utilities/PropertyUtils.java
+
31
−
8
View file @
da2ab0d2
...
@@ -67,6 +67,30 @@ public final class PropertyUtils
...
@@ -67,6 +67,30 @@ public final class PropertyUtils
assert
propertyKey
!=
null
:
"Given property key can not be null."
;
assert
propertyKey
!=
null
:
"Given property key can not be null."
;
}
}
/**
* Searches for the property with the specified key in this property list.
*
* @return <code>null</code> or the value trimmed if found.
*/
public
final
static
String
getProperty
(
final
Properties
properties
,
final
String
propertyKey
)
{
assertParameters
(
properties
,
propertyKey
);
final
String
property
=
properties
.
getProperty
(
propertyKey
);
return
property
==
null
?
null
:
property
.
trim
();
}
/**
* Searches for the property with the specified key in this property list.
*
* @return <code>null</code> or the value trimmed if found.
*/
public
final
static
String
getProperty
(
final
Properties
properties
,
final
String
propertyKey
,
final
String
defaultValue
)
{
final
String
property
=
getProperty
(
properties
,
propertyKey
);
return
property
==
null
?
defaultValue
:
property
;
}
/**
/**
* Looks up given mandatory <var>propertyKey</var> in given <var>properties</var>.
* Looks up given mandatory <var>propertyKey</var> in given <var>properties</var>.
*
*
...
@@ -77,14 +101,13 @@ public final class PropertyUtils
...
@@ -77,14 +101,13 @@ public final class PropertyUtils
final
String
propertyKey
)
throws
ConfigurationFailureException
final
String
propertyKey
)
throws
ConfigurationFailureException
{
{
assertParameters
(
properties
,
propertyKey
);
assertParameters
(
properties
,
propertyKey
);
String
property
=
properties
.
getProperty
(
propertyKey
);
String
property
=
getProperty
(
properties
,
propertyKey
);
if
(
property
==
null
)
if
(
property
==
null
)
{
{
throw
ConfigurationFailureException
.
fromTemplate
(
NOT_FOUND_PROPERTY_FORMAT
,
throw
ConfigurationFailureException
.
fromTemplate
(
NOT_FOUND_PROPERTY_FORMAT
,
propertyKey
,
CollectionUtils
.
abbreviate
(
Collections
.
list
(
properties
propertyKey
,
CollectionUtils
.
abbreviate
(
Collections
.
list
(
properties
.
propertyNames
()),
10
));
.
propertyNames
()),
10
));
}
}
property
=
property
.
trim
();
if
(
property
.
length
()
==
0
)
if
(
property
.
length
()
==
0
)
{
{
throw
ConfigurationFailureException
.
fromTemplate
(
EMPTY_STRING_FORMAT
,
propertyKey
);
throw
ConfigurationFailureException
.
fromTemplate
(
EMPTY_STRING_FORMAT
,
propertyKey
);
...
@@ -101,7 +124,7 @@ public final class PropertyUtils
...
@@ -101,7 +124,7 @@ public final class PropertyUtils
final
long
defaultValue
,
final
ISimpleLogger
loggerOrNull
)
final
long
defaultValue
,
final
ISimpleLogger
loggerOrNull
)
{
{
assertParameters
(
properties
,
propertyKey
);
assertParameters
(
properties
,
propertyKey
);
final
String
longOrNull
=
properties
.
getProperty
(
propertyKey
);
final
String
longOrNull
=
getProperty
(
properties
,
propertyKey
);
if
(
longOrNull
==
null
)
if
(
longOrNull
==
null
)
{
{
return
defaultValue
;
return
defaultValue
;
...
@@ -139,7 +162,7 @@ public final class PropertyUtils
...
@@ -139,7 +162,7 @@ public final class PropertyUtils
{
{
assertParameters
(
properties
,
propertyKey
);
assertParameters
(
properties
,
propertyKey
);
assert
defaultValue
>
-
1
:
"Negative default value (< 0)."
;
assert
defaultValue
>
-
1
:
"Negative default value (< 0)."
;
final
String
longOrNull
=
properties
.
getProperty
(
propertyKey
);
final
String
longOrNull
=
getProperty
(
properties
,
propertyKey
);
if
(
longOrNull
==
null
)
if
(
longOrNull
==
null
)
{
{
return
defaultValue
;
return
defaultValue
;
...
@@ -176,7 +199,7 @@ public final class PropertyUtils
...
@@ -176,7 +199,7 @@ public final class PropertyUtils
final
int
defaultValue
,
final
ISimpleLogger
loggerOrNull
)
final
int
defaultValue
,
final
ISimpleLogger
loggerOrNull
)
{
{
assertParameters
(
properties
,
propertyKey
);
assertParameters
(
properties
,
propertyKey
);
final
String
intOrNull
=
properties
.
getProperty
(
propertyKey
);
final
String
intOrNull
=
getProperty
(
properties
,
propertyKey
);
if
(
intOrNull
==
null
)
if
(
intOrNull
==
null
)
{
{
return
defaultValue
;
return
defaultValue
;
...
@@ -214,7 +237,7 @@ public final class PropertyUtils
...
@@ -214,7 +237,7 @@ public final class PropertyUtils
{
{
assertParameters
(
properties
,
propertyKey
);
assertParameters
(
properties
,
propertyKey
);
assert
defaultValue
>
-
1
:
"Negative default value (< 0)."
;
assert
defaultValue
>
-
1
:
"Negative default value (< 0)."
;
final
String
intOrNull
=
properties
.
getProperty
(
propertyKey
);
final
String
intOrNull
=
getProperty
(
properties
,
propertyKey
);
if
(
intOrNull
==
null
)
if
(
intOrNull
==
null
)
{
{
return
defaultValue
;
return
defaultValue
;
...
@@ -251,7 +274,7 @@ public final class PropertyUtils
...
@@ -251,7 +274,7 @@ public final class PropertyUtils
final
boolean
defaultValue
,
final
ISimpleLogger
loggerOrNull
)
final
boolean
defaultValue
,
final
ISimpleLogger
loggerOrNull
)
{
{
assertParameters
(
properties
,
propertyKey
);
assertParameters
(
properties
,
propertyKey
);
final
String
booleanOrNull
=
properties
.
getProperty
(
propertyKey
);
final
String
booleanOrNull
=
getProperty
(
properties
,
propertyKey
);
if
(
booleanOrNull
==
null
)
if
(
booleanOrNull
==
null
)
{
{
return
defaultValue
;
return
defaultValue
;
...
@@ -289,7 +312,7 @@ public final class PropertyUtils
...
@@ -289,7 +312,7 @@ public final class PropertyUtils
final
char
defaultValue
,
final
ISimpleLogger
loggerOrNull
)
final
char
defaultValue
,
final
ISimpleLogger
loggerOrNull
)
{
{
assertParameters
(
properties
,
propertyKey
);
assertParameters
(
properties
,
propertyKey
);
final
String
charOrNull
=
properties
.
getProperty
(
propertyKey
);
final
String
charOrNull
=
getProperty
(
properties
,
propertyKey
);
if
(
charOrNull
==
null
)
if
(
charOrNull
==
null
)
{
{
return
defaultValue
;
return
defaultValue
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment