updated to use new cooja project class

This commit is contained in:
fros4943 2010-12-02 15:28:06 +00:00
parent 7d26ad8426
commit 1d9ed108d4
2 changed files with 844 additions and 763 deletions

View file

@ -26,13 +26,14 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ProjectConfig.java,v 1.4 2009/10/28 12:05:43 fros4943 Exp $
* $Id: ProjectConfig.java,v 1.5 2010/12/02 15:28:06 fros4943 Exp $
*/
package se.sics.cooja;
import java.io.*;
import java.util.*;
import org.apache.log4j.Logger;
/**
@ -293,6 +294,25 @@ public class ProjectConfig {
return true;
}
public boolean appendConfig(ProjectConfig config) {
Enumeration<String> propertyNames = config.getPropertyNames();
while (propertyNames.hasMoreElements()) {
String key = propertyNames.nextElement();
String property = config.getStringValue(key);
if (property.startsWith("+ ")) {
if (myConfig.getProperty(key) != null) {
myConfig.setProperty(key, myConfig.getProperty(key) + " "
+ property.substring(1).trim());
} else {
myConfig.setProperty(key, property.substring(1).trim());
}
} else {
myConfig.setProperty(key, property);
}
}
return true;
}
/**
* @return All property names in configuration
*/
@ -338,7 +358,8 @@ public class ProjectConfig {
*/
public String getStringValue(String name) {
if (!myConfig.containsKey(name)) {
logger.debug("Could not find key named '" + name + "'");
/*logger.debug("Could not find key named '" + name + "'");*/
return null;
}
return myConfig.getProperty(name);