Bug fixes, Configurable is only looking for public fields
This commit is contained in:
parent
fdc8c8caf5
commit
f8b9a86d65
3 changed files with 8 additions and 8 deletions
BIN
Zutil.jar
BIN
Zutil.jar
Binary file not shown.
4
src/zutil/io/StringOutputStream.java
Normal file → Executable file
4
src/zutil/io/StringOutputStream.java
Normal file → Executable file
|
|
@ -62,9 +62,7 @@ public class StringOutputStream extends OutputStream{
|
||||||
* Same as {@link OutputStream:clear()}
|
* Same as {@link OutputStream:clear()}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {}
|
||||||
clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the String buffer
|
* Clears the String buffer
|
||||||
|
|
|
||||||
|
|
@ -110,24 +110,26 @@ public class Configurator<T> {
|
||||||
/**
|
/**
|
||||||
* Uses a Map to assign all parameters of the Object
|
* Uses a Map to assign all parameters of the Object
|
||||||
*/
|
*/
|
||||||
public void setValues(Map<String,String> parameters){
|
public Configurator<T> setValues(Map<String,String> parameters){
|
||||||
for(ConfigurationParam param : this.params){
|
for(ConfigurationParam param : this.params){
|
||||||
if(parameters.containsKey(param.getName()))
|
if(parameters.containsKey(param.getName()))
|
||||||
param.setValue(parameters.get(param.getName()));
|
param.setValue(parameters.get(param.getName()));
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses a Map to assign all parameters of the Object.
|
* Uses a Map to assign all parameters of the Object.
|
||||||
* NOTE: the DataNode must be of type Map
|
* NOTE: the DataNode must be of type Map
|
||||||
*/
|
*/
|
||||||
public void setValues(DataNode node){
|
public Configurator<T> setValues(DataNode node){
|
||||||
if(!node.isMap())
|
if(!node.isMap())
|
||||||
return;
|
return this;
|
||||||
for(ConfigurationParam param : this.params){
|
for(ConfigurationParam param : this.params){
|
||||||
if(node.get(param.getName()) != null)
|
if(node.get(param.getName()) != null)
|
||||||
param.setValue(node.getString(param.getName()));
|
param.setValue(node.getString(param.getName()));
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataNode getValuesAsNode(){
|
public DataNode getValuesAsNode(){
|
||||||
|
|
@ -156,7 +158,7 @@ public class Configurator<T> {
|
||||||
if(param.isTypeString())
|
if(param.isTypeString())
|
||||||
strParams.append(": '").append(param.getString()).append("', ");
|
strParams.append(": '").append(param.getString()).append("', ");
|
||||||
else
|
else
|
||||||
strParams.append(param.getString());
|
strParams.append(": ").append(param.getString());
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
logger.log(Level.WARNING, null, e);
|
logger.log(Level.WARNING, null, e);
|
||||||
|
|
@ -165,7 +167,7 @@ public class Configurator<T> {
|
||||||
((ConfigurationActionListener) obj).postConfigurationAction();
|
((ConfigurationActionListener) obj).postConfigurationAction();
|
||||||
}
|
}
|
||||||
if(logger.isLoggable(Level.FINE))
|
if(logger.isLoggable(Level.FINE))
|
||||||
logger.fine("Configured object: " + obj.getClass().getSimpleName() + "("+ strParams +")");
|
logger.fine("Configured object: " + obj.getClass().getName() + " ("+ strParams +")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue