From 5b78d0ba6fe0251619df15ede79617849c914349 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Sat, 5 Jan 2002 03:07:00 +0000 Subject: [PATCH] Make sure a property file with no properties in it does not cause any exceptions. Removed an unused method. Made the Properties object returned from getNativeEnvironment() contain all environment properties rather than having the environment properties as default properties for property object. This allows much easier direct access to prpoerty values. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270517 13f79535-47bb-0310-9956-ffa450edef68 --- .../myrmidon/framework/exec/Environment.java | 32 ++++--------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/Environment.java b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/Environment.java index a643c87fa..0aa3434c2 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/Environment.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/Environment.java @@ -64,29 +64,6 @@ public final class Environment } } - /** - * Retrieve an array of EnvironmentData vars that contains a list of all - * native EnvironmentData Variables for the current process. - */ - private static String[] getNativeEnvironmentAsArray() - throws IOException, ExecException - { - final Properties environment = getEnvironmentVariables(); - - final String[] env = new String[ environment.size() ]; - final Iterator keys = environment.keySet().iterator(); - int index = 0; - while( keys.hasNext() ) - { - final String key = (String)keys.next(); - final String value = environment.getProperty( key ); - env[ index ] = key + '=' + value; - index++; - } - - return env; - } - /** * Retrieve a Properties object that contains the list of all * native EnvironmentData Variables for the current process. @@ -94,7 +71,9 @@ public final class Environment public static Properties getNativeEnvironment() throws IOException, ExecException { - return new Properties( getEnvironmentVariables() ); + final Properties properties = new Properties(); + properties.putAll( getEnvironmentVariables() ); + return properties; } /** @@ -151,7 +130,10 @@ public final class Environment } // Since we "look ahead" before adding, there's one last env var. - addProperty( properties, var ); + if( null != var ) + { + addProperty( properties, var ); + } return properties; }