/**
 * Copyright (c) 2016, Michael Sonntag
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted under the terms of the BSD License. See
 * LICENSE file in the root of the Project.
 */

package lib;

import java.util.ArrayList;
import java.util.List;

/**
 * Parse list of Strings to a List of tagged entities.
 */
public final class ParseList {

    public static List<TaggedEntity> parseStringList(final List<String> toParse) {

        List<TaggedEntity> retList = new ArrayList<>();

        System.out.println(
                String.join("", "List has a length of: ",
                        Integer.toString(toParse.size()), "\n")
        );

        for (String currLine : toParse) {
            if (currLine.contains("(#)") & currLine.endsWith("#)")) {
                System.out.println("TagLine");
                System.out.println(currLine);

                retList.add(new TaggedEntity());
            } else {
                System.out.println("BodyLine");
                System.out.println(currLine);
            }
        }

        System.out.println(String.join("", "# of Tagged entities: ",
                Integer.toString(retList.size()))
        );

        return retList;
    }

}

@@ -619,16 +619,24 @@
 in(%22%22, %22
+%5BDEBUG%5D 
 List has
@@ -836,24 +836,25 @@
 th(%22#)%22)) %7B%0A
+%0A
             
@@ -877,16 +877,24 @@
 rintln(%22
+%5BDEBUG%5D 
 TagLine%22
@@ -900,122 +900,444 @@
 %22);%0A
-                System.out.println(currLine);%0A%0A                retList.add(new TaggedEntity());%0A            %7D else
+%0A                retList.add(new TaggedEntity());%0A%0A                String%5B%5D ls = currLine%0A                        .substring(currLine.indexOf(%22(#)%22)+%22(#)%22.length(),%0A                                currLine.length()-%22#)%22.length())%0A                        .split(%22,%22);%0A%0A                for (String s : ls) %7B%0A                    retList.get(retList.size()-1).getTags().add(s);%0A                %7D%0A%0A            %7D else if (!retList.isEmpty()) 
  %7B%0A 
@@ -1371,16 +1371,24 @@
 rintln(%22
+%5BDEBUG%5D 
 BodyLine
@@ -1395,51 +1395,347 @@
 %22);%0A
-                System.out.println(currLine
+%0A                String currString = retList.get(retList.size()-1).getBody();%0A                retList.get(retList.size()-1).setBody(%0A                        String.join(%22%22, currString, currLine, %22%5Cn%22)%0A                );%0A            %7D else %7B%0A                System.out.println(%22%5BWARNING%5D Found line not connected to a tag, will be omitted.%22
 );%0A 
@@ -1802,16 +1802,24 @@
 in(%22%22, %22
+%5BDEBUG%5D 
 # of Tag
@@ -1889,32 +1889,351 @@
 )))%0A        );%0A%0A
+        retList.forEach(c -%3E System.out.println(%0A                String.join(%22%22, %22%5BDEBUG%5D %22, %22ID: %22, c.getEntityID(), %22 Tags: %22,%0A                        Integer.toString(c.getTags().size()), %22 %22, c.getTags().toString(),%0A                        %22 Body: %22, c.getBody()%0A                    )%0A                )%0A        );%0A%0A
         return r

parse text to entity