OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
TopicDataImpl.java
Go to the documentation of this file.
1 /*
2  * Vortex OpenSplice
3  *
4  * This software and documentation are Copyright 2006 to 2024 ADLINK
5  * Technology Limited, its affiliated companies and licensors. All rights
6  * reserved.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 package org.opensplice.dds.core.policy;
22 
23 import java.util.Arrays;
24 
28 
29 public class TopicDataImpl extends QosPolicyImpl implements TopicData {
30  private static final long serialVersionUID = 9077570108733402200L;
31  private final byte[] value;
32 
34  super(environment);
35  this.value = new byte[0];
36  }
37 
39  super(environment);
40 
41  if (value != null) {
42  this.value = value.clone();
43  } else {
44  this.value = new byte[0];
45  }
46  }
47 
48  @Override
49  public byte[] getValue() {
50  return this.value.clone();
51  }
52 
53  @Override
54  public TopicData withValue(byte[] value, int offset, int length) {
55  return new TopicDataImpl(this.environment, value);
56  }
57 
58  @Override
59  public Class<? extends QosPolicy> getPolicyClass() {
60  return TopicData.class;
61  }
62 
63  @Override
64  public boolean equals(Object other) {
65  if (!(other instanceof TopicDataImpl)) {
66  return false;
67  }
68  return Arrays.equals(this.value, ((TopicDataImpl) other).value);
69  }
70 
71  @Override
72  public int hashCode() {
73  final int prime = 31;
74  int result = 17;
75 
76  for (byte b : this.value) {
77  result = prime * result + b;
78  }
79  return result;
80  }
81 }
TopicDataImpl(OsplServiceEnvironment environment)
Class<? extends QosPolicy > getPolicyClass()
TopicDataImpl(OsplServiceEnvironment environment, byte[] value)
This class is the abstract root for all the QoS policies.
Definition: QosPolicy.java:118
byte [] getValue()
Get a copy of the data.
TopicData withValue(byte[] value, int offset, int length)
User data not known by the middleware, but distributed by means of built-in topics.
Definition: TopicData.java:42