package ContentFilterTest; import java.util.ArrayList; import com.rti.dds.domain.DomainParticipant; import com.rti.dds.domain.DomainParticipantFactory; import com.rti.dds.infrastructure.StatusKind; import com.rti.dds.infrastructure.StringSeq; import com.rti.dds.subscription.Subscriber; import com.rti.dds.topic.ContentFilteredTopic; import com.rti.dds.topic.Topic; import com.rti.ndds.config.LogVerbosity; public class ContentFilterTopic { public static void main(String[] args) throws Exception { DomainParticipant participant = null; Topic topic = null; ContentFilteredTopic cft = null; Subscriber subscriber = null; //String filterExpression = "producer_id.userData = hex(%0)"; String filterExpression = "producer_id[0] = %0 and " + "producer_id[1] = %1 and " + "producer_id[2] = %2 and " + "producer_id[3] = %3 and " + "producer_id[4] = %4 and " + "producer_id[5] = %5 and " + "producer_id[6] = %6 and " + "producer_id[7] = %7 and " + "producer_id[8] = %8 and " + "producer_id[9] = %9 and " + "producer_id[10] = %10 and " + "producer_id[11] = %11 and " + "producer_id[12] = %12 and " + "producer_id[13] = %13 and " + "producer_id[14] = %14 and " + "producer_id[15] = %15"; ArrayList params = new ArrayList<>(); //params.add("01"); //params.add("02"); //params.add("01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10"); //params.add("0102030405060708090a0b0c0d0e0f10"); for (int i = 0; i < 16; i++) { params.add(String.format("'%02X'", (byte) i)); } StringSeq parameters = new StringSeq(params); com.rti.ndds.config.Logger.get_instance().set_verbosity(LogVerbosity.NDDS_CONFIG_LOG_VERBOSITY_ERROR); participant = DomainParticipantFactory.get_instance().create_participant(0, DomainParticipantFactory.PARTICIPANT_QOS_DEFAULT, null, StatusKind.STATUS_MASK_NONE); if (participant == null) { throw new Exception("Unable to create domain participant"); } subscriber = participant.create_subscriber(DomainParticipant.SUBSCRIBER_QOS_DEFAULT, null, StatusKind.STATUS_MASK_NONE); if (subscriber == null) { throw new Exception("Unable to create publisher"); } messageTypeSupport.register_type(participant, messageTypeSupport.get_type_name()); topic = participant.create_topic("messageTopic", messageTypeSupport.get_type_name(), DomainParticipant.TOPIC_QOS_DEFAULT, null, StatusKind.STATUS_MASK_NONE); if (topic == null) { throw new Exception("Unable to create topic"); } cft = participant.create_contentfilteredtopic("messageTopic" + "_FILTER", topic, filterExpression, parameters); if (cft == null) { throw new Exception("Unable to create confent filtered topic"); } } }