21 package org.opensplice.dds.sub;
23 import java.util.ArrayList;
24 import java.util.Arrays;
25 import java.util.Collections;
26 import java.util.List;
42 private final int maxSamples;
47 private final String queryExpression;
48 private final List<String> queryParameters;
52 this.environment = environment;
54 this.maxSamples = DDS.LENGTH_UNLIMITED.value;
55 this.condition = null;
57 this.queryExpression = null;
58 this.queryParameters =
new ArrayList<String>();
60 this.retrieveNextInstance =
false;
63 @SuppressWarnings(
"unchecked")
65 String queryExpression, List<String> queryParameters,
67 boolean retrieveNextInstance) {
68 this.environment = s.environment;
69 this.reader = s.reader;
70 this.maxSamples = maxSamples;
71 this.instance = instance;
73 this.dataState = dataState.
clone();
74 this.queryExpression = queryExpression;
76 if (queryParameters == null) {
78 "Illegal List of query arguments (null) provided.");
80 this.queryParameters =
new ArrayList<String>(queryParameters);
82 if (this.queryExpression != null) {
84 .createQueryCondition(this.dataState, this.queryExpression,
85 this.queryParameters);
87 this.condition = null;
92 List<String> queryParameters) {
93 this(s, s.dataState, queryExpression, queryParameters, s.maxSamples,
94 s.instance, s.retrieveNextInstance);
98 this(s, dataState, s.queryExpression, s.queryParameters, s.maxSamples,
99 s.instance, s.retrieveNextInstance);
103 this(s, s.dataState, s.queryExpression, s.queryParameters, maxSamples,
104 s.instance, s.retrieveNextInstance);
108 this(s, s.dataState, s.queryExpression, s.queryParameters,
109 s.maxSamples, instance, s.retrieveNextInstance);
113 this(s, s.dataState, s.queryExpression, s.queryParameters,
119 return this.environment;
124 if (handle == null) {
126 "Illegal InstanceHandle (null) provided.");
128 if (!handle.equals(
this.instance)) {
136 if (this.retrieveNextInstance != retrieveNextInstance) {
142 private void checkDataStateValidity(
DataState state) {
145 "Illegal instance state.");
149 "Illegal sample state.");
153 "Illegal view state.");
161 "Illegal DataState (null) provided.");
163 checkDataStateValidity(state);
165 if (!state.
equals(
this.dataState)) {
171 private boolean isQueryEqualToCurrent(String qe, List<String> qp) {
175 throw new IllegalArgumentException(
176 "Query parameters for null query expression provided.");
179 if (this.queryExpression == null) {
188 if (qe.equals(
this.queryExpression)) {
190 if (this.queryParameters.size() == 0) {
194 }
else if (qp.size() == 0 && this.queryParameters.size() == 0) {
196 }
else if (qp.size() != this.queryParameters.size()) {
199 for (
int i = 0; i < qp.size(); i++) {
200 if (!qp.get(i).equals(this.queryParameters.get(i))) {
212 List<String> queryParameters) {
214 if (!isQueryEqualToCurrent(queryExpression, queryParameters)) {
223 String... queryParameters) {
224 if (queryParameters == null) {
225 return this.
Content(queryExpression,
new ArrayList<String>());
227 return this.
Content(queryExpression, Arrays.asList(queryParameters));
234 "maxSamples < 1 not supported.");
236 if (this.maxSamples != max) {
244 return this.instance;
254 return this.dataState.
clone();
260 return this.queryExpression;
266 return Collections.unmodifiableList(this.queryParameters);
271 return this.maxSamples;
276 if (this.condition == null) {
279 return this.condition;
284 return this.reader.
read(
this);
289 return this.reader.
read(samples,
this);
294 return this.reader.
take(
this);
299 return this.reader.
take(samples,
this);
304 if (this.condition != null) {
306 this.condition.
close();
307 }
catch (Exception e) {
A DataReader allows the application (1) to declare the data it wishes to receive (i.e., make a subscription) and (2) to access the data received by the attached org.omg.dds.sub.Subscriber.
A Subscriber is the object responsible for the actual reception of the data resulting from its subscr...
A Sample represents an atom of data information (i.e., one value for one instance) as returned by a o...
Selector< TYPE > Content(String queryExpression, List< String > queryParameters)
InstanceHandle nilHandle()
InstanceHandle getInstance()
Selector< TYPE > nextInstance(boolean retrieveNextInstance)
A DataState encapsulates sets of sample states, view states, and instance states as a convenience...
Selector< TYPE > maxSamples(int max)
Selector< TYPE > dataState(DataState state)
Selector< TYPE > instance(InstanceHandle handle)
String getQueryExpression()
List< String > getQueryParameters()
Selector< TYPE > Content(String queryExpression, String... queryParameters)
Set< SampleState > getSampleStates()
Get the current set of sample states.
An opaque handle that can be used to refer to a local or remote entity.
List< Sample< TYPE > > take(List< Sample< TYPE >> samples)
void close()
Reclaim any resources associated with this condition.
ServiceProviderInterface getSPI()
ReadCondition< TYPE > createReadCondition(DataState states)
This operation creates a ReadCondition.
ReadCondition objects are conditions specifically dedicated to read operations and attached to one or...
Iterator< TYPE > take()
This operation accesses a collection of samples from this DataReader.
SelectorImpl(OsplServiceEnvironment environment, AbstractDataReader< TYPE > reader)
ServiceEnvironment getEnvironment()
Set< ViewState > getViewStates()
Get the current set of view states.
static DataStateImpl any(OsplServiceEnvironment environment)
DDS implementations are rooted in this class, a concrete subclass of which can be instantiated based ...
Selector class encapsulates different ways of selecting samples from a org.omg.dds.sub.DataReader.
boolean retrieveNextInstance()
Set< InstanceState > getInstanceStates()
Get the current set of instance states.
ReadCondition< TYPE > getCondition()
List< Sample< TYPE > > read(List< Sample< TYPE >> samples)
Iterator< TYPE > read()
This operation accesses a collection of samples from this DataReader.
boolean equals(Object other)