X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftemplate%2FRequestChangeFilter.java;h=2d6167a37739121daf3cdac320a288c3b4a35a42;hb=144cf48d9b40d0379456d61a504999612f530733;hp=380027b53ce7f235a145d60dab9504f4b0f277b2;hpb=64427850be2b3130b3a2cef30170c95bae2c1a02;p=Sone.git
diff --git a/src/main/java/net/pterodactylus/sone/template/RequestChangeFilter.java b/src/main/java/net/pterodactylus/sone/template/RequestChangeFilter.java
index 380027b..2d6167a 100644
--- a/src/main/java/net/pterodactylus/sone/template/RequestChangeFilter.java
+++ b/src/main/java/net/pterodactylus/sone/template/RequestChangeFilter.java
@@ -1,5 +1,5 @@
/*
- * Sone - RequestChangeFilter.java - Copyright © 2010 David Roden
+ * Sone - RequestChangeFilter.java - Copyright © 2010â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
@@ -26,15 +26,14 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-import net.pterodactylus.sone.web.page.Page.Request;
-import net.pterodactylus.util.template.DataProvider;
+import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.template.Filter;
+import net.pterodactylus.util.template.TemplateContext;
/**
- * This filter expects a {@link Request} as input and outputs a {@link URI} that
- * is modified by the parameters. The name of the parameter is handed in as
- * ânameâ, the value may either be stored in âvalueâ, or in a template variable
- * whose key is stored in âkeyâ.
+ * This filter expects a {@link FreenetRequest} as input and outputs a
+ * {@link URI} that is modified by the parameters. The name of the parameter is
+ * handed in as ânameâ, the new value is stored in âvalueâ.
*
* @author David âBombeâ Roden
*/
@@ -44,24 +43,10 @@ public class RequestChangeFilter implements Filter {
* {@inheritDoc}
*/
@Override
- public Object format(DataProvider dataProvider, Object data, Map parameters) {
- Request request = (Request) data;
- String name = parameters.get("name");
- String nameKey = parameters.get("nameKey");
- if (nameKey != null) {
- name = String.valueOf(dataProvider.getData(nameKey));
- }
- String key = parameters.get("key");
- String value = null;
- if (key != null) {
- value = String.valueOf(dataProvider.getData(key));
- }
- if (value == null) {
- value = parameters.get("value");
- }
- if (value == null) {
- return request.getUri();
- }
+ public Object format(TemplateContext templateContext, Object data, Map parameters) {
+ FreenetRequest request = (FreenetRequest) data;
+ String name = String.valueOf(parameters.get("name"));
+ String value = String.valueOf(parameters.get("value"));
Map values = new HashMap();
Collection parameterNames = request.getHttpRequest().getParameterNames();
@@ -83,8 +68,7 @@ public class RequestChangeFilter implements Filter {
if (questionMark == -1) {
questionMark = oldUri.length();
}
- URI u = new URI(oldUri.substring(0, questionMark) + query.toString());
- return u;
+ return new URI(oldUri.substring(0, questionMark) + query.toString());
} catch (UnsupportedEncodingException uee1) {
/* UTF-8 not supported? I donât think so. */
} catch (URISyntaxException use1) {