All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jivesoftware.smackx.pubsub.AffiliationsExtension Maven / Gradle / Ivy

Go to download

Smack extensions. Classes and methods that implement support for the various XMPP XEPs (Multi-User Chat, PubSub, …) and other XMPP extensions.

There is a newer version: 4.5.0-beta5
Show newest version
/**
 *
 * Copyright the original author or authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jivesoftware.smackx.pubsub;

import java.util.Collections;
import java.util.List;

import org.jivesoftware.smack.util.XmlStringBuilder;

import org.jivesoftware.smackx.pubsub.Affiliation.AffiliationNamespace;

/**
 * Represents the affiliations element of the reply to a request for affiliations.
 * It is defined in the specification in section 5.7 Retrieve Affiliations and
 * 8.9 Manage Affiliations.
 *
 * @author Robin Collier
 */
public class AffiliationsExtension extends NodeExtension {
    protected List items = Collections.emptyList();

    public AffiliationsExtension() {
        this(null);
    }

    public AffiliationsExtension(List subList) {
        this(subList, null);
    }

    public AffiliationsExtension(AffiliationNamespace affiliationsNamespace, List subList) {
        this(affiliationsNamespace, subList, null);
    }

    public AffiliationsExtension(List subList, String node) {
        this(AffiliationNamespace.basic, subList, node);
    }

    public AffiliationsExtension(AffiliationNamespace affiliationsNamespace, List subList, String node) {
        super(affiliationsNamespace.type, node);
        items = subList;
    }

    public List getAffiliations() {
        return items;
    }

    @Override
    protected void addXml(XmlStringBuilder xml) {
        if ((items == null) || (items.size() == 0)) {
            xml.closeEmptyElement();
            return;
        }

        xml.rightAngleBracket();
        xml.append(items);
        xml.closeElement(this);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy