RTI Connext CORBA Compatibility Kit  Version 6.0.1
 All Groups Pages
DateTimeTypeSupport.java

[$(NDDSHOME)/example/JAVA/corba/DateTimeTypeSupport.java]

/*
WARNING: THIS FILE IS AUTO-GENERATED. DO NOT MODIFY.
This file was generated from .idl using "rtiddsgen".
The rtiddsgen tool is part of the RTI Connext distribution.
For more information, type 'rtiddsgen -help' at a command shell
or consult the RTI Connext user manual.
*/
import com.rti.dds.cdr.CdrEncapsulation;
import com.rti.dds.cdr.CdrInputStream;
import com.rti.dds.cdr.CdrOutputStream;
import com.rti.dds.cdr.CdrPrimitiveType;
import com.rti.dds.cdr.CdrBuffer;
import com.rti.dds.cdr.CdrHelper;
import com.rti.dds.domain.DomainParticipant;
import com.rti.dds.publication.DataWriter;
import com.rti.dds.publication.DataWriterListener;
import com.rti.dds.subscription.DataReader;
import com.rti.dds.subscription.DataReaderListener;
import com.rti.dds.topic.KeyHash_t;
import com.rti.dds.topic.TypeSupportImpl;
import com.rti.dds.topic.TypeSupportType;
import com.rti.dds.util.Sequence;
import com.rti.dds.topic.DefaultEndpointData;
import com.rti.dds.infrastructure.RETCODE_ERROR;
import com.rti.dds.topic.TypeSupportParticipantInfo;
import com.rti.dds.topic.TypeSupportEndpointInfo;
import com.rti.dds.typecode.TypeCode;
public final class DateTimeTypeSupport extends TypeSupportImpl {
// -----------------------------------------------------------------------
// Private Fields
// -----------------------------------------------------------------------
private static final String TYPE_NAME = "DateTime";
private static final char[] PLUGIN_VERSION = {2, 0, 0, 0};
private static final DateTimeTypeSupport _singleton
= new DateTimeTypeSupport();
// -----------------------------------------------------------------------
// Public Methods
// -----------------------------------------------------------------------
// --- External methods: -------------------------------------------------
/* The methods in this section are for use by users of RTI Connext.
*/
public static String get_type_name() {
return _singleton.get_type_nameI();
}
public static void register_type(DomainParticipant participant,
String type_name) {
_singleton.register_typeI(participant, type_name);
}
public static void unregister_type(DomainParticipant participant,
String type_name) {
_singleton.unregister_typeI(participant, type_name);
}
/* The methods in this section are for use by RTI Connext
* itself and by the code generated by rtiddsgen for other types.
* They should be used directly or modified only by advanced users and are
* subject to change in future versions of RTI Connext.
*/
public static DateTimeTypeSupport get_instance() {
return _singleton;
}
/* deprecated API */
public static DateTimeTypeSupport getInstance() {
return get_instance();
}
public Object create_data() {
DateTime instance = new DateTime();
return instance;
}
public void destroy_data(Object data) {
return;
}
public Object create_key() {
DateTime instance = new DateTime();
return instance;
}
public void destroy_key(Object key) {
return;
}
public Class get_type() {
return DateTime.class;
}
public Object copy_data(Object destination, Object source) {
DateTime typedDst = (DateTime) destination;
DateTime typedSrc = (DateTime) source;
typedDst.year = typedSrc.year;
typedDst.month = typedSrc.month;
typedDst.day = typedSrc.day;
typedDst.hour = typedSrc.hour;
typedDst.minute = typedSrc.minute;
typedDst.second = typedSrc.second;
return typedDst;
}
public boolean are_samples_equal(DateTime sample,
DateTime sample2) {
if(sample.year != sample2.year) {
return false;
}
if(sample.month != sample2.month) {
return false;
}
if(sample.day != sample2.day) {
return false;
}
if(sample.hour != sample2.hour) {
return false;
}
if(sample.minute != sample2.minute) {
return false;
}
if(sample.second != sample2.second) {
return false;
}
return true;
}
public String sample_toString(DateTime sample, String desc, int indent) {
StringBuffer strBuffer = new StringBuffer();
if (desc != null) {
CdrHelper.printIndent(strBuffer, indent);
strBuffer.append(desc).append(":\n");
}
CdrHelper.printIndent(strBuffer, indent+1);
strBuffer.append("year: ").append(sample.year).append("\n");
CdrHelper.printIndent(strBuffer, indent+1);
strBuffer.append("month: ").append(sample.month).append("\n");
CdrHelper.printIndent(strBuffer, indent+1);
strBuffer.append("day: ").append(sample.day).append("\n");
CdrHelper.printIndent(strBuffer, indent+1);
strBuffer.append("hour: ").append(sample.hour).append("\n");
CdrHelper.printIndent(strBuffer, indent+1);
strBuffer.append("minute: ").append(sample.minute).append("\n");
CdrHelper.printIndent(strBuffer, indent+1);
strBuffer.append("second: ").append(sample.second).append("\n");
return strBuffer.toString();
}
public long get_serialized_sample_max_size(Object endpoint_data,boolean include_encapsulation, short encapsulation_id, long current_alignment) {
CdrPrimitiveType _cdrPrimitiveType = CdrPrimitiveType.getInstance(encapsulation_id);
long encapsulation_size = current_alignment;
long origAlignment = current_alignment;
if(include_encapsulation) {
if (!CdrEncapsulation.isValidEncapsulationKind(encapsulation_id)) {
throw new RETCODE_ERROR("Unsupported encapsulation");
}
encapsulation_size += _cdrPrimitiveType.getShortMaxSizeSerialized(encapsulation_size);
encapsulation_size += _cdrPrimitiveType.getShortMaxSizeSerialized(encapsulation_size);
encapsulation_size -= current_alignment;
current_alignment = 0;
origAlignment = 0;
}
current_alignment += _cdrPrimitiveType.getIntMaxSizeSerialized(current_alignment);
current_alignment += _cdrPrimitiveType.getIntMaxSizeSerialized(current_alignment);
current_alignment += _cdrPrimitiveType.getIntMaxSizeSerialized(current_alignment);
current_alignment += _cdrPrimitiveType.getIntMaxSizeSerialized(current_alignment);
current_alignment += _cdrPrimitiveType.getIntMaxSizeSerialized(current_alignment);
current_alignment += _cdrPrimitiveType.getIntMaxSizeSerialized(current_alignment);
if (include_encapsulation) {
current_alignment += encapsulation_size;
}
if ((current_alignment - origAlignment) == 0) {
return 1;
} else {
return current_alignment - origAlignment;
}
}
public long get_serialized_sample_min_size(Object endpoint_data,boolean include_encapsulation,short encapsulation_id,long current_alignment) {
CdrPrimitiveType _cdrPrimitiveType = CdrPrimitiveType.getInstance(encapsulation_id);
long encapsulation_size = current_alignment;
long origAlignment = current_alignment;
if(include_encapsulation) {
if (!CdrEncapsulation.isValidEncapsulationKind(encapsulation_id)) {
throw new RETCODE_ERROR("Unsupported encapsulation");
}
encapsulation_size += _cdrPrimitiveType.getShortMaxSizeSerialized(encapsulation_size);
encapsulation_size += _cdrPrimitiveType.getShortMaxSizeSerialized(encapsulation_size);
encapsulation_size -= current_alignment;
current_alignment = 0;
origAlignment = 0;
}
current_alignment += _cdrPrimitiveType.getIntMaxSizeSerialized(current_alignment);
current_alignment += _cdrPrimitiveType.getIntMaxSizeSerialized(current_alignment);
current_alignment += _cdrPrimitiveType.getIntMaxSizeSerialized(current_alignment);
current_alignment += _cdrPrimitiveType.getIntMaxSizeSerialized(current_alignment);
current_alignment += _cdrPrimitiveType.getIntMaxSizeSerialized(current_alignment);
current_alignment += _cdrPrimitiveType.getIntMaxSizeSerialized(current_alignment);
if (include_encapsulation) {
current_alignment += encapsulation_size;
}
if ((current_alignment - origAlignment) == 0) {
return 1;
} else {
return current_alignment - origAlignment;
}
}
public long get_serialized_sample_size(
Object endpoint_data, boolean include_encapsulation,
short encapsulation_id, int current_alignment,
Object sample)
{
CdrPrimitiveType _cdrPrimitiveType = CdrPrimitiveType.getInstance(encapsulation_id);
long origAlignment = current_alignment;
long encapsulation_size = current_alignment;
DateTime typedSrc = (DateTime) sample;
if(include_encapsulation) {
if (!CdrEncapsulation.isValidEncapsulationKind(encapsulation_id)) {
throw new RETCODE_ERROR("Unsupported encapsulation");
}
encapsulation_size += _cdrPrimitiveType.getShortMaxSizeSerialized(encapsulation_size);
encapsulation_size += _cdrPrimitiveType.getShortMaxSizeSerialized(encapsulation_size);
encapsulation_size -= current_alignment;
current_alignment = 0;
origAlignment = 0;
}
current_alignment += _cdrPrimitiveType.getIntMaxSizeSerialized(current_alignment);
current_alignment += _cdrPrimitiveType.getIntMaxSizeSerialized(current_alignment);
current_alignment += _cdrPrimitiveType.getIntMaxSizeSerialized(current_alignment);
current_alignment += _cdrPrimitiveType.getIntMaxSizeSerialized(current_alignment);
current_alignment += _cdrPrimitiveType.getIntMaxSizeSerialized(current_alignment);
current_alignment += _cdrPrimitiveType.getIntMaxSizeSerialized(current_alignment);
if (include_encapsulation) {
current_alignment += encapsulation_size;
}
return current_alignment - origAlignment;
}
public long get_serialized_key_max_size(
Object endpoint_data,
boolean include_encapsulation,
short encapsulation_id,
long current_alignment)
{
CdrPrimitiveType _cdrPrimitiveType = CdrPrimitiveType.getInstance(encapsulation_id);
long encapsulation_size = current_alignment;
long origAlignment = current_alignment;
if(include_encapsulation) {
if (!CdrEncapsulation.isValidEncapsulationKind(encapsulation_id)) {
throw new RETCODE_ERROR("Unsupported encapsulation");
}
encapsulation_size += _cdrPrimitiveType.getShortMaxSizeSerialized(encapsulation_size);
encapsulation_size += _cdrPrimitiveType.getShortMaxSizeSerialized(encapsulation_size);
encapsulation_size -= current_alignment;
current_alignment = 0;
origAlignment = 0;
}
current_alignment += get_serialized_sample_max_size(
endpoint_data,false,encapsulation_id,current_alignment);
if (include_encapsulation) {
current_alignment += encapsulation_size;
}
if ((current_alignment - origAlignment) == 0) {
return 1;
} else {
return current_alignment - origAlignment;
}
}
public void serialize(Object endpoint_data,Object src,CdrOutputStream dst,
boolean serialize_encapsulation, short encapsulation_id,
boolean serialize_sample, Object endpoint_plugin_qos) {
int position = 0;
DateTime typedSrc = (DateTime) src;
if(serialize_encapsulation) {
dst.serializeAndSetCdrEncapsulation(encapsulation_id);
position = dst.resetAlignment();
}
if(serialize_sample) {
dst.writeInt(typedSrc.year);
dst.writeInt(typedSrc.month);
dst.writeInt(typedSrc.day);
dst.writeInt(typedSrc.hour);
dst.writeInt(typedSrc.minute);
dst.writeInt(typedSrc.second);
}
if (serialize_encapsulation) {
dst.restoreAlignment(position);
}
}
public void serialize_key(
Object endpoint_data,
Object src,
CdrOutputStream dst,
boolean serialize_encapsulation,
short encapsulation_id,
boolean serialize_key,
Object endpoint_plugin_qos)
{
int position = 0;
if (serialize_encapsulation) {
dst.serializeAndSetCdrEncapsulation(encapsulation_id);
position = dst.resetAlignment();
}
if (serialize_key) {
DateTime typedSrc = (DateTime) src;
serialize(endpoint_data, src, dst, false, encapsulation_id,true, endpoint_plugin_qos);
}
if (serialize_encapsulation) {
dst.restoreAlignment(position);
}
}
public Object deserialize_sample(
Object endpoint_data,
Object dst,
CdrInputStream src,
boolean deserialize_encapsulation,
boolean deserialize_sample,
Object endpoint_plugin_qos)
{
int position = 0;
DateTime typedDst = (DateTime) dst;
if(deserialize_encapsulation) {
src.deserializeAndSetCdrEncapsulation();
position = src.resetAlignment();
}
if(deserialize_sample) {
typedDst.year = (int) src.readInt();
typedDst.month = (int) src.readInt();
typedDst.day = (int) src.readInt();
typedDst.hour = (int) src.readInt();
typedDst.minute = (int) src.readInt();
typedDst.second = (int) src.readInt();
}
if (deserialize_encapsulation) {
src.restoreAlignment(position);
}
return dst;
}
public Object deserialize_key_sample(
Object endpoint_data,
Object dst,
CdrInputStream src,
boolean deserialize_encapsulation,
boolean deserialize_key,
Object endpoint_plugin_qos)
{
int position = 0;
if(deserialize_encapsulation) {
src.deserializeAndSetCdrEncapsulation();
position = src.resetAlignment();
}
if(deserialize_key) {
DateTime typedDst = (DateTime) dst;
deserialize_sample(endpoint_data, dst, src, false, true, endpoint_plugin_qos);
}
if (deserialize_encapsulation) {
src.restoreAlignment(position);
}
return dst;
}
public void skip(Object endpoint_data,
CdrInputStream src,
boolean skip_encapsulation,
boolean skip_sample,
Object endpoint_plugin_qos)
{
int position = 0;
if (skip_encapsulation) {
src.skipEncapsulation();
position = src.resetAlignment();
}
if (skip_sample) {
src.skipInt();
src.skipInt();
src.skipInt();
src.skipInt();
src.skipInt();
src.skipInt();
}
if (skip_encapsulation) {
src.restoreAlignment(position);
}
}
public Object serialized_sample_to_key(
Object endpoint_data,
Object sample,
CdrInputStream src,
boolean deserialize_encapsulation,
boolean deserialize_key,
Object endpoint_plugin_qos) {
int position = 0;
if(deserialize_encapsulation) {
src.deserializeAndSetCdrEncapsulation();
position = src.resetAlignment();
}
if (deserialize_key) {
DateTime typedDst = (DateTime) sample;
deserialize_sample(
endpoint_data, sample, src, false,
true, endpoint_plugin_qos);
}
if (deserialize_encapsulation) {
src.restoreAlignment(position);
}
return sample;
}
// -----------------------------------------------------------------------
// Callbacks
// -----------------------------------------------------------------------
public Object on_participant_attached(Object registration_data,
TypeSupportParticipantInfo participant_info,
boolean top_level_registration,
Object container_plugin_context,
TypeCode type_code) {
return super.on_participant_attached(
registration_data, participant_info, top_level_registration,
container_plugin_context, type_code);
}
public void on_participant_detached(Object participant_data) {
super.on_participant_detached(participant_data);
}
public Object on_endpoint_attached(Object participantData,
TypeSupportEndpointInfo endpoint_info,
boolean top_level_registration,
Object container_plugin_context) {
return super.on_endpoint_attached(
participantData, endpoint_info,
top_level_registration, container_plugin_context);
}
public void on_endpoint_detached(Object endpoint_data) {
super.on_endpoint_detached(endpoint_data);
}
// -----------------------------------------------------------------------
// Protected Methods
// -----------------------------------------------------------------------
protected DataWriter create_datawriter(long native_writer,
DataWriterListener listener,
int mask) {
return null;
}
protected DataReader create_datareader(long native_reader,
DataReaderListener listener,
int mask) {
return null;
}
// -----------------------------------------------------------------------
// Constructor
// -----------------------------------------------------------------------
private DateTimeTypeSupport() {
/* If the user data type supports keys, then the second argument
to the constructor below should be true. Otherwise it should
be false. */
super(TYPE_NAME, false,DateTimeTypeCode.VALUE,DateTime.class,TypeSupportType.TST_STRUCT, PLUGIN_VERSION);
}
protected DateTimeTypeSupport(boolean enableKeySupport) {
super(TYPE_NAME, enableKeySupport,DateTimeTypeCode.VALUE,DateTime.class,TypeSupportType.TST_STRUCT, PLUGIN_VERSION);
}
}

RTI Connext CORBA Compatibility Kit Version 6.0.1 Copyright © Sun Nov 17 2019 Real-Time Innovations, Inc