001/**
002 *
003 * Copyright the original author or authors
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.jivesoftware.smackx.pubsub;
018
019import java.util.Arrays;
020import java.util.Collections;
021import java.util.List;
022
023import org.jivesoftware.smack.packet.ExtensionElement;
024
025/**
026 * Represents the <b>configuration</b> element of a PubSub message event which
027 * associates a configuration form to the node which was configured.  The form
028 * contains the current node configuration.
029 *
030 * @author Robin Collier
031 */
032public class ConfigurationEvent extends NodeExtension implements EmbeddedPacketExtension {
033    private ConfigureForm form;
034
035    public ConfigurationEvent(String nodeId) {
036        super(PubSubElementType.CONFIGURATION, nodeId);
037    }
038
039    public ConfigurationEvent(String nodeId, ConfigureForm configForm) {
040        super(PubSubElementType.CONFIGURATION, nodeId);
041        form = configForm;
042    }
043
044    public ConfigureForm getConfiguration() {
045        return form;
046    }
047
048    @Override
049    public List<ExtensionElement> getExtensions() {
050        if (getConfiguration() == null)
051            return Collections.emptyList();
052        else
053            return Arrays.asList(((ExtensionElement) getConfiguration().getDataFormToSend()));
054    }
055}