Update years in copyright line
[Sone.git] / src / main / java / net / pterodactylus / sone / template / ParserFilter.java
index db41830..109222e 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
@@ -17,6 +17,9 @@
 
 package net.pterodactylus.sone.template;
 
+import static java.lang.String.valueOf;
+import static net.pterodactylus.sone.utils.NumberParsers.parseInt;
+
 import java.io.IOException;
 import java.io.StringReader;
 import java.io.StringWriter;
@@ -44,9 +47,6 @@ import net.pterodactylus.util.template.TemplateContext;
 import net.pterodactylus.util.template.TemplateContextFactory;
 import net.pterodactylus.util.template.TemplateParser;
 
-import com.google.common.base.Optional;
-import com.google.common.primitives.Ints;
-
 /**
  * Filter that filters a given text through a {@link SoneTextParser}.
  *
@@ -91,12 +91,12 @@ public class ParserFilter implements Filter {
         */
        @Override
        public Object format(TemplateContext templateContext, Object data, Map<String, Object> parameters) {
-               String text = String.valueOf(data);
-               int length = Optional.fromNullable(Ints.tryParse(String.valueOf(parameters.get("length")))).or(-1);
-               int cutOffLength = Optional.fromNullable(Ints.tryParse(String.valueOf(parameters.get("cut-off-length")))).or(length);
+               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");
                if (sone instanceof String) {
-                       sone = core.getSone((String) sone, false);
+                       sone = core.getSone((String) sone).orNull();
                }
                FreenetRequest request = (FreenetRequest) templateContext.get("request");
                SoneTextParserContext context = new SoneTextParserContext(request, (Sone) sone);