Add javadoc comments.
[Sone.git] / src / main / java / net / pterodactylus / sone / text / PartContainer.java
index 7399859..d52658e 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;
@@ -48,6 +49,36 @@ public class PartContainer implements Part {
                parts.add(part);
        }
 
+       /**
+        * Returns the part at the given index.
+        *
+        * @param index
+        *            The index of the part
+        * @return The part
+        */
+       public Part getPart(int index) {
+               return parts.get(index);
+       }
+
+       /**
+        * Removes the part at the given index.
+        *
+        * @param index
+        *            The index of the part to remove
+        */
+       public void removePart(int index) {
+               parts.remove(index);
+       }
+
+       /**
+        * Returns the number of parts.
+        *
+        * @return The number of parts
+        */
+       public int size() {
+               return parts.size();
+       }
+
        //
        // PART METHODS
        //
@@ -62,4 +93,22 @@ public class PartContainer implements Part {
                }
        }
 
+       //
+       // OBJECT METHODS
+       //
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public String toString() {
+               StringWriter stringWriter = new StringWriter();
+               try {
+                       render(stringWriter);
+               } catch (IOException ioe1) {
+                       /* should never throw, ignore. */
+               }
+               return stringWriter.toString();
+       }
+
 }