2014-02-17 23:58:40 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* 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;
|
|
|
|
|
2015-06-06 11:14:26 +02:00
|
|
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
|
|
|
|
2018-04-19 11:05:43 +02:00
|
|
|
import org.jivesoftware.smackx.pubsub.Affiliation.AffiliationNamespace;
|
|
|
|
|
2014-02-17 23:58:40 +01:00
|
|
|
/**
|
|
|
|
* Represents the <b>affiliations</b> element of the reply to a request for affiliations.
|
2015-06-06 11:14:26 +02:00
|
|
|
* It is defined in the specification in section <a href="http://xmpp.org/extensions/xep-0060.html#entity-affiliations">5.7 Retrieve Affiliations</a> and
|
|
|
|
* <a href="http://www.xmpp.org/extensions/xep-0060.html#owner-affiliations">8.9 Manage Affiliations</a>.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2014-02-17 23:58:40 +01:00
|
|
|
* @author Robin Collier
|
|
|
|
*/
|
2018-04-06 10:21:46 +02:00
|
|
|
public class AffiliationsExtension extends NodeExtension {
|
2017-02-07 22:02:40 +01:00
|
|
|
protected List<Affiliation> items = Collections.emptyList();
|
2015-03-17 11:33:02 +01:00
|
|
|
|
2015-06-06 11:14:26 +02:00
|
|
|
public AffiliationsExtension() {
|
2018-04-19 11:05:43 +02:00
|
|
|
this(null);
|
2015-06-06 11:14:26 +02:00
|
|
|
}
|
2015-03-17 11:33:02 +01:00
|
|
|
|
2015-06-06 11:14:26 +02:00
|
|
|
public AffiliationsExtension(List<Affiliation> subList) {
|
|
|
|
this(subList, null);
|
|
|
|
}
|
|
|
|
|
2018-04-19 11:05:43 +02:00
|
|
|
public AffiliationsExtension(AffiliationNamespace affiliationsNamespace, List<Affiliation> subList) {
|
|
|
|
this(affiliationsNamespace, subList, null);
|
|
|
|
}
|
|
|
|
|
2015-06-06 11:14:26 +02:00
|
|
|
public AffiliationsExtension(List<Affiliation> subList, String node) {
|
2018-04-19 11:05:43 +02:00
|
|
|
this(AffiliationNamespace.basic, subList, node);
|
|
|
|
}
|
|
|
|
|
|
|
|
public AffiliationsExtension(AffiliationNamespace affiliationsNamespace, List<Affiliation> subList, String node) {
|
2020-06-14 16:52:13 +02:00
|
|
|
super(affiliationsNamespace.type, node);
|
2015-06-06 11:14:26 +02:00
|
|
|
items = subList;
|
|
|
|
}
|
2014-02-17 23:58:40 +01:00
|
|
|
|
2018-04-06 10:21:46 +02:00
|
|
|
public List<Affiliation> getAffiliations() {
|
2017-02-07 22:02:40 +01:00
|
|
|
return items;
|
|
|
|
}
|
2014-02-17 23:58:40 +01:00
|
|
|
|
2017-02-07 22:02:40 +01:00
|
|
|
@Override
|
2020-06-14 16:52:13 +02:00
|
|
|
protected void addXml(XmlStringBuilder xml) {
|
2018-04-06 10:21:46 +02:00
|
|
|
if ((items == null) || (items.size() == 0)) {
|
2020-06-14 16:52:13 +02:00
|
|
|
xml.closeEmptyElement();
|
|
|
|
return;
|
2017-02-07 22:02:40 +01:00
|
|
|
}
|
2020-06-14 16:52:13 +02:00
|
|
|
|
|
|
|
xml.rightAngleBracket();
|
|
|
|
xml.append(items);
|
|
|
|
xml.closeElement(this);
|
2017-02-07 22:02:40 +01:00
|
|
|
}
|
2014-02-17 23:58:40 +01:00
|
|
|
}
|