Remove @author tags
[Sone.git] / src / main / java / net / pterodactylus / sone / template / JavascriptFilter.java
index f852202..4c64f96 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - JavascriptFilter.java - Copyright © 2011 David Roden
+ * Sone - JavascriptFilter.java - Copyright © 2011–2016 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
@@ -19,16 +19,15 @@ package net.pterodactylus.sone.template;
 
 import java.util.Map;
 
-import net.pterodactylus.util.number.Hex;
 import net.pterodactylus.util.template.Filter;
 import net.pterodactylus.util.template.TemplateContext;
 
+import com.google.common.io.BaseEncoding;
+
 /**
  * Escapes double quotes, backslashes, carriage returns and line feeds, and
  * additionally encloses a given string with double quotes to make it possible
  * to use a string in Javascript.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
 public class JavascriptFilter implements Filter {
 
@@ -36,7 +35,7 @@ public class JavascriptFilter implements Filter {
         * {@inheritDoc}
         */
        @Override
-       public Object format(TemplateContext templateContext, Object data, Map<String, String> parameters) {
+       public Object format(TemplateContext templateContext, Object data, Map<String, Object> parameters) {
                StringBuilder javascriptString = new StringBuilder();
                javascriptString.append('"');
                for (char c : String.valueOf(data).toCharArray()) {
@@ -56,7 +55,7 @@ public class JavascriptFilter implements Filter {
                                javascriptString.append('\\');
                                javascriptString.append(c);
                        } else if (c < 32) {
-                               javascriptString.append("\\x").append(Hex.toHex((byte) c));
+                               javascriptString.append("\\x").append(BaseEncoding.base16().lowerCase().encode(new byte[] { (byte) c }));
                        } else {
                                javascriptString.append(c);
                        }