/** * Get the size of the sysproperties instance. This merges all * property sets, so is not an O(1) operation. * @return the size of the sysproperties instance. */ public int size() { Properties p = mergePropertySets(); return variables.size() + p.size(); }
/** * Add all definitions (including property sets) to a list. * @param listIt list iterator supporting add method. */ public void addDefinitionsToList(ListIterator<String> listIt) { String[] props = super.getVariables(); if (props != null) { for (String prop : props) { listIt.add("-D" + prop); } } Properties propertySetProperties = mergePropertySets(); for (String key : propertySetProperties.stringPropertyNames()) { listIt.add("-D" + key + "=" + propertySetProperties.getProperty(key)); } }
/** * Cache the system properties and set the system properties to the * new values. * @throws BuildException if Security prevented this operation. */ public void setSystem() throws BuildException { try { sys = System.getProperties(); Properties p = new Properties(); for (String name : sys.stringPropertyNames()) { String value = sys.getProperty(name); if (value != null) { p.put(name, value); } } p.putAll(mergePropertySets()); for (Environment.Variable v : variables) { v.validate(); p.put(v.getKey(), v.getValue()); } System.setProperties(p); } catch (SecurityException e) { throw new BuildException("Cannot modify system properties", e); } }