ConfigurationEvent.java

  1. /**
  2.  *
  3.  * Copyright the original author or authors
  4.  *
  5.  * Licensed under the Apache License, Version 2.0 (the "License");
  6.  * you may not use this file except in compliance with the License.
  7.  * You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.jivesoftware.smackx.pubsub;

  18. import java.util.Arrays;
  19. import java.util.Collections;
  20. import java.util.List;

  21. import org.jivesoftware.smack.packet.ExtensionElement;

  22. /**
  23.  * Represents the <b>configuration</b> element of a pubsub message event which
  24.  * associates a configuration form to the node which was configured.  The form
  25.  * contains the current node configuration.
  26.  *  
  27.  * @author Robin Collier
  28.  */
  29. public class ConfigurationEvent extends NodeExtension implements EmbeddedPacketExtension
  30. {
  31.     private ConfigureForm form;
  32.    
  33.     public ConfigurationEvent(String nodeId)
  34.     {
  35.         super(PubSubElementType.CONFIGURATION, nodeId);
  36.     }
  37.    
  38.     public ConfigurationEvent(String nodeId, ConfigureForm configForm)
  39.     {
  40.         super(PubSubElementType.CONFIGURATION, nodeId);
  41.         form = configForm;
  42.     }
  43.    
  44.     public ConfigureForm getConfiguration()
  45.     {
  46.         return form;
  47.     }

  48.     public List<ExtensionElement> getExtensions()
  49.     {
  50.         if (getConfiguration() == null)
  51.             return Collections.emptyList();
  52.         else
  53.             return Arrays.asList(((ExtensionElement)getConfiguration().getDataFormToSend()));
  54.     }
  55. }