You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@creadur.apache.org by rd...@apache.org on 2012/08/18 21:08:34 UTC

svn commit: r1374636 - in /creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app: analysis/ResourceSourceAuditor.java load/StreamableClassPathResource.java

Author: rdonkin
Date: Sat Aug 18 19:08:34 2012
New Revision: 1374636

URL: http://svn.apache.org/viewvc?rev=1374636&view=rev
Log:
Tidied up code and javadocs based on checkstyles

Modified:
    creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/analysis/ResourceSourceAuditor.java
    creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/load/StreamableClassPathResource.java

Modified: creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/analysis/ResourceSourceAuditor.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/analysis/ResourceSourceAuditor.java?rev=1374636&r1=1374635&r2=1374636&view=diff
==============================================================================
--- creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/analysis/ResourceSourceAuditor.java (original)
+++ creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/analysis/ResourceSourceAuditor.java Sat Aug 18 19:08:34 2012
@@ -14,7 +14,7 @@
  * "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. 
+ * under the License.
  */
 package org.apache.creadur.whisker.app.analysis;
 
@@ -30,73 +30,91 @@ import org.apache.creadur.whisker.model.
 import org.apache.creadur.whisker.model.WithinDirectory;
 
 /**
- * 
+ * Collects resource source details.
  */
-public class ResourceSourceAuditor extends Visitor {
-
+public final class ResourceSourceAuditor extends Visitor {
+    /** Last license visited. */
     private WithLicense lastLicense;
+    /** Last directory visited. */
     private WithinDirectory lastDirectory;
-    
-    private final Collection<Pair<WithinDirectory, Resource>> resourcesMissingSource 
-        = new TreeSet<Pair<WithinDirectory, Resource>>();
-    
-    private final Collection<Pair<WithinDirectory, Resource>> resourcesWithSource 
-    = new TreeSet<Pair<WithinDirectory, Resource>>();
-    
+    /** Collects resources that are missing source. */
+    private final Collection<
+        Pair<WithinDirectory, Resource>> resourcesMissingSource
+            = new TreeSet<Pair<WithinDirectory, Resource>>();
+    /** Collects resources that match a source. */
+    private final Collection<
+        Pair<WithinDirectory, Resource>> resourcesWithSource
+            = new TreeSet<Pair<WithinDirectory, Resource>>();
+
     /**
+     * Hook for public domain.
+     * @return false (no need to traverse public domain)
      * @see Visitor#traversePublicDomain()
      */
     @Override
     public boolean traversePublicDomain() {
-        // TODO: no need to traverse public domain 
-        // TODO: think about API 
+        // no need to traverse public domain
         return false;
     }
 
-    
+
     /**
-     * @return the resourcesWithSource
+     * Gets the resources with source collected during visits.
+     * @return the resourcesWithSource, not null
      */
-    public Collection<Pair<WithinDirectory, Resource>> getResourcesWithSource() {
+    public Collection<
+            Pair<WithinDirectory, Resource>> getResourcesWithSource() {
         return resourcesWithSource;
     }
 
     /**
-     * @return the resourcesMissingSource
+     * Gets the resources missing source collected during visits.
+     * @return the resourcesMissingSource not null
      */
-    public Collection<Pair<WithinDirectory, Resource>> getResourcesMissingSource() {
+    public Collection<
+            Pair<WithinDirectory, Resource>> getResourcesMissingSource() {
         return resourcesMissingSource;
     }
 
     /**
+     * Accepts a directory visit.
+     * @param directory not null
      * @see Visitor#visit(WithinDirectory)
      */
     @Override
-    public void visit(WithinDirectory directory) {
+    public void visit(final WithinDirectory directory) {
         this.lastDirectory = directory;
     }
 
 
 
     /**
+     * Accepts a license visit.
+     * @param license not null
      * @see Visitor#visit(WithLicense)
      */
     @Override
-    public void visit(WithLicense license) {
+    public void visit(final WithLicense license) {
         this.lastLicense = license;
     }
 
     /**
+     * Accepts a visit to a resource.
+     * @param resource not null
      * @see Visitor#visit(Resource)
      */
     @Override
     @SuppressWarnings("PMD.EmptyIfStmt")
-    public void visit(Resource resource) {
+    public void visit(final Resource resource) {
         if (lastLicense == null) {
-            throw new IllegalArgumentException("Last license unexpectedly null for resource " + resource);
+            throw new IllegalArgumentException(
+                    "Last license unexpectedly null for resource "
+                            + resource);
         } else if (lastLicense.isSourceRequired()) {
-            // TODO: Consider using ResourceDescription
-            final ImmutablePair<WithinDirectory, Resource> pair = new ImmutablePair<WithinDirectory, Resource>(lastDirectory, resource);
+            final ImmutablePair<WithinDirectory, Resource> pair =
+                    new ImmutablePair<
+                        WithinDirectory,
+                        Resource>(lastDirectory, resource);
             if (resource.hasSource()) {
                 resourcesWithSource.add(pair);
             } else {
@@ -109,7 +127,8 @@ public class ResourceSourceAuditor exten
 
 
     /**
-     * @return
+     * Gets those resources visited which require source links.
+     * @return not null, possibly empty
      */
     public Collection<Resource> getResourcesRequiringSourceLinks() {
         final Collection<Resource> results = new ArrayList<Resource>();
@@ -118,5 +137,5 @@ public class ResourceSourceAuditor exten
         }
         return results;
     }
-    
+
 }

Modified: creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/load/StreamableClassPathResource.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/load/StreamableClassPathResource.java?rev=1374636&r1=1374635&r2=1374636&view=diff
==============================================================================
--- creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/load/StreamableClassPathResource.java (original)
+++ creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/load/StreamableClassPathResource.java Sat Aug 18 19:08:34 2012
@@ -14,7 +14,7 @@
  * "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. 
+ * under the License.
  */
 package org.apache.creadur.whisker.app.load;
 
@@ -28,13 +28,16 @@ import org.apache.creadur.whisker.app.St
  */
 public class StreamableClassPathResource extends StreamableResource {
 
-    /** The full name <strong>including path</strong> of a resource on the class path */
+    /**
+     * The full name <strong>including path</strong>
+     * of a resource on the class path.
+     */
     private final String name;
-  
+
     /**
      * Constructs an instance that streams the given class path resource
      * on demand.
-     * @param name full name <strong>including path</strong> of 
+     * @param name full name <strong>including path</strong> of
      * a resource on the class path,
      * not null
      */
@@ -43,7 +46,7 @@ public class StreamableClassPathResource
         this.name = name;
     }
 
-    
+
     /**
      * Gets the location on the class path of the resource to be streamed.
      * @return not null
@@ -61,7 +64,7 @@ public class StreamableClassPathResource
     public InputStream open() throws IOException {
         return getClass().getClassLoader().getResourceAsStream(name);
     }
-    
+
     @Override
     public String toString() {
         return "StreamableClassPathResource [name=" + name + "]";