Override Object.toString() to get a reasonable String representation.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 1 Apr 2011 09:25:04 +0000 (11:25 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 1 Apr 2011 09:25:04 +0000 (11:25 +0200)
src/main/java/net/pterodactylus/sone/text/PartContainer.java
src/main/java/net/pterodactylus/sone/text/TemplatePart.java

index 7399859..05bfb3e 100644 (file)
@@ -18,6 +18,7 @@
 package net.pterodactylus.sone.text;
 
 import java.io.IOException;
+import java.io.StringWriter;
 import java.io.Writer;
 import java.util.ArrayList;
 import java.util.List;
@@ -62,4 +63,19 @@ public class PartContainer implements Part {
                }
        }
 
+       //
+       // OBJECT METHODS
+       //
+
+       @Override
+       public String toString() {
+               StringWriter stringWriter = new StringWriter();
+               try {
+                       render(stringWriter);
+               } catch (IOException ioe1) {
+                       /* should never throw, ignore. */
+               }
+               return stringWriter.toString();
+       }
+
 }
index 1ac1fdd..b948f10 100644 (file)
@@ -18,6 +18,7 @@
 package net.pterodactylus.sone.text;
 
 import java.io.IOException;
+import java.io.StringWriter;
 import java.io.Writer;
 
 import net.pterodactylus.util.template.Template;
@@ -89,4 +90,19 @@ public class TemplatePart implements Part, net.pterodactylus.util.template.Part
                template.render(templateContext.mergeContext(template.getInitialContext()), writer);
        }
 
+       //
+       // OBJECT METHODS
+       //
+
+       @Override
+       public String toString() {
+               StringWriter stringWriter = new StringWriter();
+               try {
+                       render(stringWriter);
+               } catch (IOException ioe1) {
+                       /* should never throw, ignore. */
+               }
+               return stringWriter.toString();
+       }
+
 }