FileDocCategorySizeDatePackage
ExpandProperties.javaAPI DocApache Ant 1.703553Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.filters

ExpandProperties

public final class ExpandProperties extends BaseFilterReader implements ChainableReader
Expands Ant properties, if any, in the data.

Example:

<expandproperties/>
Or:
<filterreader
classname="org.apache.tools.ant.filters.ExpandProperties"/>

Fields Summary
private String
queuedData
Data that must be read from, if not null.
Constructors Summary
public ExpandProperties()
Constructor for "dummy" instances.

see
BaseFilterReader#BaseFilterReader()


               
      
        super();
    
public ExpandProperties(Reader in)
Creates a new filtered reader.

param
in A Reader object providing the underlying stream. Must not be null.

        super(in);
    
Methods Summary
public java.io.Readerchain(java.io.Reader rdr)
Creates a new ExpandProperties filter using the passed in Reader for instantiation.

param
rdr A Reader object providing the underlying stream. Must not be null.
return
a new filter based on this configuration, but filtering the specified reader

        ExpandProperties newFilter = new ExpandProperties(rdr);
        newFilter.setProject(getProject());
        return newFilter;
    
public intread()
Returns the next character in the filtered stream. The original stream is first read in fully, and the Ant properties are expanded. The results of this expansion are then queued so they can be read character-by-character.

return
the next character in the resulting stream, or -1 if the end of the resulting stream has been reached
exception
IOException if the underlying stream throws an IOException during reading


        int ch = -1;

        if (queuedData != null && queuedData.length() == 0) {
            queuedData = null;
        }

        if (queuedData != null) {
            ch = queuedData.charAt(0);
            queuedData = queuedData.substring(1);
            if (queuedData.length() == 0) {
                queuedData = null;
            }
        } else {
            queuedData = readFully();
            if (queuedData == null) {
                ch = -1;
            } else {
                Project project = getProject();
                queuedData = project.replaceProperties(queuedData);
                return read();
            }
        }
        return ch;