Add a LinkLine type, and a GeneralLine type as a placeholder.
M src/main/java/com/ajtjp/geminiclient/GeminiClient.java +9 -4
@@ 2,6 2,8 @@ package com.ajtjp.geminiclient;
 
 import com.ajtjp.geminiclient.lines.LineType;
 import com.ajtjp.geminiclient.lines.GeminiLine;
+import com.ajtjp.geminiclient.lines.GeneralLine;
+import com.ajtjp.geminiclient.lines.LinkLine;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;

          
@@ 91,18 93,21 @@ public class GeminiClient {
         boolean preformatToggle = false;
         for (String line : rawLines) {
             if (line.startsWith("=>")) {
-                geminiLines.add(new GeminiLine(LineType.LINK, line.substring(2)));
+                //TODO: Blows up when loading link, with ArrayIndexOutOfBounds exception:
+                // => gemini://mozz.us/journal/2020-05-22.gmi Mozz Gemlog - A new home for jetforce-diagnostics
+                //Need better error handling!  Note it's a link on that page, not the link above
+                geminiLines.add(new LinkLine(line));
             }
             else if (line.startsWith("```")) {
-                geminiLines.add(new GeminiLine(LineType.PREFORMAT_TOGGLE, ""));
+                geminiLines.add(new GeneralLine(LineType.PREFORMAT_TOGGLE, ""));
                 preformatToggle = !preformatToggle;
             }
             else {
                 if (preformatToggle) {
-                    geminiLines.add(new GeminiLine(LineType.PREFORMATTED, line));
+                    geminiLines.add(new GeneralLine(LineType.PREFORMATTED, line));
                 }
                 else {
-                    geminiLines.add(new GeminiLine(LineType.TEXT, line));
+                    geminiLines.add(new GeneralLine(LineType.TEXT, line));
                 }
             }
         }

          
M src/main/java/com/ajtjp/geminiclient/lines/GeminiLine.java +1 -6
@@ 1,11 1,6 @@ 
 package com.ajtjp.geminiclient.lines;
 
-public class GeminiLine {
+public abstract class GeminiLine {
     public LineType type;
     public String contents;
-    
-    public GeminiLine(LineType type, String contents) {
-        this.type = type;
-        this.contents = contents;
-    }
 }

          
A => src/main/java/com/ajtjp/geminiclient/lines/GeneralLine.java +13 -0
@@ 0,0 1,13 @@ 
+
+package com.ajtjp.geminiclient.lines;
+
+/**
+ * Placeholder while I'm refactoring...
+ * @author Andrew
+ */
+public class GeneralLine extends GeminiLine {
+    public GeneralLine(LineType type, String contents) {
+        this.type = type;
+        this.contents = contents;
+    }
+}

          
A => src/main/java/com/ajtjp/geminiclient/lines/LinkLine.java +30 -0
@@ 0,0 1,30 @@ 
+
+package com.ajtjp.geminiclient.lines;
+
+/**
+ *
+ * @author Andrew
+ */
+public class LinkLine extends GeminiLine {
+
+    public String url;
+    public String label;
+    
+    public LinkLine(String contents) {
+        this.type = LineType.LINK;
+        parseContents(contents);
+    }
+    
+    private void parseContents(String contents) {
+        String[] parts = contents.split("\\s+");
+        url = parts[1];
+        StringBuilder sb = new StringBuilder();
+        for (int i = 2; i < parts.length; i++) {
+            sb.append(parts[i]);
+            if (i < parts.length - 1) {
+                sb.append(" ");
+            }
+        }
+        label = sb.toString();
+    }
+}