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;
|
|
|
|
|
2014-09-21 20:49:11 +02:00
|
|
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
|
|
|
|
2014-02-17 23:58:40 +01:00
|
|
|
/**
|
|
|
|
* Represents a request to subscribe to a node.
|
|
|
|
*
|
|
|
|
* @author Robin Collier
|
|
|
|
*/
|
|
|
|
public class GetItemsRequest extends NodeExtension
|
|
|
|
{
|
2017-02-07 22:02:40 +01:00
|
|
|
protected final String subId;
|
|
|
|
protected final int maxItems;
|
2015-03-17 11:33:02 +01:00
|
|
|
|
2017-02-07 22:02:40 +01:00
|
|
|
public GetItemsRequest(String nodeId)
|
|
|
|
{
|
|
|
|
this(nodeId, null, -1);
|
|
|
|
}
|
2015-03-17 11:33:02 +01:00
|
|
|
|
2017-02-07 22:02:40 +01:00
|
|
|
public GetItemsRequest(String nodeId, String subscriptionId)
|
|
|
|
{
|
2014-09-21 20:49:11 +02:00
|
|
|
this(nodeId, subscriptionId, -1);
|
2017-02-07 22:02:40 +01:00
|
|
|
}
|
2014-02-17 23:58:40 +01:00
|
|
|
|
2017-02-07 22:02:40 +01:00
|
|
|
public GetItemsRequest(String nodeId, int maxItemsToReturn)
|
|
|
|
{
|
2014-09-21 20:49:11 +02:00
|
|
|
this(nodeId, null, maxItemsToReturn);
|
2017-02-07 22:02:40 +01:00
|
|
|
}
|
2014-02-17 23:58:40 +01:00
|
|
|
|
2017-02-07 22:02:40 +01:00
|
|
|
public GetItemsRequest(String nodeId, String subscriptionId, int maxItemsToReturn)
|
|
|
|
{
|
2014-09-21 20:49:11 +02:00
|
|
|
super(PubSubElementType.ITEMS, nodeId);
|
|
|
|
maxItems = maxItemsToReturn;
|
2017-02-07 22:02:40 +01:00
|
|
|
subId = subscriptionId;
|
|
|
|
}
|
2014-02-17 23:58:40 +01:00
|
|
|
|
2017-02-07 22:02:40 +01:00
|
|
|
public String getSubscriptionId()
|
|
|
|
{
|
|
|
|
return subId;
|
|
|
|
}
|
2014-02-17 23:58:40 +01:00
|
|
|
|
2017-02-07 22:02:40 +01:00
|
|
|
public int getMaxItems()
|
|
|
|
{
|
|
|
|
return maxItems;
|
|
|
|
}
|
2014-02-17 23:58:40 +01:00
|
|
|
|
2017-02-07 22:02:40 +01:00
|
|
|
@Override
|
2014-09-21 20:49:11 +02:00
|
|
|
public XmlStringBuilder toXML() {
|
|
|
|
XmlStringBuilder xml = new XmlStringBuilder();
|
|
|
|
xml.halfOpenElement(getElementName());
|
|
|
|
xml.attribute("node", getNode());
|
|
|
|
xml.optAttribute("subid", getSubscriptionId());
|
|
|
|
xml.optIntAttribute("max_items", getMaxItems());
|
|
|
|
xml.closeEmptyElement();
|
|
|
|
return xml;
|
|
|
|
}
|
2014-02-17 23:58:40 +01:00
|
|
|
}
|