Subversion Repository Public Repository

litesoft

Diff Revisions 49 vs 474 for /trunk/Java/core/Server/src/org/litesoft/configuration/ConfigAccessorFactoryProperties.java

Diff revisions: vs.
  @@ -27,93 +27,38 @@
27 27 return new ConfigDataAccessorImpl( pLoadedFromDirectory, pLoadedFromName, props );
28 28 }
29 29
30 - private static class ConfigDataAccessorImpl implements ConfigDataAccessor
30 + private static class ConfigDataAccessorImpl extends AbstractConfigDataAccessor
31 31 {
32 - private String mLoadedFromDirectory;
33 - private String mLoadedFromName;
34 - private Properties mProperties;
32 + private final Properties mProperties;
35 33
36 34 public ConfigDataAccessorImpl( String pLoadedFromDirectory, String pLoadedFromName, Properties pProperties )
37 35 {
38 - mLoadedFromDirectory = pLoadedFromDirectory;
39 - mLoadedFromName = pLoadedFromName;
36 + super( pLoadedFromDirectory, pLoadedFromName + " from '" + pLoadedFromDirectory + "'", null );
40 37 mProperties = pProperties;
41 38 }
42 39
43 40 @Override
44 - public String loadedFrom()
41 + protected String getExceptionPlus()
45 42 {
46 - return mLoadedFromName + " from '" + loadedFromDirectory() + "'";
43 + return " Properties";
47 44 }
48 45
49 46 @Override
50 - public String loadedFromDirectory()
47 + protected void setOtherLevelKeyValue(String pKey, String pValue)
51 48 {
52 - return mLoadedFromDirectory;
49 + throw new IllegalStateException("Huh");
53 50 }
54 51
55 - /**
56 - * All implementations MUST support RUN level, but may not support other levels
57 - *
58 - * @return an array with at least 1 (RUN) entry
59 - */
60 52 @Override
61 - public Level[] getSetableSupportedLevels()
53 + protected String[] getBaseKeys()
62 54 {
63 - return new Level[]{Level.RUN};
55 + return Utils.toStringArray(mProperties.keySet());
64 56 }
65 57
66 - /**
67 - * All implementations MUST support RUN level, but may not support other levels
68 - *
69 - * @param pLevel null interpreted as RUN
70 - * @param pKey not null or empty
71 - * @param pValue null means remove
72 - *
73 - * @throws UnsupportedOperationException if requested level not supported
74 - */
75 58 @Override
76 - public void setKeyValue( Level pLevel, String pKey, String pValue )
77 - throws UnsupportedOperationException
59 + protected String getBaseValue(String pKey)
78 60 {
79 - pKey = Utils.assertNotNullNotEmpty( "Key", pKey );
80 - if ( !Level.RUN.equals( Utils.deNull( pLevel, Level.RUN ) ) )
81 - {
82 - throw new UnsupportedOperationException( "setKeyValue for Level '" + pLevel + "' not supported" );
83 - }
84 - if ( pValue == null )
85 - {
86 - mProperties.remove( pKey );
87 - }
88 - else
89 - {
90 - mProperties.put( pKey, pValue );
91 - }
92 - }
93 -
94 - @Override
95 - public String[] getAllKeys()
96 - {
97 - List<String> keys = new ArrayList<String>();
98 - for ( Object key : mProperties.keySet() )
99 - {
100 - if ( key instanceof String )
101 - {
102 - keys.add( (String) key );
103 - }
104 - }
105 - return keys.toArray( new String[keys.size()] );
106 - }
107 -
108 - /**
109 - * @param pKey not null or empty
110 - *
111 - * @return null if not found or value associated with key
112 - */
113 - @Override
114 - public String getString( String pKey )
115 - {
116 - Object o = mProperties.get( Utils.assertNotNullNotEmpty( "Key", pKey ) );
61 + Object o = mProperties.get( pKey );
117 62 return (o == null) ? null : o.toString();
118 63 }
119 64 }