factor out common message

git-svn-id: https://svn.apache.org/repos/asf/ant/antlibs/compress/trunk@1150544 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/org/apache/ant/compress/resources/CommonsCompressArchiveScanner.java b/src/main/org/apache/ant/compress/resources/CommonsCompressArchiveScanner.java
index 1b98e3d..7d7f53e 100644
--- a/src/main/org/apache/ant/compress/resources/CommonsCompressArchiveScanner.java
+++ b/src/main/org/apache/ant/compress/resources/CommonsCompressArchiveScanner.java
@@ -23,6 +23,7 @@
 import java.util.Map;
 
 import org.apache.ant.compress.util.ArchiveStreamFactory;
+import org.apache.ant.compress.util.Messages;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.ArchiveScanner;
@@ -66,13 +67,6 @@
     }
 
     /**
-     * @since Compress Antlib 1.1
-     */
-    public Project getProject() {
-        return project;
-    }
-
-    /**
      * Fills the file and directory maps with resources read from the
      * archive.
      *
@@ -106,8 +100,7 @@
             }
             while ((entry = ai.getNextEntry()) != null) {
                 if (skipUnreadable && !ai.canReadEntryData(entry)) {
-                    project.log("skipping " + entry.getName()
-                                + ", Commons Compress cannot read it");
+                    log(Messages.skippedIsUnreadable(entry));
                     continue;
                 }
                 Resource r = builder.buildResource(src, encoding, entry);
@@ -132,6 +125,18 @@
         }
     }
 
+    /**
+     * @since Compress Antlib 1.1
+     */
+    protected final void log(String msg) {
+        if (project != null) {
+            project.log(msg);
+        } else {
+            // rely on Ant's output redirection
+            System.out.println(msg);
+        }
+    }
+
     public static interface ResourceBuilder {
         /**
          * Creates the matching archive entry resource.
diff --git a/src/main/org/apache/ant/compress/resources/ZipScanner.java b/src/main/org/apache/ant/compress/resources/ZipScanner.java
index 90dbe8c..8d7653a 100644
--- a/src/main/org/apache/ant/compress/resources/ZipScanner.java
+++ b/src/main/org/apache/ant/compress/resources/ZipScanner.java
@@ -27,6 +27,7 @@
 import org.apache.ant.compress.util.ZipStreamFactory;
 
 import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.apache.ant.compress.util.Messages;
 import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
 import org.apache.commons.compress.archivers.zip.ZipFile;
 import org.apache.tools.ant.BuildException;
@@ -99,8 +100,7 @@
             while (e.hasMoreElements()) {
                 entry = (ZipArchiveEntry) e.nextElement();
                 if (getSkipUnreadableEntries() && !zf.canReadEntryData(entry)) {
-                    getProject().log("skipping " + entry.getName()
-                                     + ", Commons Compress cannot read it");
+                    log(Messages.skippedIsUnreadable(entry));
                     continue;
                 }
                 Resource r = new ZipResource(srcFile, encoding, entry);
diff --git a/src/main/org/apache/ant/compress/taskdefs/ExpandBase.java b/src/main/org/apache/ant/compress/taskdefs/ExpandBase.java
index 44eb0c9..cfe3bae 100644
--- a/src/main/org/apache/ant/compress/taskdefs/ExpandBase.java
+++ b/src/main/org/apache/ant/compress/taskdefs/ExpandBase.java
@@ -27,6 +27,7 @@
 
 import org.apache.ant.compress.util.ArchiveStreamFactory;
 import org.apache.ant.compress.util.EntryHelper;
+import org.apache.ant.compress.util.Messages;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
@@ -146,8 +147,7 @@
             ArchiveEntry ent = null;
             while ((ent = is.getNextEntry()) != null) {
                 if (skipUnreadable && !is.canReadEntryData(ent)) {
-                    log("skipping " + ent.getName()
-                        + ", Commons Compress cannot read it");
+                    log(Messages.skippedIsUnreadable(ent));
                     continue;
                 }
                 empty = false;
diff --git a/src/main/org/apache/ant/compress/taskdefs/Unzip.java b/src/main/org/apache/ant/compress/taskdefs/Unzip.java
index bf6e8d8..c6ca2b7 100644
--- a/src/main/org/apache/ant/compress/taskdefs/Unzip.java
+++ b/src/main/org/apache/ant/compress/taskdefs/Unzip.java
@@ -24,6 +24,7 @@
 import java.util.Date;
 import java.util.Enumeration;
 
+import org.apache.ant.compress.util.Messages;
 import org.apache.ant.compress.util.ZipStreamFactory;
 
 import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
@@ -65,8 +66,7 @@
                 empty = false;
                 ZipArchiveEntry ze = (ZipArchiveEntry) e.nextElement();
                 if (getSkipUnreadableEntries() && !zf.canReadEntryData(ze)) {
-                    log("skipping " + ze.getName()
-                        + ", Commons Compress cannot read it");
+                    log(Messages.skippedIsUnreadable(ze));
                     continue;
                 }
                 log("extracting " + ze.getName(), Project.MSG_DEBUG);
diff --git a/src/main/org/apache/ant/compress/util/Messages.java b/src/main/org/apache/ant/compress/util/Messages.java
new file mode 100644
index 0000000..81f47cb
--- /dev/null
+++ b/src/main/org/apache/ant/compress/util/Messages.java
@@ -0,0 +1,41 @@
+/*
+ *  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.util;
+
+import java.text.MessageFormat;
+import org.apache.commons.compress.archivers.ArchiveEntry;
+
+/**
+ * Factored out messages.
+ *
+ * @since Compress Antlib 1.1
+ */
+public final class Messages {
+
+    /**
+     * Message to log when Commons Compress knows it cannot handle a given
+     * entry.
+     */
+    public static String skippedIsUnreadable(ArchiveEntry ent) {
+        return MessageFormat.format("skipping {0}, Apache Commons Compress "
+                                    + "cannot read it.",
+                                    new Object[] { ent.getName() });
+    }
+
+}