From 4443dd5c27df6eee3f4a12db0160760300221138 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 9 Nov 2013 00:59:00 +0100 Subject: [PATCH] Extract finding next whitespace into its own method. --- src/main/java/net/pterodactylus/sone/text/SoneTextParser.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java index 4f9900a..313758e 100644 --- a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java +++ b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java @@ -194,8 +194,7 @@ public class SoneTextParser implements Parser { } lineComplete = false; - Matcher matcher = whitespacePattern.matcher(line); - int nextSpace = matcher.find(0) ? matcher.start() : line.length(); + int nextSpace = findNextWhitespace(line); String link = line.substring(0, nextSpace); String name = link; logger.log(Level.FINER, String.format("Found link: %s", link)); @@ -309,6 +308,11 @@ public class SoneTextParser implements Parser { return parts; } + private int findNextWhitespace(String line) { + Matcher matcher = whitespacePattern.matcher(line); + return matcher.find(0) ? matcher.start() : line.length(); + } + private Optional findNextLink(String line) { EnumMap linkTypeIndexes = new EnumMap(LinkType.class); for (LinkType linkType : LinkType.values()) { -- 2.7.4