Author: bodewig
Date: Fri Aug 28 03:56:46 2009
New Revision: 808745
URL: http://svn.apache.org/viewvc?rev=808745&view=rev
Log:
bzip2resource and gzipresource
Added:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/BZip2Resource.java
(with props)
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressCompressorResource.java
(contents, props changed)
- copied, changed from r808260,
ant/core/trunk/src/main/org/apache/tools/ant/types/resources/GZipResource.java
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/GZipResource.java
(with props)
ant/sandbox/antlibs/compress/trunk/src/tests/antunit/bzip2resource-test.xml
(with props)
ant/sandbox/antlibs/compress/trunk/src/tests/antunit/gzipresource-test.xml
(with props)
Modified:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
Modified:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
URL:
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml?rev=808745&r1=808744&r2=808745&view=diff
==============================================================================
---
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
(original)
+++
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
Fri Aug 28 03:56:46 2009
@@ -92,6 +92,15 @@
/>
<typedef
+ name="bzip2resource"
+ classname="org.apache.ant.compress.resources.BZip2Resource"
+ />
+ <typedef
+ name="gzipresource"
+ classname="org.apache.ant.compress.resources.GZipResource"
+ />
+
+ <typedef
name="hasusername"
classname="org.apache.ant.compress.conditions.HasUserName"
/>
Added:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/BZip2Resource.java
URL:
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/BZip2Resource.java?rev=808745&view=auto
==============================================================================
---
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/BZip2Resource.java
(added)
+++
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/BZip2Resource.java
Fri Aug 28 03:56:46 2009
@@ -0,0 +1,36 @@
+/*
+ * 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.ant.compress.resources;
+
+import org.apache.ant.compress.util.BZip2StreamFactory;
+import org.apache.tools.ant.types.ResourceCollection;
+
+/**
+ * A BZip2 compressed resource.
+ */
+public final class BZip2Resource extends CommonsCompressCompressorResource {
+ private static final String NAME = "BZip2";
+
+ public BZip2Resource() {
+ super(NAME, new BZip2StreamFactory());
+ }
+
+ public BZip2Resource(ResourceCollection other) {
+ super(NAME, new BZip2StreamFactory(), other);
+ }
+}
Propchange:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/BZip2Resource.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressCompressorResource.java
(from r808260,
ant/core/trunk/src/main/org/apache/tools/ant/types/resources/GZipResource.java)
URL:
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressCompressorResource.java?p2=ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressCompressorResource.java&p1=ant/core/trunk/src/main/org/apache/tools/ant/types/resources/GZipResource.java&r1=808260&r2=808745&rev=808745&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/types/resources/GZipResource.java
(original)
+++
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressCompressorResource.java
Fri Aug 28 03:56:46 2009
@@ -15,61 +15,76 @@
* limitations under the License.
*
*/
-package org.apache.tools.ant.types.resources;
+package org.apache.ant.compress.resources;
-import java.io.InputStream;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
-import java.util.zip.GZIPInputStream;
-import java.util.zip.GZIPOutputStream;
+
+import org.apache.ant.compress.util.CompressorStreamFactory;
+import org.apache.tools.ant.types.ResourceCollection;
+import org.apache.tools.ant.types.resources.ContentTransformingResource;
/**
- * A GZip compressed resource.
+ * A compressed resource.
*
* <p>Wraps around another resource, delegates all queries to that
* other resource but uncompresses/compresses streams on the fly.</p>
- *
- * @since Ant 1.7
*/
-public class GZipResource extends CompressedResource {
+public abstract class CommonsCompressCompressorResource
+ extends ContentTransformingResource {
+
+ private final String name;
+ private final CompressorStreamFactory factory;
/** A no-arg constructor */
- public GZipResource() {
+ protected CommonsCompressCompressorResource(String name,
+ CompressorStreamFactory
factory) {
+ this.name = name;
+ this.factory = factory;
}
/**
* Constructor with another resource to wrap.
* @param other the resource to wrap.
*/
- public GZipResource(org.apache.tools.ant.types.ResourceCollection other) {
+ protected CommonsCompressCompressorResource(String name,
+ CompressorStreamFactory
factory,
+ ResourceCollection other) {
super(other);
+ this.name = name;
+ this.factory = factory;
}
/**
- * Decompress on the fly using java.util.zip.GZIPInputStream.
+ * Decompress on the fly.
* @param in the stream to wrap.
* @return the wrapped stream.
* @throws IOException if there is a problem.
*/
- protected InputStream wrapStream(InputStream in) throws IOException {
- return new GZIPInputStream(in);
+ protected final InputStream wrapStream(InputStream in) throws IOException {
+ return factory.getCompressorStream(new BufferedInputStream(in));
}
/**
- * Compress on the fly using java.util.zip.GZIPOutStream.
+ * Compress on the fly.
* @param out the stream to wrap.
* @return the wrapped stream.
* @throws IOException if there is a problem.
*/
- protected OutputStream wrapStream(OutputStream out) throws IOException {
- return new GZIPOutputStream(out);
+ protected final OutputStream wrapStream(OutputStream out)
+ throws IOException {
+ return factory.getCompressorStream(new BufferedOutputStream(out));
}
/**
- * Get the name of the compression method.
- * @return the string "GZip".
+ * Get the string representation of this Resource.
+ * @return this Resource formatted as a String.
*/
- protected String getCompressionName() {
- return "GZip";
+ public String toString() {
+ return name + " compressed " + super.toString();
}
+
}
Propchange:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressCompressorResource.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressCompressorResource.java
------------------------------------------------------------------------------
svn:mergeinfo =
Added:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/GZipResource.java
URL:
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/GZipResource.java?rev=808745&view=auto
==============================================================================
---
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/GZipResource.java
(added)
+++
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/GZipResource.java
Fri Aug 28 03:56:46 2009
@@ -0,0 +1,36 @@
+/*
+ * 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.ant.compress.resources;
+
+import org.apache.ant.compress.util.GZipStreamFactory;
+import org.apache.tools.ant.types.ResourceCollection;
+
+/**
+ * A GZip compressed resource.
+ */
+public final class GZipResource extends CommonsCompressCompressorResource {
+ private static final String NAME = "GZip";
+
+ public GZipResource() {
+ super(NAME, new GZipStreamFactory());
+ }
+
+ public GZipResource(ResourceCollection other) {
+ super(NAME, new GZipStreamFactory(), other);
+ }
+}
Propchange:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/GZipResource.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
ant/sandbox/antlibs/compress/trunk/src/tests/antunit/bzip2resource-test.xml
URL:
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/tests/antunit/bzip2resource-test.xml?rev=808745&view=auto
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/tests/antunit/bzip2resource-test.xml
(added)
+++ ant/sandbox/antlibs/compress/trunk/src/tests/antunit/bzip2resource-test.xml
Fri Aug 28 03:56:46 2009
@@ -0,0 +1,40 @@
+<?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"
+ xmlns:cond="antlib:org.apache.tools.ant.types.conditions"
+ xmlns:cmp="antlib:org.apache.ant.compress">
+
+ <import file="antunit-base.xml" />
+
+ <target name="setUp">
+ <mkdir dir="${output}"/>
+ </target>
+
+ <target name="testNativeBzip2" depends="setUp">
+ <copy todir="${output}">
+ <cmp:bzip2resource>
+ <file file="../resources/asf-logo.gif.bz2"/>
+ </cmp:bzip2resource>
+ <globmapper from="*.bz2" to="*"/>
+ </copy>
+ <au:assertFilesMatch expected="../resources/asf-logo.gif"
+ actual="${output}/asf-logo.gif"/>
+ </target>
+</project>
Propchange:
ant/sandbox/antlibs/compress/trunk/src/tests/antunit/bzip2resource-test.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
ant/sandbox/antlibs/compress/trunk/src/tests/antunit/gzipresource-test.xml
URL:
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/tests/antunit/gzipresource-test.xml?rev=808745&view=auto
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/tests/antunit/gzipresource-test.xml
(added)
+++ ant/sandbox/antlibs/compress/trunk/src/tests/antunit/gzipresource-test.xml
Fri Aug 28 03:56:46 2009
@@ -0,0 +1,40 @@
+<?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"
+ xmlns:cond="antlib:org.apache.tools.ant.types.conditions"
+ xmlns:cmp="antlib:org.apache.ant.compress">
+
+ <import file="antunit-base.xml" />
+
+ <target name="setUp">
+ <mkdir dir="${output}"/>
+ </target>
+
+ <target name="testNativeGZip" depends="setUp">
+ <copy todir="${output}">
+ <cmp:gzipresource>
+ <file file="../resources/asf-logo.gif.gz"/>
+ </cmp:gzipresource>
+ <globmapper from="*.gz" to="*"/>
+ </copy>
+ <au:assertFilesMatch expected="../resources/asf-logo.gif"
+ actual="${output}/asf-logo.gif"/>
+ </target>
+</project>
Propchange:
ant/sandbox/antlibs/compress/trunk/src/tests/antunit/gzipresource-test.xml
------------------------------------------------------------------------------
svn:eol-style = native