|
@@ -1,11 +1,10 @@ |
1 |
1 |
|
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt |
2 |
2 |
|
package org.litesoft.configuration; |
3 |
3 |
|
|
4 |
|
- |
import org.litesoft.core.util.PersistenceException; |
5 |
|
- |
import org.litesoft.core.util.UtilsCommon; |
6 |
|
- |
|
7 |
4 |
|
import java.util.*; |
8 |
5 |
|
|
|
6 |
+ |
import org.litesoft.core.util.*; |
|
7 |
+ |
|
9 |
8 |
|
public abstract class AbstractConfigDataAccessor implements ConfigDataAccessor |
10 |
9 |
|
{ |
11 |
10 |
|
private final String mLoadedFromDirectory; |
|
@@ -65,7 +64,7 @@ |
65 |
64 |
|
public final synchronized void setKeyValue( Level pLevel, String pKey, String pValue ) |
66 |
65 |
|
throws UnsupportedOperationException |
67 |
66 |
|
{ |
68 |
|
- |
pKey = UtilsCommon.assertNotNullNotEmpty("Key", pKey); |
|
67 |
+ |
pKey = UtilsCommon.assertNotNullNotEmpty( "Key", pKey ); |
69 |
68 |
|
Level zLevel = UtilsCommon.deNull( pLevel, Level.RUN ); |
70 |
69 |
|
if ( Level.RUN.equals( zLevel ) ) |
71 |
70 |
|
{ |
|
@@ -85,9 +84,9 @@ |
85 |
84 |
|
} |
86 |
85 |
|
try |
87 |
86 |
|
{ |
88 |
|
- |
setOtherLevelKeyValue(pKey, pValue); |
|
87 |
+ |
setOtherLevelKeyValue( pKey, pValue ); |
89 |
88 |
|
} |
90 |
|
- |
catch (RuntimeException e) |
|
89 |
+ |
catch ( RuntimeException e ) |
91 |
90 |
|
{ |
92 |
91 |
|
throw new PersistenceException( "Unable to setKeyValue( " + pLevel + ", \"" + pKey + "\", " + pValue + " )" + getExceptionPlus(), e ); |
93 |
92 |
|
} |
|
@@ -95,7 +94,7 @@ |
95 |
94 |
|
|
96 |
95 |
|
abstract protected String getExceptionPlus(); |
97 |
96 |
|
|
98 |
|
- |
abstract protected void setOtherLevelKeyValue(String pKey, String pValue); |
|
97 |
+ |
abstract protected void setOtherLevelKeyValue( String pKey, String pValue ); |
99 |
98 |
|
|
100 |
99 |
|
@Override |
101 |
100 |
|
public final synchronized String[] getAllKeys() |
|
@@ -103,9 +102,9 @@ |
103 |
102 |
|
Set<String> zKeys; |
104 |
103 |
|
try |
105 |
104 |
|
{ |
106 |
|
- |
zKeys = new HashSet<String>(Arrays.asList(getBaseKeys())); |
|
105 |
+ |
zKeys = new HashSet<String>( Arrays.asList( getBaseKeys() ) ); |
107 |
106 |
|
} |
108 |
|
- |
catch (RuntimeException e) |
|
107 |
+ |
catch ( RuntimeException e ) |
109 |
108 |
|
{ |
110 |
109 |
|
throw new PersistenceException( "Unable to getAllKeys()" + getExceptionPlus(), e ); |
111 |
110 |
|
} |
|
@@ -129,28 +128,27 @@ |
129 |
128 |
|
{ |
130 |
129 |
|
return (rv != null) ? rv : getBaseValue( pKey ); |
131 |
130 |
|
} |
132 |
|
- |
catch (RuntimeException e) |
|
131 |
+ |
catch ( RuntimeException e ) |
133 |
132 |
|
{ |
134 |
133 |
|
throw new PersistenceException( "Unable to getString( \"" + pKey + "\" )" + getExceptionPlus(), e ); |
135 |
134 |
|
} |
136 |
135 |
|
} |
137 |
136 |
|
|
138 |
|
- |
protected abstract String getBaseValue(String pKey); |
|
137 |
+ |
protected abstract String getBaseValue( String pKey ); |
139 |
138 |
|
|
140 |
139 |
|
@Override |
141 |
|
- |
public final synchronized void overrideAllStartingWith(String pKeyPrefix, String pValue) |
|
140 |
+ |
public final synchronized void overrideAllStartingWith( String pKeyPrefix, String pValue ) |
142 |
141 |
|
{ |
143 |
142 |
|
if ( null != (pKeyPrefix = UtilsCommon.noEmpty( pKeyPrefix )) ) |
144 |
143 |
|
{ |
145 |
144 |
|
pValue = UtilsCommon.deNull( pValue ); |
146 |
|
- |
for (String zKey : getAllKeys()) |
|
145 |
+ |
for ( String zKey : getAllKeys() ) |
147 |
146 |
|
{ |
148 |
147 |
|
if ( zKey.startsWith( pKeyPrefix ) ) |
149 |
148 |
|
{ |
150 |
|
- |
setKeyValue(Level.RUN, zKey, pValue ); |
|
149 |
+ |
setKeyValue( Level.RUN, zKey, pValue ); |
151 |
150 |
|
} |
152 |
151 |
|
} |
153 |
152 |
|
} |
154 |
153 |
|
} |
155 |
|
- |
|
156 |
154 |
|
} |