21 package org.opensplice.dds.sub;
23 import java.lang.reflect.Array;
24 import java.lang.reflect.Field;
25 import java.util.ArrayList;
26 import java.util.List;
34 import DDS.SampleInfoSeqHolder;
39 private final Class<?> dataSeqHolderClaz;
40 private final Field dataSeqHolderValueField;
43 private SampleInfoSeqHolder infoSeqHolder;
44 private Object dataSeqHolder;
45 private List<Sample<PROTOBUF_TYPE>> sampleList;
47 @SuppressWarnings(
"unchecked")
50 Class<?> dataSeqHolderClaz, Field dataSeqHolderValueField,
51 List<
Sample<PROTOBUF_TYPE>> preAllocated) {
52 this.environment = environment;
53 this.sampleList = preAllocated;
54 this.dataSeqHolderClaz = dataSeqHolderClaz;
55 this.dataSeqHolderValueField = dataSeqHolderValueField;
57 .getTopicDescription().getTypeSupport();
65 if (preAllocated == null) {
66 this.sampleList =
new ArrayList<Sample<PROTOBUF_TYPE>>();
68 this.sampleList = preAllocated;
69 this.sampleList.clear();
71 this.infoSeqHolder =
new SampleInfoSeqHolder();
72 this.dataSeqHolder = dataSeqHolderClaz.newInstance();
73 }
catch (InstantiationException e) {
75 + e.getMessage() +
").");
76 }
catch (IllegalAccessException e) {
78 + e.getMessage() +
").");
79 }
catch (ClassCastException ce) {
81 "Usage of non-OpenSplice Sample implementation is not supported.");
85 @SuppressWarnings(
"unchecked")
89 Object dataValue = this.dataSeqHolderValueField
90 .get(this.dataSeqHolder);
92 for (
int i = 0; i < this.infoSeqHolder.value.length; i++) {
93 if (this.infoSeqHolder.value[i].valid_data) {
96 this.typeSupport.ddsToProtobuf((DDS_TYPE)Array.get(dataValue, i)),
97 this.infoSeqHolder.value[i]));
101 this.typeSupport.ddsKeyToProtobuf((DDS_TYPE)Array.get(dataValue, i)),
102 this.infoSeqHolder.value[i]));
106 }
catch (IllegalArgumentException e) {
108 + e.getMessage() +
").");
109 }
catch (IllegalAccessException e) {
111 + e.getMessage() +
").");
117 return this.dataSeqHolder;
122 return this.infoSeqHolder;
127 return this.sampleList;
A Sample represents an atom of data information (i.e., one value for one instance) as returned by a o...
void setSampleList(List< Sample< PROTOBUF_TYPE >> preAllocated)
List< Sample< PROTOBUF_TYPE > > getSampleList()
SampleInfoSeqHolder getInfoSeqHolder()
Object getDataSeqHolder()