Replace Reader with String in Parser interface
[Sone.git] / src / main / java / net / pterodactylus / sone / template / ParserFilter.java
index f402a41..6c74f0b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - ParserFilter.java - Copyright © 2011–2013 David Roden
+ * Sone - ParserFilter.java - Copyright © 2011–2015 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -91,7 +91,7 @@ public class ParserFilter implements Filter {
         */
        @Override
        public Object format(TemplateContext templateContext, Object data, Map<String, Object> parameters) {
-               String text = String.valueOf(data);
+               String text = valueOf(data);
                int length = parseInt(valueOf(parameters.get("length")), -1);
                int cutOffLength = parseInt(valueOf(parameters.get("cut-off-length")), length);
                Object sone = parameters.get("sone");
@@ -102,7 +102,7 @@ public class ParserFilter implements Filter {
                SoneTextParserContext context = new SoneTextParserContext(request, (Sone) sone);
                StringWriter parsedTextWriter = new StringWriter();
                try {
-                       Iterable<Part> parts = soneTextParser.parse(context, new StringReader(text));
+                       Iterable<Part> parts = soneTextParser.parse(context, text);
                        if (length > -1) {
                                int allPartsLength = 0;
                                List<Part> shortenedParts = new ArrayList<Part>();
@@ -253,7 +253,7 @@ public class ParserFilter implements Filter {
                SoneTextParser parser = new SoneTextParser(core, core);
                SoneTextParserContext parserContext = new SoneTextParserContext(null, postPart.getPost().getSone());
                try {
-                       Iterable<Part> parts = parser.parse(parserContext, new StringReader(postPart.getPost().getText()));
+                       Iterable<Part> parts = parser.parse(parserContext, postPart.getPost().getText());
                        StringBuilder excerpt = new StringBuilder();
                        for (Part part : parts) {
                                excerpt.append(part.getText());