@@ -1,9 +1,8 @@
<html>
<html>
<head>
<head>
<meta http-equiv="Content-Language" content="en-us"></meta>
<meta http-equiv="Content-Language" content="en-us"></meta>
<title>Custom Components</title>
<title>Custom Components</title>
</head>
</head>
<body>
<body>
<h2>Custom Components</h2>
<h2>Custom Components</h2>
<h3>Overview</h3>
<h3>Overview</h3>
@@ -66,10 +65,10 @@ public class AllUpperCaseCondition extends Condition {
// This method evaluates the condition
// This method evaluates the condition
public boolean eval() {
public boolean eval() {
if (value == null) {
if (value == null) {
throw new BuildException("value attribute is not set" );
throw new BuildException("value attribute is not set" );
}
}
return value.toUpperCase().equals(value);
return value.toUpperCase().equals(value);
}
}
}
}
</pre>
</pre>
</blockquote>
</blockquote>
@@ -80,9 +79,9 @@ public class AllUpperCaseCondition extends Condition {
<blockquote>
<blockquote>
<pre>
<pre>
<typedef
<typedef
name="alluppercase"
classname="com.mydomain.AllUpperCaseCondition"
classpath="${mydomain.classes" />
name="alluppercase"
classname="com.mydomain.AllUpperCaseCondition"
classpath="${mydomain.classes}" />
</pre>
</pre>
</blockquote>
</blockquote>
<p>
<p>
@@ -91,8 +90,8 @@ public class AllUpperCaseCondition extends Condition {
</p>
</p>
<blockquote>
<blockquote>
<pre>
<pre>
<condition property="allupper" >
<alluppercase value="THIS IS ALL UPPER CASE" />
<condition property="allupper" >
<alluppercase value="THIS IS ALL UPPER CASE" />
</condition>
</condition>
</pre>
</pre>
</blockquote>
</blockquote>
@@ -110,7 +109,7 @@ public class AllUpperCaseCondition extends Condition {
</p>
</p>
<p>
<p>
An example of a custom selection that selects filenames ending
An example of a custom selection that selects filenames ending
in ".java" would be:
in ".java" would be:
</p>
</p>
<blockquote>
<blockquote>
<pre>
<pre>
@@ -119,7 +118,7 @@ import java.io.File;
import org.apache.tools.ant.types.selectors.FileSelector;
import org.apache.tools.ant.types.selectors.FileSelector;
public class JavaSelector implements FileSelector {
public class JavaSelector implements FileSelector {
public boolean isSelected(File b, String filename, File f) {
public boolean isSelected(File b, String filename, File f) {
return filename.toLowerCase().endsWith(".java" );
return filename.toLowerCase().endsWith(".java" );
}
}
}
}
</pre>
</pre>
@@ -130,9 +129,9 @@ public class JavaSelector implements FileSelector {
<blockquote>
<blockquote>
<pre>
<pre>
<typedef
<typedef
name="javaselector"
classname="com.mydomain.JavaSelector"
classpath="${mydomain.classes" />
name="javaselector"
classname="com.mydomain.JavaSelector"
classpath="${mydomain.classes}" />
</pre>
</pre>
</blockquote>
</blockquote>
<p>
<p>
@@ -141,14 +140,14 @@ public class JavaSelector implements FileSelector {
</p>
</p>
<blockquote>
<blockquote>
<pre>
<pre>
<copy todir="to" >
<fileset dir="src" >
<copy todir="to" >
<fileset dir="src" >
<javaselector/>
<javaselector/>
</fileset>
</fileset>
</copy>
</copy>
</pre>
</pre>
</blockquote>
</blockquote>
<p>
<p>
One may use
One may use
<code>org.apache.tools.ant.types.selectors.BaseSelector</code>,
<code>org.apache.tools.ant.types.selectors.BaseSelector</code>,
@@ -164,7 +163,7 @@ public class JavaSelector implements FileSelector {
last chance to check your settings for consistency because it
last chance to check your settings for consistency because it
calls <code>verifySettings()</code>. Override this method and
calls <code>verifySettings()</code>. Override this method and
call <code>setError()</code> within it if you detect any
call <code>setError()</code> within it if you detect any
problems in how your selector is set up.</p>
problems in how your selector is set up.
</p>
</p>
<p>
<p>
To write custom selector containers one should extend
To write custom selector containers one should extend
@@ -190,7 +189,7 @@ public class MatchNumberSelectors extends BaseSelectorContainer {
}
}
public void verifySettings() {
public void verifySettings() {
if (number < 0) {
if (number < 0) {
throw new BuildException("Number attribute should be set" );
throw new BuildException("Number attribute should be set" );
}
}
}
}
public boolean isSelected(File baseDir, String filename, File file) {
public boolean isSelected(File baseDir, String filename, File file) {
@@ -212,13 +211,13 @@ public class MatchNumberSelectors extends BaseSelectorContainer {
</p>
</p>
<blockquote>
<blockquote>
<pre>
<pre>
<typedef name="numberselected"
classname="com.mydomain.MatchNumberSelectors" />
<typedef name="numberselected"
classname="com.mydomain.MatchNumberSelectors" />
...
...
<fileset dir="${src.path}" >
<numberselected number="2" >
<contains text="script" casesensitive="no" />
<size value="4" units="Ki" when="more" />
<fileset dir="${src.path}" >
<numberselected number="2" >
<contains text="script" casesensitive="no" />
<size value="4" units="Ki" when="more" />
<javaselector/>
<javaselector/>
</numberselected>
</numberselected>
</fileset>
</fileset>
@@ -229,7 +228,7 @@ public class MatchNumberSelectors extends BaseSelectorContainer {
</p>
</p>
<p>
<p>
The custom selector was the pre ant 1.6 way of defining custom selectors.
The custom selector was the pre ant 1.6 way of defining custom selectors.
This method is still supported for backward compatiblity.
This method is still supported for backward compatibi lity.
</p>
</p>
<p>You can write your own selectors and use them within the selector
<p>You can write your own selectors and use them within the selector
containers by specifying them within the <custom> tag.</p>
containers by specifying them within the <custom> tag.</p>
@@ -299,7 +298,7 @@ public class MatchNumberSelectors extends BaseSelectorContainer {
</fileset>
</fileset>
</pre></blockquote>
</pre></blockquote>
<p>The core selectors that can also be used as custom selectors
<p>The core selectors that can also be used as custom selectors
are</p>
are</p>
@@ -364,7 +363,7 @@ public class RemoveOddCharacters implements ChainableReader {
count++;
count++;
if ((count % 2) == 1) {
if ((count % 2) == 1) {
return c;
return c;
}
}
}
}
}
}
}
}
@@ -386,13 +385,13 @@ public class AddLineNumber extends ChainableReaderFilter {
private void lineNumber = 0;
private void lineNumber = 0;
public String filter(String string) {
public String filter(String string) {
lineNumber++;
lineNumber++;
return "" + lineNumber + "\t" + string;
return "" + lineNumber + "\t" + string;
}
}
}
}
</pre>
</pre>
</blockquote>
</blockquote>
<hr></hr>
<hr></hr>
<p align="center">Copyright © 2003 Apache Software Foundation. All rights
<p align="center">Copyright © 2003 Apache Software Foundation. All rights
Reserved.</p>
Reserved.</p>