Extract finding next whitespace into its own method.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 8 Nov 2013 23:59:00 +0000 (00:59 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:57 +0000 (22:25 +0100)
src/main/java/net/pterodactylus/sone/text/SoneTextParser.java

index 4f9900a..313758e 100644 (file)
@@ -194,8 +194,7 @@ public class SoneTextParser implements Parser<SoneTextParserContext> {
                                        }
                                        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<SoneTextParserContext> {
                return parts;
        }
 
+       private int findNextWhitespace(String line) {
+               Matcher matcher = whitespacePattern.matcher(line);
+               return matcher.find(0) ? matcher.start() : line.length();
+       }
+
        private Optional<NextLink> findNextLink(String line) {
                EnumMap<LinkType, Integer> linkTypeIndexes = new EnumMap<LinkType, Integer>(LinkType.class);
                for (LinkType linkType : LinkType.values()) {