From 352a702c1514412653310247b100e8b007e3210d Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Thu, 4 Sep 2014 20:30:35 +0200 Subject: [PATCH] [New] Implemented param null selector and ParameterBagSelector --- .../model/query/OrderSelectionVisitor.java | 2 +- .../model/query/ParameterBagSelection.java | 70 +++++++++++++++++++ .../model/query/ParameterSelection.java | 16 +++++ .../query/ParameterSelectionVisitor.java | 5 +- .../model/query/ResourceQueryVisitor.java | 3 +- .../StrolchRootElementSelectionVisitor.java | 28 ++++++++ 6 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 src/main/java/li/strolch/model/query/ParameterBagSelection.java create mode 100644 src/main/java/li/strolch/model/query/StrolchRootElementSelectionVisitor.java diff --git a/src/main/java/li/strolch/model/query/OrderSelectionVisitor.java b/src/main/java/li/strolch/model/query/OrderSelectionVisitor.java index 700208027..6f3c36349 100644 --- a/src/main/java/li/strolch/model/query/OrderSelectionVisitor.java +++ b/src/main/java/li/strolch/model/query/OrderSelectionVisitor.java @@ -19,7 +19,7 @@ package li.strolch.model.query; * @author Robert von Burg * */ -public interface OrderSelectionVisitor extends StrolchElementSelectionVisitor { +public interface OrderSelectionVisitor extends StrolchRootElementSelectionVisitor { public void visit(DateSelection selection); diff --git a/src/main/java/li/strolch/model/query/ParameterBagSelection.java b/src/main/java/li/strolch/model/query/ParameterBagSelection.java new file mode 100644 index 000000000..3ed626da0 --- /dev/null +++ b/src/main/java/li/strolch/model/query/ParameterBagSelection.java @@ -0,0 +1,70 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.model.query; + +/** + * @author Robert von Burg + */ +public class ParameterBagSelection implements Selection { + + private String bagKey; + + public ParameterBagSelection(String bagKey) { + this.bagKey = bagKey; + } + + /** + * @return the bagKey + */ + public String getBagKey() { + return this.bagKey; + } + + @Override + public boolean hasSelection() { + return true; + } + + @Override + public void accept(QueryVisitor visitor) { + accept((StrolchRootElementSelectionVisitor) visitor); + } + + public void accept(StrolchRootElementSelectionVisitor visitor) { + visitor.visit(this); + } + + @SuppressWarnings("nls") + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append(getClass().getSimpleName() + " [bagKey="); + builder.append(this.bagKey); + builder.append("]"); + return builder.toString(); + } + + public static class NullParameterBagSelection extends ParameterBagSelection { + + public NullParameterBagSelection(String bagKey) { + super(bagKey); + } + + public void accept(StrolchRootElementSelectionVisitor visitor) { + visitor.visit(this); + } + } +} diff --git a/src/main/java/li/strolch/model/query/ParameterSelection.java b/src/main/java/li/strolch/model/query/ParameterSelection.java index c1835b032..d6742d54c 100644 --- a/src/main/java/li/strolch/model/query/ParameterSelection.java +++ b/src/main/java/li/strolch/model/query/ParameterSelection.java @@ -105,6 +105,22 @@ public abstract class ParameterSelection implements Selection { return new StringListParameterSelection(bagKey, paramKey, value); } + public static NullParameterSelection nullSelection(String bagKey, String paramKey) { + return new NullParameterSelection(bagKey, paramKey); + } + + public static class NullParameterSelection extends ParameterSelection { + + public NullParameterSelection(String bagKey, String paramKey) { + super(bagKey, paramKey); + } + + @Override + public void accept(ParameterSelectionVisitor visitor) { + visitor.visit(this); + } + } + public static class StringParameterSelection extends ParameterSelection { private StringMatchMode matchMode; diff --git a/src/main/java/li/strolch/model/query/ParameterSelectionVisitor.java b/src/main/java/li/strolch/model/query/ParameterSelectionVisitor.java index e6b5b2e8d..3b53f54f6 100644 --- a/src/main/java/li/strolch/model/query/ParameterSelectionVisitor.java +++ b/src/main/java/li/strolch/model/query/ParameterSelectionVisitor.java @@ -21,6 +21,7 @@ import li.strolch.model.query.ParameterSelection.DateRangeParameterSelection; import li.strolch.model.query.ParameterSelection.FloatParameterSelection; import li.strolch.model.query.ParameterSelection.IntegerParameterSelection; import li.strolch.model.query.ParameterSelection.LongParameterSelection; +import li.strolch.model.query.ParameterSelection.NullParameterSelection; import li.strolch.model.query.ParameterSelection.StringListParameterSelection; import li.strolch.model.query.ParameterSelection.StringParameterSelection; @@ -40,8 +41,10 @@ public interface ParameterSelectionVisitor extends QueryVisitor { public void visit(FloatParameterSelection selection); public void visit(DateParameterSelection selection); - + public void visit(DateRangeParameterSelection selection); public void visit(StringListParameterSelection selection); + + public void visit(NullParameterSelection nullParameterSelection); } diff --git a/src/main/java/li/strolch/model/query/ResourceQueryVisitor.java b/src/main/java/li/strolch/model/query/ResourceQueryVisitor.java index 850b6950c..867e0b344 100644 --- a/src/main/java/li/strolch/model/query/ResourceQueryVisitor.java +++ b/src/main/java/li/strolch/model/query/ResourceQueryVisitor.java @@ -17,9 +17,8 @@ package li.strolch.model.query; /** * @author Robert von Burg - * */ -public interface ResourceQueryVisitor extends StrolchElementSelectionVisitor, ParameterSelectionVisitor { +public interface ResourceQueryVisitor extends StrolchRootElementSelectionVisitor, ParameterSelectionVisitor { // marker interface } diff --git a/src/main/java/li/strolch/model/query/StrolchRootElementSelectionVisitor.java b/src/main/java/li/strolch/model/query/StrolchRootElementSelectionVisitor.java new file mode 100644 index 000000000..3a2c3cace --- /dev/null +++ b/src/main/java/li/strolch/model/query/StrolchRootElementSelectionVisitor.java @@ -0,0 +1,28 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.model.query; + +import li.strolch.model.query.ParameterBagSelection.NullParameterBagSelection; + +/** + * @author Robert von Burg + */ +public interface StrolchRootElementSelectionVisitor extends StrolchElementSelectionVisitor { + + public void visit(ParameterBagSelection selection); + + public void visit(NullParameterBagSelection selection); +}