WICKET-5539 Incorrect recreation of page in case of PageExpire Add javadoc and method to read all named parameters with a given type
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/e8773fb1 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/e8773fb1 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/e8773fb1 Branch: refs/heads/master Commit: e8773fb18da2d763d62a2857335b3c73d491d064 Parents: 5f0e63c Author: Martin Tzvetanov Grigorov <mgrigo...@apache.org> Authored: Mon Aug 11 11:59:55 2014 +0200 Committer: Martin Tzvetanov Grigorov <mgrigo...@apache.org> Committed: Mon Aug 11 12:11:25 2014 +0200 ---------------------------------------------------------------------- .../mapper/parameter/INamedParameters.java | 19 +++++++ .../mapper/parameter/PageParameters.java | 53 ++++++++++---------- 2 files changed, 46 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/e8773fb1/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/INamedParameters.java ---------------------------------------------------------------------- diff --git a/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/INamedParameters.java b/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/INamedParameters.java index f09874d..288cd7c 100644 --- a/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/INamedParameters.java +++ b/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/INamedParameters.java @@ -31,12 +31,24 @@ import org.apache.wicket.util.string.StringValue; */ public interface INamedParameters { + /** + * A hint where the parameter is read from. + */ enum Type { + /** + * The named parameter is set manually in the application code + */ MANUAL, + /** + * The named parameter is read/parsed from the query string + */ QUERY_STRING, + /** + * The named parameter is read/parsed from the url path + */ PATH } @@ -145,6 +157,13 @@ public interface INamedParameters List<NamedPair> getAllNamed(); /** + * @param type + * The type to filter + * @return All named parameters with the given type. If the type is {@code null} then returns all named parameters. + */ + List<NamedPair> getAllNamedByType(Type type); + + /** * Returns the position of a named parameter. * * @param name http://git-wip-us.apache.org/repos/asf/wicket/blob/e8773fb1/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParameters.java ---------------------------------------------------------------------- diff --git a/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParameters.java b/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParameters.java index 0b6e7fb..357e91a 100644 --- a/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParameters.java +++ b/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParameters.java @@ -55,7 +55,7 @@ public class PageParameters implements IClusterable, IIndexedParameters, INamedP private List<NamedPair> namedParameters; /** - * Construct. + * Constructor. */ public PageParameters() { @@ -65,6 +65,7 @@ public class PageParameters implements IClusterable, IIndexedParameters, INamedP * Copy constructor. * * @param copy + * The parameters to copy from */ public PageParameters(final PageParameters copy) { @@ -110,9 +111,6 @@ public class PageParameters implements IClusterable, IIndexedParameters, INamedP return this; } - /** - * @see org.apache.wicket.request.mapper.parameter.IIndexedParameters#get(int) - */ @Override public StringValue get(final int index) { @@ -126,9 +124,6 @@ public class PageParameters implements IClusterable, IIndexedParameters, INamedP return StringValue.valueOf((String)null); } - /** - * @see org.apache.wicket.request.mapper.parameter.IIndexedParameters#remove(int) - */ @Override public PageParameters remove(final int index) { @@ -142,9 +137,6 @@ public class PageParameters implements IClusterable, IIndexedParameters, INamedP return this; } - /** - * @see org.apache.wicket.request.mapper.parameter.INamedParameters#getNamedKeys() - */ @Override public Set<String> getNamedKeys() { @@ -160,9 +152,6 @@ public class PageParameters implements IClusterable, IIndexedParameters, INamedP return Collections.unmodifiableSet(set); } - /** - * @see org.apache.wicket.request.mapper.parameter.INamedParameters#get(java.lang.String) - */ @Override public StringValue get(final String name) { @@ -181,9 +170,6 @@ public class PageParameters implements IClusterable, IIndexedParameters, INamedP return StringValue.valueOf((String)null); } - /** - * @see org.apache.wicket.request.mapper.parameter.INamedParameters#getValues(java.lang.String) - */ @Override public List<StringValue> getValues(final String name) { @@ -207,18 +193,35 @@ public class PageParameters implements IClusterable, IIndexedParameters, INamedP } } - /** - * @see org.apache.wicket.request.mapper.parameter.INamedParameters#getAllNamed() - */ @Override public List<NamedPair> getAllNamed() { return namedParameters != null ? Collections.unmodifiableList(namedParameters) : Collections.<NamedPair>emptyList(); } - /** - * @see org.apache.wicket.request.mapper.parameter.INamedParameters#getPosition(String) - */ + + @Override + public List<NamedPair> getAllNamedByType(Type type) + { + List<NamedPair> allNamed = getAllNamed(); + if (type == null || allNamed.isEmpty()) + { + return allNamed; + } + + List<NamedPair> parametersByType = new ArrayList<>(); + Iterator<NamedPair> iterator = allNamed.iterator(); + while (iterator.hasNext()) + { + NamedPair pair = iterator.next(); + if (type == pair.getType()) + { + parametersByType.add(pair); + } + } + return Collections.unmodifiableList(parametersByType); + } + @Override public int getPosition(final String name) { @@ -238,10 +241,6 @@ public class PageParameters implements IClusterable, IIndexedParameters, INamedP return index; } - /** - * @see org.apache.wicket.request.mapper.parameter.INamedParameters#remove(java.lang.String, - * java.lang.String...) - */ @Override public PageParameters remove(final String name, final String... values) { @@ -441,7 +440,9 @@ public class PageParameters implements IClusterable, IIndexedParameters, INamedP * Compares two {@link PageParameters} objects. * * @param p1 + * The first parameters * @param p2 + * The second parameters * @return <code>true</code> if the objects are equal, <code>false</code> otherwise. */ public static boolean equals(final PageParameters p1, final PageParameters p2)