package com.drew.metadata;


import java.util.ArrayList;

/**
 * Represents a subpath created by Photoshop:
 * <ul>
 *   <li>Closed Bezier knot, linked</li>
 *   <li>Closed Bezier knot, unlinked</li>
 *   <li>Open Bezier knot, linked</li>
 *   <li>Open Bezier knot, unlinked</li>
 * </ul>
 *
 * @author Payton Garland
 */
public class Subpath
{
    private final ArrayList<Knot> _knots = new ArrayList<Knot>();
    private final String _type;

    public Subpath()
    {
        this("");
    }

    public Subpath(String type)
    {
        _type = type;
    }

    /**
     * Insert a knot (set of 3 points) into the list
     */
    public void insert(Knot knot)
    {
        _knots.add(knot);
    }

    /**
     * Gets size of knots list
     *
     * @return size of knots ArrayList
     */
    public int size()
    {
        return _knots.size();
    }

    /**
     * Create a copy of this Subpath
     *
     * @return a new, duplicate Subpath
     */
    public Subpath copy()
    {
        Subpath copy = new Subpath(_type);
        for (Knot knot : _knots) {
            copy.insert(knot);
        }
        return copy;
    }

    @Override
    public String toString()
    {
        String description = _type + "(" + _knots.size() + " knots): ";
        for (Knot knot : _knots) {
            description += knot.getType() + "[ ";
            description += "(" + knot.getPoint(0) + ", " + knot.getPoint(1) + ")(";
            description += "(" + knot.getPoint(2) + ", " + knot.getPoint(3) + ")(";
            description += "(" + knot.getPoint(4) + ", " + knot.getPoint(5) + ") ]";
            description += " ";
        }
        return description;
    }
}

@@ -1198,16 +1198,23 @@
   String
+Builder
  descrip
@@ -1224,22 +1224,83 @@
 n = 
-_type + %22(%22 + 
+new StringBuilder();%0A%0A        description.append(_type).append(%22(%22).append(
 _kno
@@ -1308,19 +1308,25 @@
 s.size()
- + 
+).append(
 %22 knots)
@@ -1328,17 +1328,19 @@
 nots): %22
-;
+);%0A
 %0A       
@@ -1390,20 +1390,24 @@
 cription
- += 
+.append(
 knot.get
@@ -1416,15 +1416,22 @@
 pe()
- + 
+).append(
 %22%5B %22
+)
 ;%0A  
@@ -1455,44 +1455,66 @@
 tion
- += %22(%22 + knot.getPoint(0) + %22, %22 + 
+.append(%22(%22).append(knot.getPoint(0)).append(%22, %22).append(
 knot
@@ -1525,23 +1525,30 @@
 Point(1)
- + 
+).append(
 %22)(%22
+)
 ;%0A      
@@ -1568,44 +1568,66 @@
 tion
- += %22(%22 + knot.getPoint(2) + %22, %22 + 
+.append(%22(%22).append(knot.getPoint(2)).append(%22, %22).append(
 knot
@@ -1642,15 +1642,22 @@
 t(3)
- + 
+).append(
 %22)(%22
+)
 ;%0A  
@@ -1681,44 +1681,66 @@
 tion
- += %22(%22 + knot.getPoint(4) + %22, %22 + 
+.append(%22(%22).append(knot.getPoint(4)).append(%22, %22).append(
 knot
@@ -1755,16 +1755,23 @@
 t(5)
- + 
+).append(
 %22) %5D%22
+)
 ;%0A  
@@ -1795,15 +1795,20 @@
 tion
- += 
+.append(
 %22 %22
+)
 ;%0A  
@@ -1807,32 +1807,33 @@
 %22 %22);%0A        %7D%0A
+%0A
         return d
@@ -1842,16 +1842,27 @@
 cription
+.toString()
 ;%0A    %7D%0A

Replace string concatenation with StringBuilder