From: David ‘Bombe’ Roden Date: Fri, 8 Nov 2013 23:59:00 +0000 (+0100) Subject: Extract finding next whitespace into its own method. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=4443dd5c27df6eee3f4a12db0160760300221138;p=Sone.git Extract finding next whitespace into its own method. --- 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()) {