1 18 package org.apache.tools.ant.filters; 19 20 import java.io.IOException ; 21 import java.io.Reader ; 22 import org.apache.tools.ant.Project; 23 24 34 public final class ExpandProperties 35 extends BaseFilterReader 36 implements ChainableReader { 37 38 private String queuedData = null; 39 40 45 public ExpandProperties() { 46 super(); 47 } 48 49 55 public ExpandProperties(final Reader in) { 56 super(in); 57 } 58 59 71 public int read() throws IOException { 72 73 int ch = -1; 74 75 if (queuedData != null && queuedData.length() == 0) { 76 queuedData = null; 77 } 78 79 if (queuedData != null) { 80 ch = queuedData.charAt(0); 81 queuedData = queuedData.substring(1); 82 if (queuedData.length() == 0) { 83 queuedData = null; 84 } 85 } else { 86 queuedData = readFully(); 87 if (queuedData == null) { 88 ch = -1; 89 } else { 90 Project project = getProject(); 91 queuedData = project.replaceProperties(queuedData); 92 return read(); 93 } 94 } 95 return ch; 96 } 97 98 108 public Reader chain(final Reader rdr) { 109 ExpandProperties newFilter = new ExpandProperties(rdr); 110 newFilter.setProject(getProject()); 111 return newFilter; 112 } 113 } 114 | Popular Tags |