git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@575634 13f79535-47bb-0310-9956-ffa450edef68master
@@ -70,9 +70,12 @@ import org.apache.tools.ant.types.EnumeratedAttribute; | |||||
* | * | ||||
*/ | */ | ||||
public final class FixCrLfFilter extends BaseParamFilterReader implements ChainableReader { | public final class FixCrLfFilter extends BaseParamFilterReader implements ChainableReader { | ||||
private static final int DEFAULT_TAB_LENGTH = 8; | |||||
private static final int MIN_TAB_LENGTH = 2; | |||||
private static final int MAX_TAB_LENGTH = 80; | |||||
private static final char CTRLZ = '\u001A'; | private static final char CTRLZ = '\u001A'; | ||||
private int tabLength = 8; | |||||
private int tabLength = DEFAULT_TAB_LENGTH; | |||||
private CrLf eol; | private CrLf eol; | ||||
@@ -376,8 +379,11 @@ public final class FixCrLfFilter extends BaseParamFilterReader implements Chaina | |||||
* @throws IOException on error. | * @throws IOException on error. | ||||
*/ | */ | ||||
public void setTablength(int tabLength) throws IOException { | public void setTablength(int tabLength) throws IOException { | ||||
if (tabLength < 2 || tabLength > 80) { | |||||
throw new IOException("tablength must be between 2 and 80"); | |||||
if (tabLength < MIN_TAB_LENGTH | |||||
|| tabLength > MAX_TAB_LENGTH) { | |||||
throw new IOException( | |||||
"tablength must be between " + MIN_TAB_LENGTH | |||||
+ " and " + MAX_TAB_LENGTH); | |||||
} | } | ||||
this.tabLength = tabLength; | this.tabLength = tabLength; | ||||
} | } | ||||
@@ -393,9 +399,10 @@ public final class FixCrLfFilter extends BaseParamFilterReader implements Chaina | |||||
* </P> | * </P> | ||||
*/ | */ | ||||
private static class SimpleFilterReader extends Reader { | private static class SimpleFilterReader extends Reader { | ||||
private static int PREEMPT_BUFFER_LENGTH = 16; | |||||
private Reader in; | private Reader in; | ||||
private int[] preempt = new int[16]; | |||||
private int[] preempt = new int[PREEMPT_BUFFER_LENGTH]; | |||||
private int preemptIndex = 0; | private int preemptIndex = 0; | ||||
@@ -37,6 +37,8 @@ import org.apache.tools.ant.util.FileUtils; | |||||
*/ | */ | ||||
public class Truncate extends Task { | public class Truncate extends Task { | ||||
private static final int BUFFER_SIZE = 1024; | |||||
private static final Long ZERO = new Long(0L); | private static final Long ZERO = new Long(0L); | ||||
private static final String NO_CHILD = "No files specified."; | private static final String NO_CHILD = "No files specified."; | ||||
@@ -47,7 +49,7 @@ public class Truncate extends Task { | |||||
private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | ||||
private static final byte[] FILL_BUFFER = new byte[1024]; | |||||
private static final byte[] FILL_BUFFER = new byte[BUFFER_SIZE]; | |||||
private Path path; | private Path path; | ||||
private boolean create = true; | private boolean create = true; | ||||
@@ -52,10 +52,19 @@ import org.apache.tools.ant.types.EnumeratedAttribute; | |||||
* @ant.task category="control" | * @ant.task category="control" | ||||
*/ | */ | ||||
public class WaitFor extends ConditionBase { | public class WaitFor extends ConditionBase { | ||||
private static final long ONE_SECOND = 1000L; | |||||
private static final long ONE_MINUTE = ONE_SECOND * 60L; | |||||
private static final long ONE_HOUR = ONE_MINUTE * 60L; | |||||
private static final long ONE_DAY = ONE_HOUR * 24L; | |||||
private static final long ONE_WEEK = ONE_DAY * 7L; | |||||
private static final long DEFAULT_MAX_WAIT_MILLIS = ONE_MINUTE * 3L; | |||||
private static final long DEFAULT_CHECK_MILLIS = 500L; | |||||
/** default max wait time */ | /** default max wait time */ | ||||
private long maxWaitMillis = 1000L * 60L * 3L; | |||||
private long maxWaitMillis = DEFAULT_MAX_WAIT_MILLIS; | |||||
private long maxWaitMultiplier = 1L; | private long maxWaitMultiplier = 1L; | ||||
private long checkEveryMillis = 500L; | |||||
private long checkEveryMillis = DEFAULT_CHECK_MILLIS; | |||||
private long checkEveryMultiplier = 1L; | private long checkEveryMultiplier = 1L; | ||||
private String timeoutProperty; | private String timeoutProperty; | ||||
@@ -201,11 +210,11 @@ public class WaitFor extends ConditionBase { | |||||
/** Constructor the Unit enumerated type. */ | /** Constructor the Unit enumerated type. */ | ||||
public Unit() { | public Unit() { | ||||
timeTable.put(MILLISECOND, new Long(1L)); | timeTable.put(MILLISECOND, new Long(1L)); | ||||
timeTable.put(SECOND, new Long(1000L)); | |||||
timeTable.put(MINUTE, new Long(1000L * 60L)); | |||||
timeTable.put(HOUR, new Long(1000L * 60L * 60L)); | |||||
timeTable.put(DAY, new Long(1000L * 60L * 60L * 24L)); | |||||
timeTable.put(WEEK, new Long(1000L * 60L * 60L * 24L * 7L)); | |||||
timeTable.put(SECOND, new Long(ONE_SECOND)); | |||||
timeTable.put(MINUTE, new Long(ONE_MINUTE)); | |||||
timeTable.put(HOUR, new Long(ONE_HOUR)); | |||||
timeTable.put(DAY, new Long(ONE_DAY)); | |||||
timeTable.put(WEEK, new Long(ONE_WEEK)); | |||||
} | } | ||||
/** | /** | ||||