You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2016/07/24 14:55:35 UTC
[1/2] ant git commit: add a filter for native2ascii
Repository: ant
Updated Branches:
refs/heads/master fd61c0af5 -> 41d51241c
add a filter for native2ascii
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/32672769
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/32672769
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/32672769
Branch: refs/heads/master
Commit: 326727692afb5db1c53f5b8d125d350dcfb2eaf4
Parents: 4ef2554
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun Jul 24 16:54:52 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun Jul 24 16:54:52 2016 +0200
----------------------------------------------------------------------
WHATSNEW | 3 ++
manual/Types/filterchain.html | 34 +++++++++++++
src/main/org/apache/tools/ant/antlib.xml | 2 +
.../tools/ant/filters/Native2AsciiFilter.java | 47 +++++++++++++++++
src/tests/antunit/filters/native2ascii-test.xml | 53 ++++++++++++++++++++
5 files changed, 139 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/32672769/WHATSNEW
----------------------------------------------------------------------
diff --git a/WHATSNEW b/WHATSNEW
index 0253e7e..e79166f 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -44,6 +44,9 @@ Other changes:
removed from the JDK.
Bugzilla Report 59855
+ * added a new <native2asciifilter> filter that can perform non-ASCII
+ to Unicode-escape conversions.
+
Changes from Ant 1.9.6 TO Ant 1.9.7
===================================
http://git-wip-us.apache.org/repos/asf/ant/blob/32672769/manual/Types/filterchain.html
----------------------------------------------------------------------
diff --git a/manual/Types/filterchain.html b/manual/Types/filterchain.html
index 4de10ea..90dd74b 100644
--- a/manual/Types/filterchain.html
+++ b/manual/Types/filterchain.html
@@ -1143,6 +1143,7 @@ and \\.
<a href="#ignoreblank">IgnoreBlank</a><br>
<a href="#filterdeletecharacters">DeleteCharacters</a><br>
<a href="#uniqfilter">UniqFilter</a><br>
+ <a href="#native2asciifilter">Native2AsciiFilter</a><br>
</p>
The following string filters are provided by the optional distribution.
@@ -1487,6 +1488,39 @@ This suppresses duplicate lines.
</tokenfilter>
</pre></blockquote>
+<p><b><em><a name="native2asciifilter">Native2AsciiFilter</a></em></b></p>
+
+<p>Uses the "builtin" implementation of
+ the <a href="../Tasks/native2ascii.html">native2ascii</a> task.</p>
+
+<p>Replaces non-ascii characters by their Unicode-escapes or
+ vice-versa. <em>Since Ant 1.9.8</em>.</p>
+
+<p>This filter may be used directly within a filterchain.</p>
+
+<table cellSpacing=0 cellPadding=2 border=1>
+ <tr>
+ <td vAlign=top><b>Attribute</b></td>
+ <td vAlign=top><b>Description</b></td>
+ <td vAlign=top align="center"><b>Required</b></td>
+ </tr>
+ <tr>
+ <td vAlign=top>reverse</td>
+ <td vAlign=top>Reverse the sense of the conversion,
+ i.e. convert from ASCII to native.</td>
+ <td vAlign=top align="center">No</td>
+ </tr>
+</table>
+
+<h4>Example:</h4>
+
+<p>This replaces all non-ASCII characters by their Unicode-escapes.</p>
+<blockquote><pre>
+<tokenfilter>
+ <native2asciifilter/>
+</tokenfilter>
+</pre></blockquote>
+
<p><b><em><a name="scriptfilter">ScriptFilter</a></em></b></p>
This is an optional filter that executes a script in a
<a href="http://jakarta.apache.org/bsf" target="_top">Apache BSF</a>
http://git-wip-us.apache.org/repos/asf/ant/blob/32672769/src/main/org/apache/tools/ant/antlib.xml
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/antlib.xml b/src/main/org/apache/tools/ant/antlib.xml
index b11bac5..6449807 100644
--- a/src/main/org/apache/tools/ant/antlib.xml
+++ b/src/main/org/apache/tools/ant/antlib.xml
@@ -140,5 +140,7 @@
classname="org.apache.tools.ant.filters.SortFilter"/>
<componentdef name="uniqfilter" onerror="ignore"
classname="org.apache.tools.ant.filters.UniqFilter"/>
+ <componentdef name="native2asciifilter" onerror="ignore"
+ classname="org.apache.tools.ant.filters.Native2AsciiFilter"/>
</antlib>
http://git-wip-us.apache.org/repos/asf/ant/blob/32672769/src/main/org/apache/tools/ant/filters/Native2AsciiFilter.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/filters/Native2AsciiFilter.java b/src/main/org/apache/tools/ant/filters/Native2AsciiFilter.java
new file mode 100644
index 0000000..2e764ae
--- /dev/null
+++ b/src/main/org/apache/tools/ant/filters/Native2AsciiFilter.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.tools.ant.filters;
+
+import org.apache.tools.ant.util.Native2AsciiUtils;
+
+/**
+ * A filter that performs translations from characters to their
+ * Unicode-escape sequences and vice-versa.
+ *
+ * @since Ant 1.9.8
+ */
+public class Native2AsciiFilter extends TokenFilter.ChainableReaderFilter {
+ private boolean reverse;
+
+ /**
+ * Flag the conversion to run in the reverse sense,
+ * that is Ascii to Native encoding.
+ *
+ * @param reverse True if the conversion is to be reversed,
+ * otherwise false;
+ */
+ public void setReverse(boolean reverse) {
+ this.reverse = reverse;
+ }
+
+ public String filter(String line) {
+ return reverse
+ ? Native2AsciiUtils.ascii2native(line)
+ : Native2AsciiUtils.native2ascii(line);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ant/blob/32672769/src/tests/antunit/filters/native2ascii-test.xml
----------------------------------------------------------------------
diff --git a/src/tests/antunit/filters/native2ascii-test.xml b/src/tests/antunit/filters/native2ascii-test.xml
new file mode 100644
index 0000000..37074a4
--- /dev/null
+++ b/src/tests/antunit/filters/native2ascii-test.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
+ <import file="../antunit-base.xml" />
+
+ <target name="testForward">
+ <au:assertTrue>
+ <resourcesmatch>
+ <string value="\u00e4\u00f6\u00fc=\u00c4\u00d6\u00dc
+\u00df=\u20ac"/>
+ <concat>
+ <string value="���=���
+�=\u20ac"/>
+ <filterchain>
+ <native2asciifilter/>
+ </filterchain>
+ </concat>
+ </resourcesmatch>
+ </au:assertTrue>
+ </target>
+
+ <target name="testReverse">
+ <au:assertTrue>
+ <resourcesmatch>
+ <string value="���=���
+�=\u20ac"/>
+ <concat>
+ <string value="\u00e4\u00f6\u00fc=\u00c4\u00d6\u00dc
+\u00df=\u20ac"/>
+ <filterchain>
+ <native2asciifilter reverse="true"/>
+ </filterchain>
+ </concat>
+ </resourcesmatch>
+ </au:assertTrue>
+ </target>
+
+</project>
[2/2] ant git commit: Merge branch '1.9.x'
Posted by bo...@apache.org.
Merge branch '1.9.x'
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/41d51241
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/41d51241
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/41d51241
Branch: refs/heads/master
Commit: 41d51241c6b52bab4a44e70792f15494d1ed05a7
Parents: fd61c0a 3267276
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun Jul 24 16:55:23 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun Jul 24 16:55:23 2016 +0200
----------------------------------------------------------------------
WHATSNEW | 3 ++
manual/Types/filterchain.html | 34 +++++++++++++
src/main/org/apache/tools/ant/antlib.xml | 2 +
.../tools/ant/filters/Native2AsciiFilter.java | 47 +++++++++++++++++
src/tests/antunit/filters/native2ascii-test.xml | 53 ++++++++++++++++++++
5 files changed, 139 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/41d51241/WHATSNEW
----------------------------------------------------------------------