Data type code generation is exactly the same, regardless of whether you are using RTSJ. You may find the publishing and subscribing example code more interesting:
package com.rti.ndds.rtsj.example.nodestatus;
import com.rti.dds.cdr.CdrHelper;
import com.rti.dds.infrastructure.Copyable;
public class NodeStatus implements Copyable {
public int id;
public int subsystemId;
public int statusId;
public NodeStatus() {
}
public NodeStatus(NodeStatus other) {
this();
copy_from(other);
}
public static Object create() {
return new NodeStatus();
}
public boolean equals(Object o) {
if(getClass() != o.getClass()) {
return false;
}
NodeStatus otherObj = (NodeStatus)o;
if(id != otherObj.id) {
return false;
}
if(subsystemId != otherObj.subsystemId) {
return false;
}
if(statusId != otherObj.statusId) {
return false;
}
return true;
}
public Object copy_from(Object src) {
NodeStatus typedSrc = (NodeStatus) src;
NodeStatus typedDst = this;
typedDst.id = typedSrc.id;
typedDst.subsystemId = typedSrc.subsystemId;
typedDst.statusId = typedSrc.statusId;
return this;
}
public String toString(){
return toString("", 0);
}
public String toString(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("id: ").append(id).append("\n");
CdrHelper.printIndent(strBuffer, indent+1);
strBuffer.append("subsystemId: ").append(subsystemId).append("\n");
CdrHelper.printIndent(strBuffer, indent+1);
strBuffer.append("statusId: ").append(statusId).append("\n");
return strBuffer.toString();
}
}