You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by il...@apache.org on 2011/12/12 13:16:23 UTC

svn commit: r1213207 - /cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/XMLGenerator.java

Author: ilgrosso
Date: Mon Dec 12 12:16:23 2011
New Revision: 1213207

URL: http://svn.apache.org/viewvc?rev=1213207&view=rev
Log:
COCOON3-83 #resolve

Modified:
    cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/XMLGenerator.java

Modified: cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/XMLGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/XMLGenerator.java?rev=1213207&r1=1213206&r2=1213207&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/XMLGenerator.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/XMLGenerator.java Mon Dec 12 12:16:23 2011
@@ -109,14 +109,14 @@ public class XMLGenerator extends Abstra
         this.generator = new URLGenerator(url);
     }
 
+    @Override
     public CacheKey constructCacheKey() {
-        if (this.generator instanceof CachingPipelineComponent) {
-            return ((CachingPipelineComponent) this.generator).constructCacheKey();
-        }
-
-        return null;
+        return this.generator instanceof CachingPipelineComponent
+                ? ((CachingPipelineComponent) this.generator).constructCacheKey()
+                : null;
     }
 
+    @Override
     public void execute() {
         this.generator.execute();
     }
@@ -159,12 +159,11 @@ public class XMLGenerator extends Abstra
             this.encoding = encoding;
         }
 
+        @Override
         public void execute() {
             try {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Using a byte array as "
-                            + "source to produce SAX events.");
-                }
+                LOG.debug("Using a byte array as "
+                        + "source to produce SAX events.");
 
                 if (this.encoding == null) {
                     XMLUtils.toSax(new ByteArrayInputStream(this.bytes),
@@ -206,12 +205,12 @@ public class XMLGenerator extends Abstra
             this.file = file;
         }
 
+        @Override
         public void execute() {
             try {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Using file " + this.file.getAbsolutePath()
-                            + " as source to produce SAX events.");
-                }
+                LOG.debug("Using file {}"
+                        + " as source to produce SAX events.",
+                        this.file.getAbsolutePath());
 
                 XMLUtils.toSax(new FileInputStream(this.file),
                         XMLGenerator.this.getSAXConsumer());
@@ -243,12 +242,12 @@ public class XMLGenerator extends Abstra
             this.inputStream = inputStream;
         }
 
+        @Override
         public void execute() {
             try {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Using input stream " + this.inputStream
-                            + " as source to produce SAX events.");
-                }
+                LOG.debug("Using input stream {}"
+                        + " as source to produce SAX events.",
+                        this.inputStream);
 
                 XMLUtils.toSax(this.inputStream,
                         XMLGenerator.this.getSAXConsumer());
@@ -281,11 +280,9 @@ public class XMLGenerator extends Abstra
             this.node = document;
         }
 
+        @Override
         public void execute() {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Using a DOM node to produce "
-                        + "SAX events.");
-            }
+            LOG.debug("Using a DOM node to produce SAX events.");
 
             final DOMStreamer streamer = new DOMStreamer(
                     XMLGenerator.this.getSAXConsumer());
@@ -316,11 +313,9 @@ public class XMLGenerator extends Abstra
             this.saxBuffer = saxBuffer;
         }
 
+        @Override
         public void execute() {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Using a SAXBuffer to produce "
-                        + "SAX events.");
-            }
+            LOG.debug("Using a SAXBuffer to produce SAX events.");
 
             try {
                 this.saxBuffer.toSAX(XMLGenerator.this.getSAXConsumer());
@@ -356,14 +351,12 @@ public class XMLGenerator extends Abstra
          *
          * @see org.apache.cocoon.pipeline.component.Starter#execute()
          */
+        @Override
         public void execute() {
             try {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Using a string to produce SAX events.");
-                }
+                LOG.debug("Using a string to produce SAX events.");
 
-                XMLUtils.toSax(new ByteArrayInputStream(
-                        this.xmlString.getBytes()),
+                XMLUtils.toSax(this.xmlString,
                         XMLGenerator.this.getSAXConsumer());
             } catch (PipelineException e) {
                 LOG.error("Pipeline exception thrown", e);
@@ -396,19 +389,19 @@ public class XMLGenerator extends Abstra
          * @see org.apache.cocoon.pipeline.component.CachingPipelineComponent
          * #constructCacheKey()
          */
+        @Override
         public CacheKey constructCacheKey() {
             if (this.source == null) {
                 throw new SetupException(this.getClass().getSimpleName()
                         + " has no source.");
             }
 
+            CacheKey cacheKey = null;
             URLConnection connection = null;
             try {
                 connection = this.source.openConnection();
-                final TimestampCacheKey timestampCacheKey =
-                        new TimestampCacheKey(this.source,
+                cacheKey = new TimestampCacheKey(this.source,
                         connection.getLastModified());
-                return timestampCacheKey;
             } catch (IOException e) {
                 LOG.error("Can't construct cache key. "
                         + "Error while connecting to " + this.source, e);
@@ -418,7 +411,7 @@ public class XMLGenerator extends Abstra
                 }
             }
 
-            return null;
+            return cacheKey;
         }
 
         /**
@@ -426,16 +419,15 @@ public class XMLGenerator extends Abstra
          *
          * @see org.apache.cocoon.pipeline.component.Starter#execute()
          */
+        @Override
         public void execute() {
             if (this.source == null) {
                 throw new ProcessingException(this.getClass().getSimpleName()
                         + " has no source.");
             }
 
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Using the URL " + this.source
-                        + " to produce SAX events.");
-            }
+            LOG.debug("Using the URL {}"
+                    + " to produce SAX events.", this.source);
 
             try {
                 XMLUtils.toSax(this.source.openConnection(),