/** * Merge all property sets into a single Properties object. * @return the merged object. */ private Properties mergePropertySets() { Properties p = new Properties(); for (PropertySet ps : propertySets) { p.putAll(ps.getProperties()); } return p; }
/** * If the regex is set, then only properties whose names match it * will be recorded. If prefix is not set and if this is never set, * or it is set to an empty string or <tt>null</tt>, then all * properties will be recorded. * * <p>For example, if the attribute is set as:</p> * <pre><echoproperties prefix=".*ant.*" /></pre> * then the properties "ant.home" and "user.variant" will be recorded, * but "ant-example" will not. * * @param regex The new regex value * * @since Ant 1.7 */ public void setRegex(String regex) { if (regex != null && !regex.isEmpty()) { this.regex = regex; PropertySet ps = new PropertySet(); ps.setProject(getProject()); ps.appendRegex(regex); addPropertyset(ps); } }
if (isReference()) { getRef().addPropertyNames(names, props); dieOnCircularReference(); break; case BuiltinPropertySetName.SYSTEM: names.addAll(getAllSystemProperties().keySet()); break; case BuiltinPropertySetName.COMMANDLINE: names.addAll(getProject().getUserProperties().keySet()); break; default:
/** * Fulfill the ResourceCollection contract. * @return the size of this ResourceCollection. */ @Override public int size() { return isReference() ? getRef().size() : getProperties().size(); }
private Set<String> getPropertyNames(Map<String, Object> props) { Set<String> names; if (getDynamic() || cachedNames == null) { names = new HashSet<>(); addPropertyNames(names, props); // Add this PropertySet's nested PropertySets' property names. for (PropertySet set : setRefs) { names.addAll(set.getPropertyMap().keySet()); } if (negate) { //make a copy... HashSet<String> complement = new HashSet<>(props.keySet()); complement.removeAll(names); names = complement; } if (!getDynamic()) { cachedNames = names; } } else { names = cachedNames; } return names; }
/** * If the prefix is set, then only properties which start with this * prefix string will be recorded. If regex is not set and if this * is never set, or it is set to an empty string or <tt>null</tt>, * then all properties will be recorded. * * <p>For example, if the attribute is set as:</p> * <pre><echoproperties prefix="ant." /></pre> * then the property "ant.home" will be recorded, but "ant-example" * will not. * * @param prefix The new prefix value */ public void setPrefix(String prefix) { if (prefix != null && !prefix.isEmpty()) { this.prefix = prefix; PropertySet ps = new PropertySet(); ps.setProject(getProject()); ps.appendPrefix(prefix); addPropertyset(ps); } }
PropertySet ps = new PropertySet(); PropertySet.BuiltinPropertySetName sys = new PropertySet.BuiltinPropertySetName(); sys.setValue("system"); ps.appendBuiltin(sys); clonedSysProperties.addSyspropertyset(ps); clonedSysProperties.addDefinitionsToList(listIterator);
public PropertySet createPropertyset() { if (propertyset == null) { propertyset = new PropertySet(); } return propertyset; }
/** * Allow properties whose names match a regex in the set. * @param regex the regular expression to use. */ public void appendRegex(String regex) { PropertyRef r = new PropertyRef(); r.setRegex(regex); addPropertyref(r); }
public PropertySet createPropertyset() { if (propertyset == null) { propertyset = new PropertySet(); } return propertyset; }
/** * Allow builtin (all, system or commandline) properties in the set. * @param b the type of builtin properties. */ public void appendBuiltin(BuiltinPropertySetName b) { PropertyRef r = new PropertyRef(); r.setBuiltin(b); addPropertyref(r); }
/** * Adds the properties provided by the specified PropertySet to this filterset. * * @param propertySet the propertyset to be added to this propertyset */ public synchronized void addConfiguredPropertySet(PropertySet propertySet) { if (isReference()) { throw noChildrenAllowed(); } Properties p = propertySet.getProperties(); Set<Map.Entry<Object, Object>> entries = p.entrySet(); for (Map.Entry<Object, Object> entry : entries) { addFilter(new Filter(String.valueOf(entry.getKey()), String.valueOf(entry.getValue()))); } }
/** * Allow properties of a particular name in the set. * @param name the property name to allow. */ public void appendName(String name) { PropertyRef r = new PropertyRef(); r.setName(name); addPropertyref(r); }
/** * Add the referenced property set as system properties for the TestNG JVM. * * @param sysPropertySet A PropertySet of system properties. */ public void addConfiguredPropertySet(PropertySet sysPropertySet) { Properties properties = sysPropertySet.getProperties(); log(properties.keySet().size() + " properties found in nested propertyset", Project.MSG_VERBOSE); for (Object propKeyObj : properties.keySet()) { String propKey = (String) propKeyObj; Environment.Variable sysProp = new Environment.Variable(); sysProp.setKey(propKey); if (properties.get(propKey) instanceof String) { String propVal = (String) properties.get(propKey); sysProp.setValue(propVal); getJavaCommand().addSysproperty(sysProp); log("Added system property " + propKey + " with value " + propVal, Project.MSG_VERBOSE); } else { log("Ignoring non-String property " + propKey, Project.MSG_WARN); } } }
/** * Allow properties whose names start with a prefix in the set. * @param prefix the prefix to use. */ public void appendPrefix(String prefix) { PropertyRef r = new PropertyRef(); r.setPrefix(prefix); addPropertyref(r); }
/** * Add the referenced property set as system properties for the TestNG JVM. * * @param sysPropertySet A PropertySet of system properties. */ public void addConfiguredPropertySet(PropertySet sysPropertySet) { Properties properties = sysPropertySet.getProperties(); log( properties.keySet().size() + " properties found in nested propertyset", Project.MSG_VERBOSE); for (Object propKeyObj : properties.keySet()) { String propKey = (String) propKeyObj; Environment.Variable sysProp = new Environment.Variable(); sysProp.setKey(propKey); if (properties.get(propKey) instanceof String) { String propVal = (String) properties.get(propKey); sysProp.setValue(propVal); getJavaCommand().addSysproperty(sysProp); log("Added system property " + propKey + " with value " + propVal, Project.MSG_VERBOSE); } else { log("Ignoring non-String property " + propKey, Project.MSG_WARN); } } }
getProperty = PropertyHelper.getPropertyHelper(project); } else { getProperty = propertySet.getProperties()::getProperty;
addAlmostAll(ps.getProperties(), PropertyType.PLAIN);
public void addConfiguredPropertySet(PropertySet ps) { properties.putAll(ps.getProperties()); }
public void addConfiguredPropertySet(PropertySet ps) { properties.putAll(ps.getProperties()); }