|
@@ -3,88 +3,41 @@ |
3 |
3 |
|
|
4 |
4 |
|
import java.util.*; |
5 |
5 |
|
|
|
6 |
+ |
import apple.util.Utils; |
6 |
7 |
|
import org.litesoft.core.util.*; |
7 |
8 |
|
|
8 |
|
- |
public class MapConfigDataAccessor implements ConfigDataAccessor |
|
9 |
+ |
public class MapConfigDataAccessor extends AbstractConfigDataAccessor |
9 |
10 |
|
{ |
10 |
|
- |
private final Map<String, String> mKeyValues = new HashMap<String, String>(); |
11 |
|
- |
private String mLoadedFrom; |
12 |
|
- |
|
13 |
11 |
|
public MapConfigDataAccessor( String pLoadedFrom, Map<String, String> pKeyValues ) |
14 |
12 |
|
{ |
15 |
|
- |
mLoadedFrom = pLoadedFrom; |
|
13 |
+ |
super( null, pLoadedFrom, null ); |
16 |
14 |
|
if ( null != pKeyValues ) |
17 |
15 |
|
{ |
18 |
|
- |
mKeyValues.putAll( pKeyValues ); |
|
16 |
+ |
mRunLevelKeyValues.putAll( pKeyValues ); |
19 |
17 |
|
} |
20 |
18 |
|
} |
21 |
19 |
|
|
22 |
20 |
|
@Override |
23 |
|
- |
public String loadedFrom() |
24 |
|
- |
{ |
25 |
|
- |
return mLoadedFrom; |
26 |
|
- |
} |
27 |
|
- |
|
28 |
|
- |
@Override |
29 |
|
- |
public String loadedFromDirectory() |
30 |
|
- |
{ |
31 |
|
- |
return null; |
32 |
|
- |
} |
33 |
|
- |
|
34 |
|
- |
@Override |
35 |
|
- |
public Level[] getSetableSupportedLevels() |
|
21 |
+ |
protected String getExceptionPlus() |
36 |
22 |
|
{ |
37 |
|
- |
return new Level[]{Level.RUN}; |
|
23 |
+ |
return ""; |
38 |
24 |
|
} |
39 |
25 |
|
|
40 |
26 |
|
@Override |
41 |
|
- |
public void setKeyValue( Level pLevel, String pKey, String pValue ) |
42 |
|
- |
throws UnsupportedOperationException |
|
27 |
+ |
protected String[] getBaseKeys() |
43 |
28 |
|
{ |
44 |
|
- |
pKey = UtilsCommon.assertNotNullNotEmpty( "Key", pKey ); |
45 |
|
- |
if ( !Level.RUN.equals( UtilsCommon.deNull( pLevel, Level.RUN ) ) ) |
46 |
|
- |
{ |
47 |
|
- |
throw new UnsupportedOperationException( "setKeyValue for Level '" + pLevel + "' not supported" ); |
48 |
|
- |
} |
49 |
|
- |
synchronized ( mKeyValues ) |
50 |
|
- |
{ |
51 |
|
- |
mKeyValues.put( pKey, pValue ); |
52 |
|
- |
} |
|
29 |
+ |
return UtilsCommon.EMPTY_STRING_ARRAY; |
53 |
30 |
|
} |
54 |
31 |
|
|
55 |
32 |
|
@Override |
56 |
|
- |
public String[] getAllKeys() |
|
33 |
+ |
protected void setOtherLevelKeyValue(String pKey, String pValue) |
57 |
34 |
|
{ |
58 |
|
- |
synchronized ( mKeyValues ) |
59 |
|
- |
{ |
60 |
|
- |
return mKeyValues.isEmpty() ? // |
61 |
|
- |
UtilsCommon.EMPTY_STRING_ARRAY : // |
62 |
|
- |
mKeyValues.keySet().toArray( new String[mKeyValues.size()] ); |
63 |
|
- |
} |
|
35 |
+ |
throw new IllegalStateException("Huh"); |
64 |
36 |
|
} |
65 |
37 |
|
|
66 |
38 |
|
@Override |
67 |
|
- |
public String getString( String pKey ) |
68 |
|
- |
{ |
69 |
|
- |
synchronized ( mKeyValues ) |
70 |
|
- |
{ |
71 |
|
- |
return (pKey == null) ? null : mKeyValues.get( pKey ); |
72 |
|
- |
} |
73 |
|
- |
} |
74 |
|
- |
|
75 |
|
- |
public void replace( String pLinesStartingWith, String... pKeyValuePairs ) |
|
39 |
+ |
protected String getBaseValue(String pKey) |
76 |
40 |
|
{ |
77 |
|
- |
synchronized ( mKeyValues ) |
78 |
|
- |
{ |
79 |
|
- |
String[] zKeys = mKeyValues.keySet().toArray( new String[mKeyValues.size()] ); |
80 |
|
- |
for ( String zKey : zKeys ) |
81 |
|
- |
{ |
82 |
|
- |
if ( zKey.startsWith( pLinesStartingWith ) ) |
83 |
|
- |
{ |
84 |
|
- |
mKeyValues.remove( zKey ); |
85 |
|
- |
} |
86 |
|
- |
} |
87 |
|
- |
UtilsCommon.addPropertiesTo( mKeyValues, pKeyValuePairs ); |
88 |
|
- |
} |
|
41 |
+ |
return null; |
89 |
42 |
|
} |
90 |
43 |
|
} |