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.     private ConfigureForm form;

  31.     public ConfigurationEvent(String nodeId) {
  32.         super(PubSubElementType.CONFIGURATION, nodeId);
  33.     }

  34.     public ConfigurationEvent(String nodeId, ConfigureForm configForm) {
  35.         super(PubSubElementType.CONFIGURATION, nodeId);
  36.         form = configForm;
  37.     }

  38.     public ConfigureForm getConfiguration() {
  39.         return form;
  40.     }

  41.     @Override
  42.     public List<ExtensionElement> getExtensions() {
  43.         if (getConfiguration() == null)
  44.             return Collections.emptyList();
  45.         else
  46.             return Arrays.asList(((ExtensionElement) getConfiguration().getDataFormToSend()));
  47.     }
  48. }