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 2009/09/11 12:55:19 UTC

svn commit: r813774 - /ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java

Author: bodewig
Date: Fri Sep 11 10:55:16 2009
New Revision: 813774

URL: http://svn.apache.org/viewvc?rev=813774&view=rev
Log:
make protected access of some methods more useful by providing access to some needed private members

Modified:
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java

Modified: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java?rev=813774&r1=813773&r2=813774&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java (original)
+++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java Fri Sep 11 10:55:16 2009
@@ -93,14 +93,26 @@
         this.factory = factory;
     }
 
+    protected final ArchiveStreamFactory getFactory() {
+        return factory;
+    }
+
     protected final void setEntryBuilder(EntryBuilder builder) {
         this.entryBuilder = builder;
     }
 
+    protected final EntryBuilder getEntryBuilder() {
+        return entryBuilder;
+    }
+
     protected final void setFileSetBuilder(FileSetBuilder builder) {
         this.fileSetBuilder = builder;
     }
 
+    protected final FileSetBuilder getFileSetBuilder() {
+        return fileSetBuilder;
+    }
+
     /**
      * The archive to create.
      */
@@ -128,6 +140,10 @@
         dest = r;
     }
 
+    protected Resource getDest() {
+        return dest;
+    }
+
     /**
      * Sources for the archive.
      */
@@ -150,6 +166,13 @@
     }
 
     /**
+     * Encoding of file names.
+     */
+    public String getEncoding() {
+        return encoding;
+    }
+
+    /**
      * Whether only file entries should be added to the archive.
      */
     public void setFilesOnly(boolean b) {
@@ -157,6 +180,13 @@
     }
 
     /**
+     * Whether only file entries should be added to the archive.
+     */
+    protected boolean isFilesOnly() {
+        return filesOnly;
+    }
+
+    /**
      * Whether 0 permissions read from an archive should be considered
      * real permissions (that should be preserved) or missing
      * permissions (which is the default).
@@ -221,7 +251,7 @@
 
     public void execute() {
         validate();
-        if (!dest.isExists()) {
+        if (!getDest().isExists()) {
             // force create mode
             mode = new Mode();
             mode.setValue(Mode.FORCE_CREATE);
@@ -242,8 +272,8 @@
             try {
                 if (!Mode.FORCE_CREATE.equals(mode.getValue())
                     && !Mode.FORCE_REPLACE.equals(mode.getValue())
-                    && isUpToDate(toAdd)) {
-                    log(dest + " is up-to-date, nothing to do.");
+                    && isUpToDate(toAdd, getDest())) {
+                    log(getDest() + " is up-to-date, nothing to do.");
                     return;
                 }
             } catch (IOException ioex) {
@@ -273,7 +303,7 @@
             throw new BuildException("subclass didn't provide an fileSetBuilder"
                                      + " instance");
         }
-        if (dest == null) {
+        if (getDest() == null) {
             throw new BuildException("must provide a destination resource");
         }
         if (sources.size() == 0) {
@@ -293,7 +323,7 @@
             ResourceCollectionFlags rcFlags = getFlags(rc);
             for (Iterator rs = rc.iterator(); rs.hasNext(); ) {
                 Resource r = (Resource) rs.next();
-                if (!filesOnly || !r.isDirectory()) {
+                if (!isFilesOnly() || !r.isDirectory()) {
                     ResourceWithFlags rwf =
                         new ResourceWithFlags(r, rcFlags, getFlags(r));
                     String name = rwf.getName();
@@ -322,9 +352,13 @@
      *
      * <p>Will only ever be invoked if the target exists.</p>
      *
+     * @param src the resources that have been found as sources
+     * @param targetArchive the target archive
+     *
      * @return true if the target is up-to-date
      */
-    protected boolean isUpToDate(ResourceWithFlags[] src) throws IOException {
+    protected boolean isUpToDate(ResourceWithFlags[] src,
+                                 Resource targetArchive) throws IOException {
         final Resource[] srcResources = new Resource[src.length];
         for (int i = 0; i < srcResources.length; i++) {
             srcResources[i] =
@@ -334,7 +368,7 @@
         return ResourceUtils
             .selectOutOfDateSources(this, srcResources,
                                     new IdentityMapper(),
-                                    fileSetBuilder.buildFileSet(dest)
+                                    fileSetBuilder.buildFileSet(targetArchive)
                                     .getDirectoryScanner(getProject()))
             .length == 0;
     }
@@ -349,13 +383,13 @@
         Set addedDirectories = new HashSet();
         try {
             out =
-                factory.getArchiveStream(new BufferedOutputStream(dest
+                factory.getArchiveStream(new BufferedOutputStream(getDest()
                                                                   .getOutputStream()),
-                                         Expand.NATIVE_ENCODING.equals(encoding)
-                                         ? null : encoding);
+                                         Expand.NATIVE_ENCODING.equals(getEncoding())
+                                         ? null : getEncoding());
             for (int i = 0; i < src.length; i++) {
 
-                if (!filesOnly) {
+                if (!isFilesOnly()) {
                     ensureParentDirs(out, src[i], addedDirectories);
                 }