Search in sources :

Example 1 with PropertyResource

use of org.apache.tools.ant.types.resources.PropertyResource in project ant by apache.

the class PropertySet method iterator.

/**
 * Fulfill the ResourceCollection interface.
 * @return an Iterator of Resources.
 * @since Ant 1.7
 */
@Override
public Iterator<Resource> iterator() {
    if (isReference()) {
        return getRef().iterator();
    }
    dieOnCircularReference();
    Stream<Resource> result = getPropertyNames(getEffectiveProperties()).stream().map(name -> new PropertyResource(getProject(), name));
    Optional<FileNameMapper> m = Optional.ofNullable(getMapper()).map(Mapper::getImplementation);
    if (m.isPresent()) {
        result = result.map(p -> new MappedResource(p, m.get()));
    }
    return result.iterator();
}
Also used : Properties(java.util.Properties) Iterator(java.util.Iterator) Enumeration(java.util.Enumeration) RegexpMatcher(org.apache.tools.ant.util.regexp.RegexpMatcher) Set(java.util.Set) HashMap(java.util.HashMap) BuildException(org.apache.tools.ant.BuildException) FileNameMapper(org.apache.tools.ant.util.FileNameMapper) Stack(java.util.Stack) ArrayList(java.util.ArrayList) RegexpMatcherFactory(org.apache.tools.ant.util.regexp.RegexpMatcherFactory) HashSet(java.util.HashSet) PropertyResource(org.apache.tools.ant.types.resources.PropertyResource) List(java.util.List) Stream(java.util.stream.Stream) TreeMap(java.util.TreeMap) MappedResource(org.apache.tools.ant.types.resources.MappedResource) Map(java.util.Map) Entry(java.util.Map.Entry) Optional(java.util.Optional) Project(org.apache.tools.ant.Project) FileNameMapper(org.apache.tools.ant.util.FileNameMapper) PropertyResource(org.apache.tools.ant.types.resources.PropertyResource) MappedResource(org.apache.tools.ant.types.resources.MappedResource) PropertyResource(org.apache.tools.ant.types.resources.PropertyResource) FileNameMapper(org.apache.tools.ant.util.FileNameMapper) MappedResource(org.apache.tools.ant.types.resources.MappedResource)

Example 2 with PropertyResource

use of org.apache.tools.ant.types.resources.PropertyResource in project ant by apache.

the class ResourceOutputTest method testpropertyoutput2.

@Test
public void testpropertyoutput2() throws IOException {
    project.setNewProperty("bar", "bar");
    PropertyResource r = new PropertyResource(project, "bar");
    try {
        testoutput(r);
        fail("should have caught ImmutableResourceException");
    } catch (ImmutableResourceException e) {
    // TODO assert exception message
    }
    assertEquals("bar", project.getProperty("bar"));
}
Also used : ImmutableResourceException(org.apache.tools.ant.types.resources.ImmutableResourceException) PropertyResource(org.apache.tools.ant.types.resources.PropertyResource) Test(org.junit.Test)

Example 3 with PropertyResource

use of org.apache.tools.ant.types.resources.PropertyResource in project ant by apache.

the class ResourceOutputTest method testpropertyoutput1.

@Test
public void testpropertyoutput1() {
    PropertyResource r = new PropertyResource(project, "bar");
    testoutputbe(r);
    assertEquals("foo", project.getProperty("bar"));
}
Also used : PropertyResource(org.apache.tools.ant.types.resources.PropertyResource) Test(org.junit.Test)

Aggregations

PropertyResource (org.apache.tools.ant.types.resources.PropertyResource)3 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 Enumeration (java.util.Enumeration)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Optional (java.util.Optional)1 Properties (java.util.Properties)1 Set (java.util.Set)1 Stack (java.util.Stack)1 TreeMap (java.util.TreeMap)1 Stream (java.util.stream.Stream)1 BuildException (org.apache.tools.ant.BuildException)1 Project (org.apache.tools.ant.Project)1 ImmutableResourceException (org.apache.tools.ant.types.resources.ImmutableResourceException)1 MappedResource (org.apache.tools.ant.types.resources.MappedResource)1