1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-12-08 14:11:07 +01:00

's;^\s+$;;' on all source files

And add checkstyle test for lines containing only whitespace characters.
This commit is contained in:
Florian Schmaus 2015-03-17 11:33:02 +01:00
parent 05c97c494b
commit 0fde39fa45
193 changed files with 1066 additions and 1062 deletions

View file

@ -32,8 +32,8 @@ import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
*/
public abstract class InBandBytestreamListener implements BytestreamListener {
public void incomingBytestreamRequest(BytestreamRequest request) {
incomingBytestreamRequest((InBandBytestreamRequest) request);
}

View file

@ -70,7 +70,7 @@ import org.jivesoftware.smack.SmackException;
*/
public class Socks5Proxy {
private static final Logger LOGGER = Logger.getLogger(Socks5Proxy.class.getName());
/* SOCKS5 proxy singleton */
private static Socks5Proxy socks5Server;

View file

@ -40,7 +40,7 @@ import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
*/
public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache {
private static final Logger LOGGER = Logger.getLogger(SimpleDirectoryPersistentCache.class.getName());
private File cacheDir;
private StringEncoder filenameEncoder;

View file

@ -119,9 +119,9 @@ public class AdHocCommandManager extends Manager {
* ID matches the sessionid attribute sent by command responders.
*/
private final Map<String, LocalCommand> executingCommands = new ConcurrentHashMap<String, LocalCommand>();
private final ServiceDiscoveryManager serviceDiscoveryManager;
/**
* Thread that reaps stale sessions.
*/

View file

@ -241,13 +241,13 @@ public class AdHocCommandData extends IQ {
public static class SpecificError implements ExtensionElement {
public static final String namespace = "http://jabber.org/protocol/commands";
public SpecificErrorCondition condition;
public SpecificError(SpecificErrorCondition condition) {
this.condition = condition;
}
public String getElementName() {
return condition.toString();
}
@ -258,7 +258,7 @@ public class AdHocCommandData extends IQ {
public SpecificErrorCondition getCondition() {
return condition;
}
public String toXML() {
StringBuilder buf = new StringBuilder();
buf.append("<").append(getElementName());

View file

@ -440,7 +440,7 @@ public class DiscoverInfo extends IQ implements TypedCloneable<DiscoverInfo> {
public int compareTo(DiscoverInfo.Identity other) {
String otherLang = other.lang == null ? "" : other.lang;
String thisLang = lang == null ? "" : lang;
// This can be removed once the deprecated constructor is removed.
String otherType = other.type == null ? "" : other.type;
String thisType = type == null ? "" : type;

View file

@ -47,7 +47,7 @@ public class JivePropertiesExtension implements ExtensionElement {
public static final String ELEMENT = "properties";
private static final Logger LOGGER = Logger.getLogger(JivePropertiesExtension.class.getName());
private final Map<String, Object> properties;
public JivePropertiesExtension() {

View file

@ -149,7 +149,7 @@ public class DiscussionHistory {
if (!isConfigured()) {
return null;
}
MUCInitialPresence.History mucHistory = new MUCInitialPresence.History();
if (maxChars > -1) {
mucHistory.setMaxChars(maxChars);

View file

@ -31,5 +31,5 @@ public interface InvitationRejectionListener {
* @param reason the reason why the invitee declined the invitation.
*/
public abstract void invitationDeclined(String invitee, String reason);
}

View file

@ -115,7 +115,7 @@ public class PEPManager {
PEPPubSub pubSub = new PEPPubSub(item);
pubSub.setType(Type.set);
//pubSub.setFrom(connection.getUser());
// Send the message that contains the roster
connection.sendStanza(pubSub);
}

View file

@ -48,7 +48,7 @@ public class PEPEvent implements ExtensionElement {
this.item = item;
}
public void addPEPItem(PEPItem item) {
this.item = item;
}

View file

@ -28,11 +28,11 @@ import org.jivesoftware.smack.packet.ExtensionElement;
* @author Jeff Williams
*/
public abstract class PEPItem implements ExtensionElement {
String id;
abstract String getNode();
abstract String getItemDetailsXML();
/**
* Creates a new PEPItem.
*
@ -41,7 +41,7 @@ public abstract class PEPItem implements ExtensionElement {
super();
this.id = id;
}
/**
* Returns the XML element name of the extension sub-packet root element.
* Always returns "x"

View file

@ -28,7 +28,7 @@ import org.jivesoftware.smack.packet.IQ;
* @author Jeff Williams
*/
public class PEPPubSub extends IQ {
public static final String ELEMENT = "pubsub";
public static final String NAMESPACE = "http://jabber.org/protocol/pubsub";

View file

@ -44,7 +44,7 @@ public class PrivacyList {
private final String listName;
/** Holds the list of {@link PrivacyItem} */
private final List<PrivacyItem> items;
protected PrivacyList(boolean isActiveList, boolean isDefaultList,
String listName, List<PrivacyItem> privacyItems) {
super();

View file

@ -264,7 +264,7 @@ public class PrivacyListManager extends Manager {
private Privacy getPrivacyWithListNames() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// The request of the list is an empty privacy message
Privacy request = new Privacy();
// Send the package to the server and get the answer
return getRequest(request);
}
@ -371,10 +371,10 @@ public class PrivacyListManager extends Manager {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setPrivacyList(listName, new ArrayList<PrivacyItem>());
// Send the package to the server and get the answer
Privacy privacyAnswer = getRequest(request);
return privacyAnswer.getPrivacyList(listName);
}
@ -427,7 +427,7 @@ public class PrivacyListManager extends Manager {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setActiveName(listName);
// Send the package to the server
setRequest(request);
}
@ -443,7 +443,7 @@ public class PrivacyListManager extends Manager {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setDeclineActiveList(true);
// Send the package to the server
setRequest(request);
}
@ -461,7 +461,7 @@ public class PrivacyListManager extends Manager {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setDefaultName(listName);
// Send the package to the server
setRequest(request);
}
@ -477,7 +477,7 @@ public class PrivacyListManager extends Manager {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setDeclineDefaultList(true);
// Send the package to the server
setRequest(request);
}

View file

@ -303,7 +303,7 @@ public class Privacy extends IQ {
buf.append("<default name=\"").escape(getDefaultName()).append("\"/>");
}
}
// Add the list with their privacy items
for (Map.Entry<String, List<PrivacyItem>> entry : this.getItemLists().entrySet()) {
String listName = entry.getKey();
@ -326,5 +326,5 @@ public class Privacy extends IQ {
return buf;
}
}

View file

@ -74,7 +74,7 @@ public class PrivacyProvider extends IQProvider<Privacy> {
return privacy;
}
// Parse the list complex type
private static void parseList(XmlPullParser parser, Privacy privacy) throws XmlPullParserException, IOException, SmackException {
boolean done = false;
@ -96,7 +96,7 @@ public class PrivacyProvider extends IQProvider<Privacy> {
privacy.setPrivacyList(listName, items);
}
// Parse the list complex type
private static PrivacyItem parseItem(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException {
// Retrieves the required attributes

View file

@ -29,13 +29,13 @@ public enum AccessModel
/** Subscription request must be approved and only subscribers may retrieve items */
authorize,
/** Anyone with a presence subscription of both or from may subscribe and retrieve items */
presence,
/** Anyone in the specified roster group(s) may subscribe and retrieve items */
roster,
/** Only those on a whitelist may subscribe and retrieve items */
whitelist;
}

View file

@ -33,7 +33,7 @@ public class Affiliation implements ExtensionElement
{
protected String node;
protected Type type;
public enum Type
{
member, none, outcast, owner, publisher
@ -50,17 +50,17 @@ public class Affiliation implements ExtensionElement
node = nodeId;
type = affiliation;
}
public String getNodeId()
{
return node;
}
public Type getType()
{
return type;
}
public String getElementName()
{
return "subscription";
@ -77,7 +77,7 @@ public class Affiliation implements ExtensionElement
builder.append(getElementName());
appendAttribute(builder, "node", node);
appendAttribute(builder, "affiliation", type.toString());
builder.append("/>");
return builder.toString();
}

View file

@ -28,12 +28,12 @@ import java.util.List;
public class AffiliationsExtension extends NodeExtension
{
protected List<Affiliation> items = Collections.emptyList();
public AffiliationsExtension()
{
super(PubSubElementType.AFFILIATIONS);
}
public AffiliationsExtension(List<Affiliation> subList)
{
super(PubSubElementType.AFFILIATIONS);
@ -57,12 +57,12 @@ public class AffiliationsExtension extends NodeExtension
StringBuilder builder = new StringBuilder("<");
builder.append(getElementName());
builder.append(">");
for (Affiliation item : items)
{
builder.append(item.toXML());
}
builder.append("</");
builder.append(getElementName());
builder.append(">");

View file

@ -26,10 +26,10 @@ public enum ChildrenAssociationPolicy
{
/** Anyone may associate leaf nodes with the collection */
all,
/** Only collection node owners may associate leaf nodes with the collection. */
owners,
/** Only those on a whitelist may associate leaf nodes with the collection. */
whitelist;
}

View file

@ -32,18 +32,18 @@ import org.jivesoftware.smack.packet.ExtensionElement;
public class ConfigurationEvent extends NodeExtension implements EmbeddedPacketExtension
{
private ConfigureForm form;
public ConfigurationEvent(String nodeId)
{
super(PubSubElementType.CONFIGURATION, nodeId);
}
public ConfigurationEvent(String nodeId, ConfigureForm configForm)
{
super(PubSubElementType.CONFIGURATION, nodeId);
form = configForm;
}
public ConfigureForm getConfiguration()
{
return form;

View file

@ -45,7 +45,7 @@ public class ConfigureForm extends Form
{
super(configDataForm);
}
/**
* Create a decorator from an existing {@link Form} for node configuration.
* Typically, this can be used to create a decorator for an answer form
@ -57,7 +57,7 @@ public class ConfigureForm extends Form
{
super(nodeConfigForm.getDataFormToSend());
}
/**
* Create a new form for configuring a node. This would typically only be used
* when creating and configuring a node at the same time via {@link PubSubManager#createNode(String, Form)}, since
@ -69,7 +69,7 @@ public class ConfigureForm extends Form
{
super(formType);
}
/**
* Get the currently configured {@link AccessModel}, null if it is not set.
*
@ -78,13 +78,13 @@ public class ConfigureForm extends Form
public AccessModel getAccessModel()
{
String value = getFieldValue(ConfigureNodeFields.access_model);
if (value == null)
return null;
else
return AccessModel.valueOf(value);
}
/**
* Sets the value of access model.
*
@ -118,7 +118,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.body_xslt, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.body_xslt.getFieldName(), bodyXslt);
}
/**
* The id's of the child nodes associated with a collection node (both leaf and collection).
*
@ -128,7 +128,7 @@ public class ConfigureForm extends Form
{
return getFieldValues(ConfigureNodeFields.children);
}
/**
* Set the list of child node ids that are associated with a collection node.
*
@ -139,7 +139,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.children, FormField.Type.text_multi);
setAnswer(ConfigureNodeFields.children.getFieldName(), children);
}
/**
* Returns the policy that determines who may associate children with the node.
*
@ -148,13 +148,13 @@ public class ConfigureForm extends Form
public ChildrenAssociationPolicy getChildrenAssociationPolicy()
{
String value = getFieldValue(ConfigureNodeFields.children_association_policy);
if (value == null)
return null;
else
return ChildrenAssociationPolicy.valueOf(value);
}
/**
* Sets the policy that determines who may associate children with the node.
*
@ -167,7 +167,7 @@ public class ConfigureForm extends Form
values.add(policy.toString());
setAnswer(ConfigureNodeFields.children_association_policy.getFieldName(), values);
}
/**
* List of JID's that are on the whitelist that determines who can associate child nodes
* with the collection node. This is only relevant if {@link #getChildrenAssociationPolicy()} is set to
@ -179,7 +179,7 @@ public class ConfigureForm extends Form
{
return getFieldValues(ConfigureNodeFields.children_association_whitelist);
}
/**
* Set the JID's in the whitelist of users that can associate child nodes with the collection
* node. This is only relevant if {@link #getChildrenAssociationPolicy()} is set to
@ -269,7 +269,7 @@ public class ConfigureForm extends Form
{
return parseBoolean(getFieldValue(ConfigureNodeFields.deliver_payloads));
}
/**
* Sets whether the node will deliver payloads with event notifications.
*
@ -289,7 +289,7 @@ public class ConfigureForm extends Form
public ItemReply getItemReply()
{
String value = getFieldValue(ConfigureNodeFields.itemreply);
if (value == null)
return null;
else
@ -329,7 +329,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.max_items, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.max_items.getFieldName(), max);
}
/**
* Gets the maximum payload size in bytes.
*
@ -350,7 +350,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.max_payload_size, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.max_payload_size.getFieldName(), max);
}
/**
* Gets the node type
*
@ -359,13 +359,13 @@ public class ConfigureForm extends Form
public NodeType getNodeType()
{
String value = getFieldValue(ConfigureNodeFields.node_type);
if (value == null)
return null;
else
return NodeType.valueOf(value);
}
/**
* Sets the node type
*
@ -386,7 +386,7 @@ public class ConfigureForm extends Form
{
return parseBoolean(getFieldValue(ConfigureNodeFields.notify_config));
}
/**
* Sets whether subscribers should be notified when the configuration changes.
*
@ -407,7 +407,7 @@ public class ConfigureForm extends Form
{
return parseBoolean(getFieldValue(ConfigureNodeFields.notify_delete));
}
/**
* Sets whether subscribers should be notified when the node is deleted.
*
@ -429,7 +429,7 @@ public class ConfigureForm extends Form
{
return parseBoolean(getFieldValue(ConfigureNodeFields.notify_retract));
}
/**
* Sets whether subscribers should be notified when items are deleted
* from the node.
@ -441,7 +441,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.notify_retract, FormField.Type.bool);
setAnswer(ConfigureNodeFields.notify_retract.getFieldName(), notify);
}
/**
* Determines whether items should be persisted in the node.
*
@ -451,7 +451,7 @@ public class ConfigureForm extends Form
{
return parseBoolean(getFieldValue(ConfigureNodeFields.persist_items));
}
/**
* Sets whether items should be persisted in the node.
*
@ -472,7 +472,7 @@ public class ConfigureForm extends Form
{
return parseBoolean(getFieldValue(ConfigureNodeFields.presence_based_delivery));
}
/**
* Sets whether to deliver notifications to available users only.
*
@ -492,7 +492,7 @@ public class ConfigureForm extends Form
public PublishModel getPublishModel()
{
String value = getFieldValue(ConfigureNodeFields.publish_model);
if (value == null)
return null;
else
@ -509,7 +509,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.publish_model, FormField.Type.list_single);
setAnswer(ConfigureNodeFields.publish_model.getFieldName(), getListSingle(publish.toString()));
}
/**
* List of the multi user chat rooms that are specified as reply rooms.
*
@ -519,7 +519,7 @@ public class ConfigureForm extends Form
{
return getFieldValues(ConfigureNodeFields.replyroom);
}
/**
* Sets the multi user chat rooms that are specified as reply rooms.
*
@ -530,7 +530,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.replyroom, FormField.Type.list_multi);
setAnswer(ConfigureNodeFields.replyroom.getFieldName(), replyRooms);
}
/**
* Gets the specific JID's for reply to.
*
@ -540,7 +540,7 @@ public class ConfigureForm extends Form
{
return getFieldValues(ConfigureNodeFields.replyto);
}
/**
* Sets the specific JID's for reply to.
*
@ -551,7 +551,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.replyto, FormField.Type.list_multi);
setAnswer(ConfigureNodeFields.replyto.getFieldName(), replyTos);
}
/**
* Gets the roster groups that are allowed to subscribe and retrieve items.
*
@ -561,7 +561,7 @@ public class ConfigureForm extends Form
{
return getFieldValues(ConfigureNodeFields.roster_groups_allowed);
}
/**
* Sets the roster groups that are allowed to subscribe and retrieve items.
*
@ -572,7 +572,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.roster_groups_allowed, FormField.Type.list_multi);
setAnswer(ConfigureNodeFields.roster_groups_allowed.getFieldName(), groups);
}
/**
* Determines if subscriptions are allowed.
*
@ -604,7 +604,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.subscribe, FormField.Type.bool);
setAnswer(ConfigureNodeFields.subscribe.getFieldName(), subscribe);
}
/**
* Gets the human readable node title.
*
@ -625,7 +625,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.title, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.title.getFieldName(), title);
}
/**
* The type of node data, usually specified by the namespace of the payload (if any).
*
@ -646,27 +646,27 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.type, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.type.getFieldName(), type);
}
@Override
public String toString()
{
StringBuilder result = new StringBuilder(getClass().getName() + " Content [");
for (FormField formField : getFields())
{
result.append('(');
result.append(formField.getVariable());
result.append(':');
StringBuilder valuesBuilder = new StringBuilder();
for (String value : formField.getValues())
{
if (valuesBuilder.length() > 0)
result.append(',');
valuesBuilder.append(value);
}
if (valuesBuilder.length() == 0)
valuesBuilder.append("NOT SET");
result.append(valuesBuilder);
@ -684,21 +684,21 @@ public class ConfigureForm extends Form
private String getFieldValue(ConfigureNodeFields field)
{
FormField formField = getField(field.getFieldName());
return (formField.getValues().isEmpty()) ? null : formField.getValues().get(0);
}
private List<String> getFieldValues(ConfigureNodeFields field)
{
FormField formField = getField(field.getFieldName());
return formField.getValues();
}
private void addField(ConfigureNodeFields nodeField, FormField.Type type)
{
String fieldName = nodeField.getFieldName();
if (getField(fieldName) == null)
{
FormField field = new FormField(fieldName);

View file

@ -44,7 +44,7 @@ public enum ConfigureNodeFields
* <p><b>Value: {@link URL}</b></p>
*/
body_xslt,
/**
* The collection with which a node is affiliated
*
@ -68,21 +68,21 @@ public enum ConfigureNodeFields
* <p><b>Value: boolean</b></p>
*/
deliver_payloads,
/**
* Whether owners or publisher should receive replies to items
*
* <p><b>Value: {@link ItemReply}</b></p>
*/
itemreply,
/**
* Who may associate leaf nodes with a collection
*
* <p><b>Value: {@link ChildrenAssociationPolicy}</b></p>
*/
children_association_policy,
/**
* The list of JIDs that may associate leaf nodes with a
* collection
@ -90,14 +90,14 @@ public enum ConfigureNodeFields
* <p><b>Value: List of JIDs as Strings</b></p>
*/
children_association_whitelist,
/**
* The child nodes (leaf or collection) associated with a collection
*
* <p><b>Value: List of Strings</b></p>
*/
children,
/**
* The maximum number of child nodes that can be associated with a
* collection
@ -105,35 +105,35 @@ public enum ConfigureNodeFields
* <p><b>Value: int</b></p>
*/
children_max,
/**
* The maximum number of items to persist
*
* <p><b>Value: int</b></p>
*/
max_items,
/**
* The maximum payload size in bytes
*
* <p><b>Value: int</b></p>
*/
max_payload_size,
/**
* Whether the node is a leaf (default) or collection
*
* <p><b>Value: {@link NodeType}</b></p>
*/
node_type,
/**
* Whether to notify subscribers when the node configuration changes
*
* <p><b>Value: boolean</b></p>
*/
notify_config,
/**
* Whether to notify subscribers when the node is deleted
*
@ -147,7 +147,7 @@ public enum ConfigureNodeFields
* <p><b>Value: boolean</b></p>
*/
notify_retract,
/**
* Whether to persist items to storage. This is required to have multiple
* items in the node.
@ -155,7 +155,7 @@ public enum ConfigureNodeFields
* <p><b>Value: boolean</b></p>
*/
persist_items,
/**
* Whether to deliver notifications to available users only
*
@ -169,42 +169,42 @@ public enum ConfigureNodeFields
* <p><b>Value: {@link PublishModel}</b></p>
*/
publish_model,
/**
* The specific multi-user chat rooms to specify for replyroom
*
* <p><b>Value: List of JIDs as Strings</b></p>
*/
replyroom,
/**
* The specific JID(s) to specify for replyto
*
* <p><b>Value: List of JIDs as Strings</b></p>
*/
replyto,
/**
* The roster group(s) allowed to subscribe and retrieve items
*
* <p><b>Value: List of strings</b></p>
*/
roster_groups_allowed,
/**
* Whether to allow subscriptions
*
* <p><b>Value: boolean</b></p>
*/
subscribe,
/**
* A friendly name for the node
*
* <p><b>Value: String</b></p>
*/
title,
/**
* The type of node data, ussually specified by the namespace
* of the payload(if any);MAY be a list-single rather than a
@ -213,7 +213,7 @@ public enum ConfigureNodeFields
* <p><b>Value: String</b></p>
*/
type;
public String getFieldName()
{
return "pubsub#" + toString();

View file

@ -34,13 +34,13 @@ public class EventElement implements EmbeddedPacketExtension
{
private EventElementType type;
private NodeExtension ext;
public EventElement(EventElementType eventType, NodeExtension eventExt)
{
type = eventType;
ext = eventExt;
}
public EventElementType getEventType()
{
return type;

View file

@ -29,16 +29,16 @@ public enum EventElementType
/** A node has had its configuration changed */
configuration,
/** A node has been deleted */
delete,
/** Items have been published to a node */
items,
/** All items have been purged from a node */
purge,
/** A node has been subscribed to */
subscription
}

View file

@ -29,7 +29,7 @@ import org.jivesoftware.smackx.xdata.Form;
public class FormNode extends NodeExtension
{
private Form configForm;
/**
* Create a {@link FormNode} which contains the specified form.
*
@ -44,7 +44,7 @@ public class FormNode extends NodeExtension
throw new IllegalArgumentException("Submit form cannot be null");
configForm = submitForm;
}
/**
* Create a {@link FormNode} which contains the specified form, which is
* associated with the specified node.
@ -61,7 +61,7 @@ public class FormNode extends NodeExtension
throw new IllegalArgumentException("Submit form cannot be null");
configForm = submitForm;
}
/**
* Get the Form that is to be sent, or was retrieved from the server.
*
@ -71,7 +71,7 @@ public class FormNode extends NodeExtension
{
return configForm;
}
@Override
public CharSequence toXML()
{
@ -83,7 +83,7 @@ public class FormNode extends NodeExtension
{
StringBuilder builder = new StringBuilder("<");
builder.append(getElementName());
if (getNode() != null)
{
builder.append(" node='");

View file

@ -29,16 +29,16 @@ public enum FormNodeType
{
/** Form for configuring an existing node */
CONFIGURE_OWNER,
/** Form for configuring a node during creation */
CONFIGURE,
/** Form for configuring subscription options */
OPTIONS,
/** Form which represents the default node configuration options */
DEFAULT;
public PubSubElementType getNodeElement()
{
return PubSubElementType.valueOf(toString());

View file

@ -27,12 +27,12 @@ public class GetItemsRequest extends NodeExtension
{
protected final String subId;
protected final int maxItems;
public GetItemsRequest(String nodeId)
{
this(nodeId, null, -1);
}
public GetItemsRequest(String nodeId, String subscriptionId)
{
this(nodeId, subscriptionId, -1);

View file

@ -45,7 +45,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
public class Item extends NodeExtension
{
private String id;
/**
* Create an empty <tt>Item</tt> with no id. This is a valid item for nodes which are configured
* so that {@link ConfigureForm#isDeliverPayloads()} is false. In most cases an id will be generated by the server.
@ -57,7 +57,7 @@ public class Item extends NodeExtension
{
super(PubSubElementType.ITEM);
}
/**
* Create an <tt>Item</tt> with an id but no payload. This is a valid item for nodes which are configured
* so that {@link ConfigureForm#isDeliverPayloads()} is false.
@ -88,7 +88,7 @@ public class Item extends NodeExtension
super(PubSubElementType.ITEM_EVENT, nodeId);
id = itemId;
}
/**
* Get the item id. Unique to the node it is associated with.
*
@ -98,7 +98,7 @@ public class Item extends NodeExtension
{
return id;
}
@Override
public String getNamespace()
{
@ -109,14 +109,14 @@ public class Item extends NodeExtension
public String toXML()
{
StringBuilder builder = new StringBuilder("<item");
if (id != null)
{
builder.append(" id='");
builder.append(id);
builder.append("'");
}
if (getNode() != null) {
builder.append(" node='");
builder.append(getNode());

View file

@ -27,7 +27,7 @@ import java.util.List;
public class ItemDeleteEvent extends SubscriptionEvent
{
private List<String> itemIds = Collections.emptyList();
/**
* Constructs an <tt>ItemDeleteEvent</tt> that indicates the the supplied
* items (by id) have been deleted, and that the event matches the listed
@ -41,12 +41,12 @@ public class ItemDeleteEvent extends SubscriptionEvent
public ItemDeleteEvent(String nodeId, List<String> deletedItemIds, List<String> subscriptionIds)
{
super(nodeId, subscriptionIds);
if (deletedItemIds == null)
throw new IllegalArgumentException("deletedItemIds cannot be null");
itemIds = deletedItemIds;
}
/**
* Get the item id's of the items that have been deleted.
*
@ -56,7 +56,7 @@ public class ItemDeleteEvent extends SubscriptionEvent
{
return Collections.unmodifiableList(itemIds);
}
@Override
public String toString()
{

View file

@ -29,7 +29,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
{
private List<T> items;
private Date originalDate;
/**
* Constructs an <tt>ItemPublishEvent</tt> with the provided list
* of {@link Item} that were published.
@ -42,7 +42,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
super(nodeId);
items = eventItems;
}
/**
* Constructs an <tt>ItemPublishEvent</tt> with the provided list
* of {@link Item} that were published. The list of subscription ids
@ -58,7 +58,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
super(nodeId, subscriptionIds);
items = eventItems;
}
/**
* Constructs an <tt>ItemPublishEvent</tt> with the provided list
* of {@link Item} that were published in the past. The published
@ -74,11 +74,11 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
{
super(nodeId, subscriptionIds);
items = eventItems;
if (publishedDate != null)
originalDate = publishedDate;
}
/**
* Get the list of {@link Item} that were published.
*
@ -88,7 +88,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
{
return Collections.unmodifiableList(items);
}
/**
* Indicates whether this event was delayed. That is, the items
* were published to the node at some time in the past. This will
@ -103,7 +103,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
{
return (originalDate != null);
}
/**
* Gets the original date the items were published. This is only
* valid if {@link #isDelayed()} is true.
@ -120,5 +120,5 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
return getClass().getName() + " [subscriptions: " + getSubscriptions() + "], [Delayed: " +
(isDelayed() ? originalDate.toString() : "false") + ']';
}
}

View file

@ -26,7 +26,7 @@ public enum ItemReply
{
/** The node owner */
owner,
/** The item publisher */
publisher;
}

View file

@ -42,19 +42,19 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
{
/** An items element, which has an optional <b>max_items</b> attribute when requesting items */
items(PubSubElementType.ITEMS, "max_items"),
/** A retract element, which has an optional <b>notify</b> 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;
@ -89,7 +89,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
type = itemsType;
this.items = items;
}
/**
* Construct an instance with a list representing items that have been published or deleted.
*
@ -113,7 +113,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
this.items = items;
this.notify = notify;
}
/**
* Get the type of element
*
@ -123,13 +123,13 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
{
return type;
}
@SuppressWarnings("unchecked")
public List<ExtensionElement> getExtensions()
{
return (List<ExtensionElement>)getItems();
}
/**
* Gets the items related to the type of request or event.
*
@ -149,7 +149,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
{
return notify;
}
@Override
public CharSequence toXML()
{
@ -163,7 +163,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
builder.append(getElementName());
builder.append(" node='");
builder.append(getNode());
if (notify != null)
{
builder.append("' ");
@ -180,7 +180,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
builder.append(item.toXML());
}
}
builder.append("</");
builder.append(getElementName());
builder.append(">");

View file

@ -43,7 +43,7 @@ public class LeafNode extends Node
{
super(connection, nodeName);
}
/**
* Get information on the items in the node in standard
* {@link DiscoverItems} format.
@ -75,7 +75,7 @@ public class LeafNode extends Node
{
return getItems((List<ExtensionElement>) null, (List<ExtensionElement>) null);
}
/**
* Get the current items stored in the node based
* on the subscription associated with the provided
@ -113,7 +113,7 @@ public class LeafNode extends Node
public <T extends Item> List<T> getItems(Collection<String> ids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
List<Item> itemList = new ArrayList<Item>(ids.size());
for (String id : ids)
{
itemList.add(new Item(id));
@ -138,7 +138,7 @@ public class LeafNode extends Node
PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId(), maxItems));
return getItems(request);
}
/**
* Get items persisted on the node, limited to the specified number
* based on the subscription associated with the provided subscriptionId.
@ -218,10 +218,10 @@ public class LeafNode extends Node
public void publish() throws NotConnectedException, InterruptedException
{
PubSub packet = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId()));
con.sendStanza(packet);
}
/**
* Publishes an event to the node. This is a simple item
* with no payload.
@ -265,7 +265,7 @@ public class LeafNode extends Node
public <T extends Item> void publish(Collection<T> items) throws NotConnectedException, InterruptedException
{
PubSub packet = createPubsubPacket(Type.set, new PublishItem<T>(getId(), items));
con.sendStanza(packet);
}
@ -289,10 +289,10 @@ public class LeafNode extends Node
public void send() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
PubSub packet = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId()));
con.createPacketCollectorAndSend(packet).nextResultOrThrow();
}
/**
* Publishes an event to the node. This can be either a simple item
* with no payload, or one with it. This is determined by the Node
@ -324,7 +324,7 @@ public class LeafNode extends Node
items.add((item == null ? (T)new Item() : item));
send(items);
}
/**
* Publishes multiple events to the node. Same rules apply as in {@link #send(Item)}.
*
@ -346,10 +346,10 @@ public class LeafNode extends Node
public <T extends Item> void send(Collection<T> items) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
PubSub packet = createPubsubPacket(Type.set, new PublishItem<T>(getId(), items));
con.createPacketCollectorAndSend(packet).nextResultOrThrow();
}
/**
* Purges the node of all items.
*
@ -363,10 +363,10 @@ public class LeafNode extends Node
public void deleteAllItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
PubSub request = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PURGE_OWNER, getId()), PubSubElementType.PURGE_OWNER.getNamespace());
con.createPacketCollectorAndSend(request).nextResultOrThrow();
}
/**
* Delete the item with the specified id from the node.
*
@ -382,7 +382,7 @@ public class LeafNode extends Node
items.add(itemId);
deleteItem(items);
}
/**
* Delete the items with the specified id's from the node.
*
@ -395,7 +395,7 @@ public class LeafNode extends Node
public void deleteItem(Collection<String> itemIds) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
List<Item> items = new ArrayList<Item>(itemIds.size());
for (String id : itemIds)
{
items.add(new Item(id));

View file

@ -50,11 +50,11 @@ abstract public class Node
protected XMPPConnection con;
protected String id;
protected Jid to;
protected ConcurrentHashMap<ItemEventListener<Item>, StanzaListener> itemEventToListenerMap = new ConcurrentHashMap<ItemEventListener<Item>, StanzaListener>();
protected ConcurrentHashMap<ItemDeleteListener, StanzaListener> itemDeleteToListenerMap = new ConcurrentHashMap<ItemDeleteListener, StanzaListener>();
protected ConcurrentHashMap<NodeConfigListener, StanzaListener> configEventToListenerMap = new ConcurrentHashMap<NodeConfigListener, StanzaListener>();
/**
* Construct a node associated to the supplied connection with the specified
* node id.
@ -105,7 +105,7 @@ abstract public class Node
Stanza reply = sendPubsubPacket(pubSub);
return NodeUtils.getFormFromPacket(reply, PubSubElementType.CONFIGURE_OWNER);
}
/**
* Update the configuration with the contents of the new {@link Form}
*
@ -121,7 +121,7 @@ abstract public class Node
getId(), submitForm), PubSubNamespace.OWNER);
con.createPacketCollectorAndSend(packet).nextResultOrThrow();
}
/**
* Discover node information in standard {@link DiscoverInfo} format.
*
@ -138,7 +138,7 @@ abstract public class Node
info.setNode(getId());
return (DiscoverInfo) con.createPacketCollectorAndSend(info).nextResultOrThrow();
}
/**
* Get the subscriptions currently associated with this node.
*
@ -308,7 +308,7 @@ abstract public class Node
PubSub reply = sendPubsubPacket(pubSub);
return reply.getExtension(PubSubElementType.SUBSCRIPTION);
}
/**
* The user subscribes to the node using the supplied jid and subscription
* options. The bare jid portion of this one must match the jid for the
@ -352,7 +352,7 @@ abstract public class Node
{
unsubscribe(jid, null);
}
/**
* Remove the specific subscription related to the specified JID.
*
@ -427,7 +427,7 @@ abstract public class Node
public void removeItemEventListener(@SuppressWarnings("rawtypes") ItemEventListener listener)
{
StanzaListener conListener = itemEventToListenerMap.remove(listener);
if (conListener != null)
con.removeSyncStanzaListener(conListener);
}
@ -453,11 +453,11 @@ abstract public class Node
public void removeConfigurationListener(NodeConfigListener listener)
{
StanzaListener conListener = configEventToListenerMap .remove(listener);
if (conListener != null)
con.removeSyncStanzaListener(conListener);
}
/**
* Register an listener for item delete events. This listener
* gets called whenever an item is deleted from the node.
@ -470,7 +470,7 @@ abstract public class Node
itemDeleteToListenerMap.put(listener, delListener);
EventContentFilter deleteItem = new EventContentFilter(EventElementType.items.toString(), "retract");
EventContentFilter purge = new EventContentFilter(EventElementType.purge.toString());
con.addSyncStanzaListener(delListener, new OrFilter(deleteItem, purge));
}
@ -482,7 +482,7 @@ abstract public class Node
public void removeItemDeleteListener(ItemDeleteListener listener)
{
StanzaListener conListener = itemDeleteToListenerMap .remove(listener);
if (conListener != null)
con.removeSyncStanzaListener(conListener);
}
@ -492,12 +492,12 @@ abstract public class Node
{
return super.toString() + " " + getClass().getName() + " id: " + id;
}
protected PubSub createPubsubPacket(Type type, ExtensionElement ext)
{
return createPubsubPacket(type, ext, null);
}
protected PubSub createPubsubPacket(Type type, ExtensionElement ext, PubSubNamespace ns)
{
return PubSub.createPubsubPacket(to, type, ext, ns);
@ -513,11 +513,11 @@ abstract public class Node
{
HeadersExtension headers = (HeadersExtension)packet.getExtension("headers", "http://jabber.org/protocol/shim");
List<String> values = null;
if (headers != null)
{
values = new ArrayList<String>(headers.getHeaders().size());
for (Header header : headers.getHeaders())
{
values.add(header.getValue());
@ -541,7 +541,7 @@ abstract public class Node
{
listener = eventListener;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public void processPacket(Stanza packet)
{
@ -566,13 +566,13 @@ abstract public class Node
{
listener = eventListener;
}
public void processPacket(Stanza packet)
{
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
List<ExtensionElement> extList = event.getExtensions();
if (extList.get(0).getElementName().equals(PubSubElementType.PURGE_EVENT.getElementName()))
{
listener.handlePurge();
@ -594,7 +594,7 @@ abstract public class Node
}
}
}
/**
* This class translates low level node configuration events into api level objects for
* user consumption.
@ -609,7 +609,7 @@ abstract public class Node
{
listener = eventListener;
}
public void processPacket(Stanza packet)
{
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
@ -629,7 +629,7 @@ abstract public class Node
{
private String firstElement;
private String secondElement;
EventContentFilter(String elementName)
{
firstElement = elementName;
@ -647,27 +647,27 @@ abstract public class Node
return false;
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
if (event == null)
return false;
NodeExtension embedEvent = event.getEvent();
if (embedEvent == null)
return false;
if (embedEvent.getElementName().equals(firstElement))
{
if (!embedEvent.getNode().equals(getId()))
return false;
if (secondElement == null)
return true;
if (embedEvent instanceof EmbeddedPacketExtension)
{
List<ExtensionElement> secondLevelList = ((EmbeddedPacketExtension)embedEvent).getExtensions();
if (secondLevelList.size() > 0 && secondLevelList.get(0).getElementName().equals(secondElement))
return true;
}

View file

@ -19,12 +19,12 @@ package org.jivesoftware.smackx.pubsub;
abstract public class NodeEvent
{
private String nodeId;
protected NodeEvent(String id)
{
nodeId = id;
}
public String getNodeId()
{
return nodeId;

View file

@ -30,7 +30,7 @@ public class NodeExtension implements ExtensionElement
{
private final PubSubElementType element;
private final String node;
/**
* Constructs a <tt>NodeExtension</tt> with an element name specified
* by {@link PubSubElementType} and the specified node id.
@ -64,7 +64,7 @@ public class NodeExtension implements ExtensionElement
{
return node;
}
public String getElementName()
{
return element.getElementName();

View file

@ -27,29 +27,29 @@ public class OptionsExtension extends NodeExtension
{
protected String jid;
protected String id;
public OptionsExtension(String subscriptionJid)
{
this(subscriptionJid, null, null);
}
public OptionsExtension(String subscriptionJid, String nodeId)
{
this(subscriptionJid, nodeId, null);
}
public OptionsExtension(String jid, String nodeId, String subscriptionId)
{
super(PubSubElementType.OPTIONS, nodeId);
this.jid = jid;
id = subscriptionId;
}
public String getJid()
{
return jid;
}
public String getId()
{
return id;

View file

@ -46,7 +46,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
public class PayloadItem<E extends ExtensionElement> extends Item
{
private E payload;
/**
* Create an <tt>Item</tt> with no id and a payload The id will be set by the server.
*
@ -55,7 +55,7 @@ public class PayloadItem<E extends ExtensionElement> extends Item
public PayloadItem(E payloadExt)
{
super();
if (payloadExt == null)
throw new IllegalArgumentException("payload cannot be 'null'");
payload = payloadExt;
@ -70,12 +70,12 @@ public class PayloadItem<E extends ExtensionElement> extends Item
public PayloadItem(String itemId, E payloadExt)
{
super(itemId);
if (payloadExt == null)
throw new IllegalArgumentException("payload cannot be 'null'");
payload = payloadExt;
}
/**
* Create an <tt>Item</tt> with an id, node id and payload.
*
@ -92,12 +92,12 @@ public class PayloadItem<E extends ExtensionElement> extends Item
public PayloadItem(String itemId, String nodeId, E payloadExt)
{
super(itemId, nodeId);
if (payloadExt == null)
throw new IllegalArgumentException("payload cannot be 'null'");
payload = payloadExt;
}
/**
* Get the payload associated with this <tt>Item</tt>. Customising the payload
* parsing from the server can be accomplished as described in {@link ItemProvider}.
@ -108,19 +108,19 @@ public class PayloadItem<E extends ExtensionElement> extends Item
{
return payload;
}
@Override
public String toXML()
{
StringBuilder builder = new StringBuilder("<item");
if (getId() != null)
{
builder.append(" id='");
builder.append(getId());
builder.append("'");
}
if (getNode() != null) {
builder.append(" node='");
builder.append(getNode());
@ -129,7 +129,7 @@ public class PayloadItem<E extends ExtensionElement> extends Item
builder.append(">");
builder.append(payload.toXML());
builder.append("</item>");
return builder.toString();
}

View file

@ -53,28 +53,28 @@ public enum PubSubElementType
private String eName;
private PubSubNamespace nSpace;
private PubSubElementType(String elemName, PubSubNamespace ns)
{
eName = elemName;
nSpace = ns;
}
public PubSubNamespace getNamespace()
{
return nSpace;
}
public String getElementName()
{
return eName;
}
public static PubSubElementType valueOfFromElemName(String elemName, String namespace)
{
int index = namespace.lastIndexOf('#');
String fragment = (index == -1 ? null : namespace.substring(index+1));
if (fragment != null)
{
return valueOf((elemName + '_' + fragment).toUpperCase(Locale.US));

View file

@ -57,7 +57,7 @@ final public class PubSubManager
private XMPPConnection con;
private DomainBareJid to;
private Map<String, Node> nodeMap = new ConcurrentHashMap<String, Node>();
/**
* Create a pubsub manager associated to the specified connection. Defaults the service
* name to <i>pubsub</i>
@ -70,7 +70,7 @@ final public class PubSubManager
con = connection;
to = JidCreate.domainBareFrom("pubsub." + connection.getServiceName());
}
/**
* Create a pubsub manager associated to the specified connection where
* the pubsub requests require a specific to address for packets.
@ -83,7 +83,7 @@ final public class PubSubManager
con = connection;
to = toAddress;
}
/**
* Creates an instant node, if supported.
*
@ -97,14 +97,14 @@ final public class PubSubManager
{
PubSub reply = sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.CREATE), null);
NodeExtension elem = reply.getExtension("create", PubSubNamespace.BASIC.getXmlns());
LeafNode newNode = new LeafNode(con, elem.getNode());
newNode.setTo(to);
nodeMap.put(newNode.getId(), newNode);
return newNode;
}
/**
* Creates a node with default configuration.
*
@ -120,7 +120,7 @@ final public class PubSubManager
{
return (LeafNode)createNode(id, null);
}
/**
* Creates a node with specified configuration.
*
@ -139,12 +139,12 @@ final public class PubSubManager
{
PubSub request = PubSub.createPubsubPacket(to, Type.set, new NodeExtension(PubSubElementType.CREATE, name), null);
boolean isLeafNode = true;
if (config != null)
{
request.addExtension(new FormNode(FormNodeType.CONFIGURE, config));
FormField nodeTypeField = config.getField(ConfigureNodeFields.node_type.getFieldName());
if (nodeTypeField != null)
isLeafNode = nodeTypeField.getValues().get(0).equals(NodeType.leaf.toString());
}
@ -155,7 +155,7 @@ final public class PubSubManager
Node newNode = isLeafNode ? new LeafNode(con, name) : new CollectionNode(con, name);
newNode.setTo(to);
nodeMap.put(newNode.getId(), newNode);
return newNode;
}
@ -174,13 +174,13 @@ final public class PubSubManager
public <T extends Node> T getNode(String id) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
Node node = nodeMap.get(id);
if (node == null)
{
DiscoverInfo info = new DiscoverInfo();
info.setTo(to);
info.setNode(id);
DiscoverInfo infoReply = (DiscoverInfo) con.createPacketCollectorAndSend(info).nextResultOrThrow();
if (infoReply.hasIdentity(PubSub.ELEMENT, "leaf")) {
@ -205,7 +205,7 @@ final public class PubSubManager
}
return (T) node;
}
/**
* Get all the nodes that currently exist as a child of the specified
* collection node. If the service does not support collection nodes
@ -225,14 +225,14 @@ final public class PubSubManager
public DiscoverItems discoverNodes(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
DiscoverItems items = new DiscoverItems();
if (nodeId != null)
items.setNode(nodeId);
items.setTo(to);
DiscoverItems nodeItems = (DiscoverItems) con.createPacketCollectorAndSend(items).nextResultOrThrow();
return nodeItems;
}
/**
* Gets the subscriptions on the root node.
*
@ -248,7 +248,7 @@ final public class PubSubManager
SubscriptionsExtension subElem = reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
return subElem.getSubscriptions();
}
/**
* Gets the affiliations on the root node.
*
@ -280,7 +280,7 @@ final public class PubSubManager
sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.DELETE, nodeId), PubSubElementType.DELETE.getNamespace());
nodeMap.remove(nodeId);
}
/**
* Returns the default settings for Node configuration.
*
@ -297,7 +297,7 @@ final public class PubSubManager
PubSub reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.DEFAULT), PubSubElementType.DEFAULT.getNamespace());
return NodeUtils.getFormFromPacket(reply, PubSubElementType.DEFAULT);
}
/**
* Gets the supported features of the servers pubsub implementation
* as a standard {@link DiscoverInfo} instance.

View file

@ -27,7 +27,7 @@ import java.util.Collection;
public class PublishItem<T extends Item> extends NodeExtension
{
protected Collection<T> items;
/**
* Construct a request to publish an item to a node.
*
@ -61,13 +61,13 @@ public class PublishItem<T extends Item> extends NodeExtension
builder.append(" node='");
builder.append(getNode());
builder.append("'>");
for (Item item : items)
{
builder.append(item.toXML());
}
builder.append("</publish>");
return builder.toString();
}
}

View file

@ -26,10 +26,10 @@ public enum PublishModel
{
/** Only publishers may publish */
publishers,
/** Only subscribers may publish */
subscribers,
/** Anyone may publish */
open;
}

View file

@ -39,7 +39,7 @@ public class RetractItem implements ExtensionElement
throw new IllegalArgumentException("itemId must not be 'null'");
id = itemId;
}
public String getId()
{
return id;

View file

@ -29,7 +29,7 @@ public class SimplePayload implements ExtensionElement
private final String elemName;
private final String ns;
private final CharSequence payload;
/**
* Construct a <tt>SimplePayload</tt> object with the specified element name,
* namespace and content. The content must be well formed XML.

View file

@ -24,13 +24,13 @@ package org.jivesoftware.smackx.pubsub;
public class SubscribeExtension extends NodeExtension
{
protected String jid;
public SubscribeExtension(String subscribeJid)
{
super(PubSubElementType.SUBSCRIBE);
jid = subscribeJid;
}
public SubscribeExtension(String subscribeJid, String nodeId)
{
super(PubSubElementType.SUBSCRIBE, nodeId);
@ -47,7 +47,7 @@ public class SubscribeExtension extends NodeExtension
{
StringBuilder builder = new StringBuilder("<");
builder.append(getElementName());
if (getNode() != null)
{
builder.append(" node='");
@ -57,7 +57,7 @@ public class SubscribeExtension extends NodeExtension
builder.append(" jid='");
builder.append(getJid());
builder.append("'/>");
return builder.toString();
}
}

View file

@ -44,17 +44,17 @@ public class SubscribeForm extends Form
{
super(configDataForm);
}
public SubscribeForm(Form subscribeOptionsForm)
{
super(subscribeOptionsForm.getDataFormToSend());
}
public SubscribeForm(DataForm.Type formType)
{
super(formType);
}
/**
* Determines if an entity wants to receive notifications.
*
@ -64,7 +64,7 @@ public class SubscribeForm extends Form
{
return parseBoolean(getFieldValue(SubscribeOptionFields.deliver));
}
/**
* Sets whether an entity wants to receive notifications.
*
@ -85,7 +85,7 @@ public class SubscribeForm extends Form
{
return parseBoolean(getFieldValue(SubscribeOptionFields.digest));
}
/**
* Sets whether notifications should be delivered as aggregations or not.
*
@ -137,7 +137,7 @@ public class SubscribeForm extends Form
throw exc;
}
}
/**
* Sets the time at which the leased subscription will expire, or has expired.
*
@ -148,7 +148,7 @@ public class SubscribeForm extends Form
addField(SubscribeOptionFields.expire, FormField.Type.text_single);
setAnswer(SubscribeOptionFields.expire.getFieldName(), XmppDateTime.formatXEP0082Date(expire));
}
/**
* Determines whether the entity wants to receive an XMPP message body in
* addition to the payload format.
@ -159,7 +159,7 @@ public class SubscribeForm extends Form
{
return parseBoolean(getFieldValue(SubscribeOptionFields.include_body));
}
/**
* Sets whether the entity wants to receive an XMPP message body in
* addition to the payload format.
@ -181,14 +181,14 @@ public class SubscribeForm extends Form
public List<PresenceState> getShowValues()
{
ArrayList<PresenceState> result = new ArrayList<PresenceState>(5);
for (String state : getFieldValues(SubscribeOptionFields.show_values))
{
result.add(PresenceState.valueOf(state));
}
return result;
}
/**
* Sets the list of {@link PresenceState} for which an entity wants
* to receive notifications.
@ -198,7 +198,7 @@ public class SubscribeForm extends Form
public void setShowValues(Collection<PresenceState> stateValues)
{
ArrayList<String> values = new ArrayList<String>(stateValues.size());
for (PresenceState state : stateValues)
{
values.add(state.toString());
@ -206,8 +206,8 @@ public class SubscribeForm extends Form
addField(SubscribeOptionFields.show_values, FormField.Type.list_multi);
setAnswer(SubscribeOptionFields.show_values.getFieldName(), values);
}
static private boolean parseBoolean(String fieldValue)
{
return ("1".equals(fieldValue) || "true".equals(fieldValue));
@ -216,21 +216,21 @@ public class SubscribeForm extends Form
private String getFieldValue(SubscribeOptionFields field)
{
FormField formField = getField(field.getFieldName());
return formField.getValues().get(0);
}
private List<String> getFieldValues(SubscribeOptionFields field)
{
FormField formField = getField(field.getFieldName());
return formField.getValues();
}
private void addField(SubscribeOptionFields nodeField, FormField.Type type)
{
String fieldName = nodeField.getFieldName();
if (getField(fieldName) == null)
{
FormField field = new FormField(fieldName);

View file

@ -40,7 +40,7 @@ public enum SubscribeOptionFields
* <p><b>Value: boolean</b></p>
*/
digest,
/**
* The minimum number of seconds between sending any two notifications digests
*
@ -61,38 +61,38 @@ public enum SubscribeOptionFields
* <p><b>Value: boolean</b></p>
*/
include_body,
/**
* The presence states for which an entity wants to receive notifications.
*
* <p><b>Value: {@link PresenceState}</b></p>
*/
show_values,
/**
*
*
* <p><b>Value: </b></p>
*/
subscription_type,
/**
*
* <p><b>Value: </b></p>
*/
subscription_depth;
public String getFieldName()
{
if (this == show_values)
return "pubsub#" + toString().replace('_', '-');
return "pubsub#" + toString();
}
static public SubscribeOptionFields valueOfFromElement(String elementName)
{
String portion = elementName.substring(elementName.lastIndexOf('#' + 1));
if ("show-values".equals(portion))
return show_values;
else

View file

@ -27,7 +27,7 @@ public class Subscription extends NodeExtension
protected String id;
protected State state;
protected boolean configRequired = false;
public enum State
{
subscribed, unconfigured, pending, none
@ -43,7 +43,7 @@ public class Subscription extends NodeExtension
{
this(subscriptionJid, null, null, null);
}
/**
* Used to constructs a subscription request to the specified node with the specified
* JID.
@ -55,7 +55,7 @@ public class Subscription extends NodeExtension
{
this(subscriptionJid, nodeId, null, null);
}
/**
* Constructs a representation of a subscription reply to the specified node
* and JID. The server will have supplied the subscription id and current state.
@ -72,7 +72,7 @@ public class Subscription extends NodeExtension
id = subscriptionId;
this.state = state;
}
/**
* Constructs a representation of a subscription reply to the specified node
* and JID. The server will have supplied the subscription id and current state
@ -92,7 +92,7 @@ public class Subscription extends NodeExtension
this.state = state;
this.configRequired = configRequired;
}
/**
* Gets the JID the subscription is created for
*
@ -102,7 +102,7 @@ public class Subscription extends NodeExtension
{
return jid;
}
/**
* Gets the subscription id
*
@ -112,7 +112,7 @@ public class Subscription extends NodeExtension
{
return id;
}
/**
* Gets the current subscription state.
*
@ -132,21 +132,21 @@ public class Subscription extends NodeExtension
{
return configRequired;
}
public String toXML()
{
StringBuilder builder = new StringBuilder("<subscription");
appendAttribute(builder, "jid", jid);
if (getNode() != null)
appendAttribute(builder, "node", getNode());
if (id != null)
appendAttribute(builder, "subid", id);
if (state != null)
appendAttribute(builder, "subscription", state.toString());
builder.append("/>");
return builder.toString();
}

View file

@ -50,7 +50,7 @@ abstract public class SubscriptionEvent extends NodeEvent
protected SubscriptionEvent(String nodeId, List<String> subscriptionIds)
{
super(nodeId);
if (subscriptionIds != null)
subIds = subscriptionIds;
}
@ -64,7 +64,7 @@ abstract public class SubscriptionEvent extends NodeEvent
{
return Collections.unmodifiableList(subIds);
}
/**
* Set the list of subscription id's for this event.
*

View file

@ -27,7 +27,7 @@ import java.util.List;
public class SubscriptionsExtension extends NodeExtension
{
protected List<Subscription> items = Collections.emptyList();
/**
* Subscriptions to the root node
*
@ -36,7 +36,7 @@ public class SubscriptionsExtension extends NodeExtension
public SubscriptionsExtension(List<Subscription> subList)
{
super(PubSubElementType.SUBSCRIPTIONS);
if (subList != null)
items = subList;
}
@ -76,7 +76,7 @@ public class SubscriptionsExtension extends NodeExtension
{
StringBuilder builder = new StringBuilder("<");
builder.append(getElementName());
if (getNode() != null)
{
builder.append(" node='");
@ -84,12 +84,12 @@ public class SubscriptionsExtension extends NodeExtension
builder.append("'");
}
builder.append(">");
for (Subscription item : items)
{
builder.append(item.toXML());
}
builder.append("</");
builder.append(getElementName());
builder.append(">");

View file

@ -28,29 +28,29 @@ public class UnsubscribeExtension extends NodeExtension
{
protected String jid;
protected String id;
public UnsubscribeExtension(String subscriptionJid)
{
this(subscriptionJid, null, null);
}
public UnsubscribeExtension(String subscriptionJid, String nodeId)
{
this(subscriptionJid, nodeId, null);
}
public UnsubscribeExtension(String jid, String nodeId, String subscriptionId)
{
super(PubSubElementType.UNSUBSCRIBE, nodeId);
this.jid = jid;
id = subscriptionId;
}
public String getJid()
{
return jid;
}
public String getId()
{
return id;

View file

@ -35,7 +35,7 @@ public interface ItemDeleteListener
* @param items The event with item deletion details
*/
void handleDeletedItems(ItemDeleteEvent items);
/**
* Called when <b>all</b> items are deleted from a node the listener is
* registered with.

View file

@ -30,24 +30,24 @@ public enum PubSubNamespace
ERROR("errors"),
EVENT("event"),
OWNER("owner");
private String fragment;
private PubSubNamespace(String fragment)
{
this.fragment = fragment;
}
public String getXmlns()
{
String ns = PubSub.NAMESPACE;
if (fragment != null)
ns += '#' + fragment;
return ns;
}
public String getFragment()
{
return fragment;
@ -56,7 +56,7 @@ public enum PubSubNamespace
public static PubSubNamespace valueOfFromXmlns(String ns)
{
int index = ns.lastIndexOf('#');
if (index != -1)
{
String suffix = ns.substring(ns.lastIndexOf('#')+1);

View file

@ -41,14 +41,14 @@ public class SubscriptionProvider extends ExtensionElementProvider<Subscription>
boolean isRequired = false;
int tag = parser.next();
if ((tag == XmlPullParser.START_TAG) && parser.getName().equals("subscribe-options"))
{
tag = parser.next();
if ((tag == XmlPullParser.START_TAG) && parser.getName().equals("required"))
isRequired = true;
while (tag != XmlPullParser.END_TAG && !parser.getName().equals("subscribe-options")) tag = parser.next();
}
while (parser.getEventType() != XmlPullParser.END_TAG) parser.next();

View file

@ -32,11 +32,11 @@ import java.util.List;
* @author Gaston Dombiak
*/
public class ReportedData {
private List<Column> columns = new ArrayList<Column>();
private List<Row> rows = new ArrayList<Row>();
private String title = "";
/**
* Returns a new ReportedData if the packet is used for reporting data and includes an
* extension that matches the elementName and namespace "x","jabber:x:data".

View file

@ -95,7 +95,7 @@ public class StreamInitiationProvider extends IQProvider<StreamInitiation> {
LOGGER.log(Level.SEVERE, "Failed to parse file size from " + fileSize, e);
}
}
Date fileDate = new Date();
if (date != null) {
try {
@ -104,7 +104,7 @@ public class StreamInitiationProvider extends IQProvider<StreamInitiation> {
// couldn't parse date, use current date-time
}
}
File file = new File(name, fileSize);
file.setHash(hash);
file.setDate(fileDate);

View file

@ -87,9 +87,9 @@ public class VCard extends IQ {
public static final String NAMESPACE = "vcard-temp";
private static final Logger LOGGER = Logger.getLogger(VCard.class.getName());
private static final String DEFAULT_MIME_TYPE = "image/jpeg";
/**
* Phone types:
* VOICE?, FAX?, PAGER?, MSG?, CELL?, VIDEO?, BBS?, MODEM?, ISDN?, PCS?, PREF?
@ -404,7 +404,7 @@ public class VCard extends IQ {
public void setEncodedImage(String encodedAvatar) {
setAvatar(encodedAvatar, DEFAULT_MIME_TYPE);
}
/**
* Return the byte representation of the avatar(if one exists), otherwise returns null if
* no avatar could be found.

View file

@ -73,7 +73,7 @@ public class Form {
public Form(DataForm dataForm) {
this.dataForm = dataForm;
}
/**
* Creates a new Form of a given type from scratch.
*
@ -82,7 +82,7 @@ public class Form {
public Form(DataForm.Type type) {
this.dataForm = new DataForm(type);
}
/**
* Adds a new field to complete as part of the form.
*
@ -91,7 +91,7 @@ public class Form {
public void addField(FormField field) {
dataForm.addField(field);
}
/**
* Sets a new String value to a given form's field. The field whose variable matches the
* requested variable will be completed with the specified value. If no field could be found
@ -401,7 +401,7 @@ public class Form {
public DataForm.Type getType() {
return dataForm.getType();
}
/**
* Sets instructions that explain how to fill out the form and what the form is about.
@ -417,7 +417,7 @@ public class Form {
}
// Set the new list of instructions
dataForm.setInstructions(instructionsList);
}
@ -430,7 +430,7 @@ public class Form {
public void setTitle(String title) {
dataForm.setTitle(title);
}
/**
* Returns a DataForm that serves to send this Form to the server. If the form is of type
* submit, it may contain fields with no value. These fields will be removed since they only
@ -451,7 +451,7 @@ public class Form {
}
return dataForm;
}
/**
* Returns true if the form is a form to fill out.
*
@ -460,7 +460,7 @@ public class Form {
private boolean isFormType() {
return DataForm.Type.form == dataForm.getType();
}
/**
* Returns true if the form is a form to submit.
*

View file

@ -73,11 +73,11 @@ public class DataForm implements ExtensionElement {
private final List<Item> items = new ArrayList<Item>();
private final List<FormField> fields = new ArrayList<FormField>();
private final List<Element> extensionElements = new ArrayList<Element>();
public DataForm(Type type) {
this.type = type;
}
/**
* Returns the meaning of the data within the context. The data could be part of a form
* to fill out, a form submission or data results.
@ -87,7 +87,7 @@ public class DataForm implements ExtensionElement {
public Type getType() {
return type;
}
/**
* Returns the description of the data. It is similar to the title on a web page or an X
* window. You can put a <title/> on either a form to fill out, or a set of data results.
@ -214,7 +214,7 @@ public class DataForm implements ExtensionElement {
fields.add(field);
}
}
/**
* Adds a new instruction to the list of instructions that explain how to fill out the form
* and what the form is about. The dataform could include multiple instructions since each
@ -320,7 +320,7 @@ public class DataForm implements ExtensionElement {
public static final String ELEMENT = "reported";
private List<FormField> fields = new ArrayList<FormField>();
public ReportedData(List<FormField> fields) {
this.fields = fields;
}
@ -345,7 +345,7 @@ public class DataForm implements ExtensionElement {
return buf;
}
}
/**
*
* Represents items of reported data.
@ -356,11 +356,11 @@ public class DataForm implements ExtensionElement {
public static final String ELEMENT = "item";
private List<FormField> fields = new ArrayList<FormField>();
public Item(List<FormField> fields) {
this.fields = fields;
}
/**
* Returns the fields that define the data that goes with the item.
*
@ -369,7 +369,7 @@ public class DataForm implements ExtensionElement {
public List<FormField> getFields() {
return Collections.unmodifiableList(new ArrayList<FormField>(fields));
}
public CharSequence toXML() {
XmlStringBuilder buf = new XmlStringBuilder();
buf.openElement(ELEMENT);