/** * All rights reserved. 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.List; import org.jivesoftware.smack.packet.PacketExtension; /** * This class is used to for multiple purposes. *
Please note, this class is used for internal purposes, and is not required for usage of * pubsub functionality. * * @author Robin Collier */ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExtension { protected ItemsElementType type; protected Boolean notify; protected List extends PacketExtension> items; public enum ItemsElementType { /** An items element, which has an optional max_items attribute when requesting items */ items(PubSubElementType.ITEMS, "max_items"), /** A retract element, which has an optional notify attribute when publishing deletions */ retract(PubSubElementType.RETRACT, "notify"); private PubSubElementType elem; private String att; private ItemsElementType(PubSubElementType nodeElement, String attribute) { elem = nodeElement; att = attribute; } public PubSubElementType getNodeElement() { return elem; } public String getElementAttribute() { return att; } } /** * Construct an instance with a list representing items that have been published or deleted. * *
Valid scenarios are: *
null
* null
*
* @param itemsType Type of representation
* @param nodeId The node to which the items are being sent or deleted
* @param items The list of {@link Item} or {@link RetractItem}
* @param attributeValue The value of the max_items
*/
public ItemsExtension(ItemsElementType itemsType, String nodeId, List extends PacketExtension> items)
{
super(itemsType.getNodeElement(), nodeId);
type = itemsType;
this.items = items;
}
/**
* Construct an instance with a list representing items that have been published or deleted.
*
* Valid scenarios are: *
null
* null
*
* @param itemsType Type of representation
* @param nodeId The node to which the items are being sent or deleted
* @param items The list of {@link Item} or {@link RetractItem}
* @param attributeValue The value of the max_items
*/
public ItemsExtension(String nodeId, List extends PacketExtension> items, boolean notify)
{
super(ItemsElementType.retract.getNodeElement(), nodeId);
type = ItemsElementType.retract;
this.items = items;
this.notify = notify;
}
/**
* Get the type of element
*
* @return The element type
*/
public ItemsElementType getItemsElementType()
{
return type;
}
public List