From 7b8defc56fc43566290a5b975936edbdf3adbed2 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Mon, 4 Aug 2014 14:50:56 +0200 Subject: [PATCH] [New] added StrolchQuery.getSelection() and cleaned up some constants --- .../strolch/agent/impl/CachedResourceMap.java | 13 +++++++++---- .../li/strolch/runtime/StrolchConstants.java | 19 +++++++++---------- .../query/inmemory/ParameterSelector.java | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/main/java/li/strolch/agent/impl/CachedResourceMap.java b/src/main/java/li/strolch/agent/impl/CachedResourceMap.java index 362d1789b..e73ea8a69 100644 --- a/src/main/java/li/strolch/agent/impl/CachedResourceMap.java +++ b/src/main/java/li/strolch/agent/impl/CachedResourceMap.java @@ -1,6 +1,9 @@ package li.strolch.agent.impl; import static li.strolch.runtime.StrolchConstants.INTERPRETATION_RESOURCE_REF; + +import java.text.MessageFormat; + import li.strolch.agent.api.ResourceMap; import li.strolch.exception.StrolchException; import li.strolch.model.Resource; @@ -15,13 +18,15 @@ public class CachedResourceMap extends CachedElementMap implements Res public Resource getBy(StrolchTransaction tx, StringParameter refP) throws StrolchException { if (!refP.getInterpretation().equals(INTERPRETATION_RESOURCE_REF)) { - throw new StrolchException(refP.getLocator() - + " is not an Resource reference as its interpretation is not " + INTERPRETATION_RESOURCE_REF); + String msg = MessageFormat.format("{0} is not an Resource reference as its interpretation is not {1}", //$NON-NLS-1$ + refP.getLocator(), INTERPRETATION_RESOURCE_REF); + throw new StrolchException(msg); } if (refP.getUom().equals(Parameter.UOM_NONE)) { - throw new StrolchException(refP.getLocator() - + " is not an Resource reference as its UOM is not set to a type!"); + String msg = MessageFormat.format("{0} is not an Resource reference as its UOM is not set to a type!", //$NON-NLS-1$ + refP.getLocator()); + throw new StrolchException(msg); } String type = refP.getUom(); diff --git a/src/main/java/li/strolch/runtime/StrolchConstants.java b/src/main/java/li/strolch/runtime/StrolchConstants.java index 6d114a5a2..02c357ae8 100644 --- a/src/main/java/li/strolch/runtime/StrolchConstants.java +++ b/src/main/java/li/strolch/runtime/StrolchConstants.java @@ -15,9 +15,7 @@ */ package li.strolch.runtime; -import li.strolch.model.Order; -import li.strolch.model.Resource; -import li.strolch.model.parameter.Parameter; +import li.strolch.model.StrolchModelConstants; import li.strolch.persistence.api.PersistenceHandler; import li.strolch.runtime.observer.ObserverHandler; @@ -36,17 +34,18 @@ public class StrolchConstants { public static final String DEFAULT_XML_VERSION = "1.0"; //$NON-NLS-1$ public static final String DEFAULT_ENCODING = "utf-8"; //$NON-NLS-1$ - public static final String TEMPLATE = "Template"; + /** + * @see StrolchModelConstants#TEMPLATE + */ + public static final String TEMPLATE = StrolchModelConstants.TEMPLATE; /** - * This interpretation value indicates that the value of the {@link Parameter} should be understood as a reference - * to a {@link Resource} + * @see StrolchModelConstants#INTERPRETATION_RESOURCE_REF */ - public static final String INTERPRETATION_RESOURCE_REF = "Resource-Ref"; //$NON-NLS-1$ + public static final String INTERPRETATION_RESOURCE_REF = StrolchModelConstants.INTERPRETATION_RESOURCE_REF; /** - * This interpretation value indicates that the value of the {@link Parameter} should be understood as a reference - * to an {@link Order} + * @see StrolchModelConstants#INTERPRETATION_ORDER_REF */ - public static final String INTERPRETATION_ORDER_REF = "Order-Ref"; //$NON-NLS-1$ + public static final String INTERPRETATION_ORDER_REF = StrolchModelConstants.INTERPRETATION_ORDER_REF; } diff --git a/src/main/java/li/strolch/runtime/query/inmemory/ParameterSelector.java b/src/main/java/li/strolch/runtime/query/inmemory/ParameterSelector.java index a3958e1d6..d0625c314 100644 --- a/src/main/java/li/strolch/runtime/query/inmemory/ParameterSelector.java +++ b/src/main/java/li/strolch/runtime/query/inmemory/ParameterSelector.java @@ -277,7 +277,7 @@ public abstract class ParameterSelector i DateParameter param = bag.getParameter(this.paramKey); Date value = param.getValue(); - return (from == null || !value.before(from)) && (to == null || !value.after(to)); + return (this.from == null || !value.before(this.from)) && (this.to == null || !value.after(this.to)); } }