示例#1
0
 public void setTopicSelectedByUser(String topicName) {
   if (getTopics() == null) throw new IllegalStateException();
   for (Topic topic : getTopics())
     if (topic.getTopicName().equals(topicName)) {
       setSelectedTopic(topic);
       break;
     }
 }
示例#2
0
 @Override
 protected int calculateRemainingLength() {
   int length = 2;
   for (Topic topic : topics) {
     length = length + 2 + topic.getTopicName().getBytes().length + 1;
   }
   return length;
 }
示例#3
0
 /**
  * @param currentUser
  * @param currentTopic
  */
 public TextConf(User currentUser, Topic currentTopic, TextConfObserver obs) {
   this.currentUser = currentUser;
   this.currentTopic = currentTopic;
   this.observer = obs;
   this.setLogging(Level.WARNING);
   UserConfiguration.setUserName(this.currentUser.getUserName());
   _namespaceStr = BASE_NAMESPACE + "/" + currentTopic.getTopicName();
   _userToDigestHash = new HashMap<PublisherPublicKeyDigest, User>();
   try {
     _namespace = ContentName.fromURI(_namespaceStr);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
示例#4
0
 @Override
 public void validate() {
   if (messageID < 0) {
     throw new IllegalStateException("Negative Message ID.");
   }
   if (topics == null || topics.size() == 0) {
     throw new IllegalStateException("Topics not provided.");
   }
   for (Topic topic : topics) {
     if (!MQTTUtils.isTopicWildcardValid(topic.getTopicName())) {
       throw new IllegalStateException("Topic Name not provided or format incorrect.");
     }
   }
 }