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.XmlElement;

  22. import org.jivesoftware.smackx.pubsub.form.FilledConfigureForm;

  23. /**
  24.  * Represents the <b>configuration</b> element of a PubSub message event which
  25.  * associates a configuration form to the node which was configured.  The form
  26.  * contains the current node configuration.
  27.  *
  28.  * @author Robin Collier
  29.  */
  30. public class ConfigurationEvent extends NodeExtension implements EmbeddedPacketExtension {
  31.     private final FilledConfigureForm form;

  32.     public ConfigurationEvent(String nodeId) {
  33.         this(nodeId, null);
  34.     }

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

  39.     public FilledConfigureForm getConfiguration() {
  40.         return form;
  41.     }

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