2003-01-13 17:58:47 +01:00
|
|
|
/**
|
|
|
|
* $RCSfile$
|
|
|
|
* $Revision$
|
|
|
|
* $Date$
|
|
|
|
*
|
2007-02-12 01:59:05 +01:00
|
|
|
* Copyright 2003-2007 Jive Software.
|
2003-01-13 17:58:47 +01:00
|
|
|
*
|
2004-11-03 00:53:30 +01:00
|
|
|
* 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
|
2003-01-13 17:58:47 +01:00
|
|
|
*
|
2004-11-03 00:53:30 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2003-01-13 17:58:47 +01:00
|
|
|
*
|
2004-11-03 00:53:30 +01:00
|
|
|
* 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.
|
2003-01-13 17:58:47 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
package org.jivesoftware.smack.packet;
|
|
|
|
|
|
|
|
import org.jivesoftware.smack.util.StringUtils;
|
|
|
|
|
2006-07-18 07:14:33 +02:00
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
import java.io.ObjectOutputStream;
|
|
|
|
import java.io.Serializable;
|
2003-01-13 17:58:47 +01:00
|
|
|
import java.util.*;
|
2006-11-23 22:10:59 +01:00
|
|
|
import java.util.concurrent.CopyOnWriteArrayList;
|
2003-01-13 17:58:47 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Base class for XMPP packets. Every packet has a unique ID (which is automatically
|
|
|
|
* generated, but can be overriden). Optionally, the "to" and "from" fields can be set,
|
|
|
|
* as well as an arbitrary number of properties.
|
|
|
|
*
|
|
|
|
* Properties provide an easy mechanism for clients to share data. Each property has a
|
|
|
|
* String name, and a value that is a Java primitive (int, long, float, double, boolean)
|
|
|
|
* or any Serializable object (a Java object is Serializable when it implements the
|
|
|
|
* Serializable interface).
|
|
|
|
*
|
|
|
|
* @author Matt Tucker
|
|
|
|
*/
|
|
|
|
public abstract class Packet {
|
|
|
|
|
2007-04-26 08:22:55 +02:00
|
|
|
protected static final String DEFAULT_LANGUAGE =
|
|
|
|
java.util.Locale.getDefault().getLanguage().toLowerCase();
|
|
|
|
|
|
|
|
private static String DEFAULT_XML_NS = null;
|
|
|
|
|
2004-02-10 16:36:57 +01:00
|
|
|
/**
|
|
|
|
* Constant used as packetID to indicate that a packet has no id. To indicate that a packet
|
2006-09-16 00:42:06 +02:00
|
|
|
* has no id set this constant as the packet's id. When the packet is asked for its id the
|
2004-02-10 16:36:57 +01:00
|
|
|
* answer will be <tt>null</tt>.
|
|
|
|
*/
|
|
|
|
public static final String ID_NOT_AVAILABLE = "ID_NOT_AVAILABLE";
|
|
|
|
|
2003-01-13 17:58:47 +01:00
|
|
|
/**
|
|
|
|
* A prefix helps to make sure that ID's are unique across mutliple instances.
|
|
|
|
*/
|
2003-04-25 22:21:28 +02:00
|
|
|
private static String prefix = StringUtils.randomString(5) + "-";
|
2003-01-13 17:58:47 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Keeps track of the current increment, which is appended to the prefix to
|
|
|
|
* forum a unique ID.
|
|
|
|
*/
|
|
|
|
private static long id = 0;
|
|
|
|
|
2007-04-26 08:22:55 +02:00
|
|
|
private String xmlns = DEFAULT_XML_NS;
|
|
|
|
|
2003-01-13 17:58:47 +01:00
|
|
|
/**
|
|
|
|
* Returns the next unique id. Each id made up of a short alphanumeric
|
|
|
|
* prefix along with a unique numeric value.
|
|
|
|
*
|
|
|
|
* @return the next id.
|
|
|
|
*/
|
2007-04-26 08:22:55 +02:00
|
|
|
public static synchronized String nextID() {
|
2003-01-13 17:58:47 +01:00
|
|
|
return prefix + Long.toString(id++);
|
|
|
|
}
|
|
|
|
|
2007-04-26 08:22:55 +02:00
|
|
|
public static void setDefaultXmlns(String defaultXmlns) {
|
|
|
|
DEFAULT_XML_NS = defaultXmlns;
|
|
|
|
}
|
|
|
|
|
2003-04-25 22:21:28 +02:00
|
|
|
private String packetID = null;
|
2003-01-13 17:58:47 +01:00
|
|
|
private String to = null;
|
|
|
|
private String from = null;
|
2006-11-23 22:10:59 +01:00
|
|
|
private final List<PacketExtension> packetExtensions
|
|
|
|
= new CopyOnWriteArrayList<PacketExtension>();
|
|
|
|
|
2007-05-04 20:35:47 +02:00
|
|
|
private final Map<String,Object> properties = new HashMap<String, Object>();
|
2003-03-07 20:47:08 +01:00
|
|
|
private XMPPError error = null;
|
2003-01-13 17:58:47 +01:00
|
|
|
|
|
|
|
/**
|
2004-02-10 16:36:57 +01:00
|
|
|
* Returns the unique ID of the packet. The returned value could be <tt>null</tt> when
|
|
|
|
* ID_NOT_AVAILABLE was set as the packet's id.
|
2003-01-13 17:58:47 +01:00
|
|
|
*
|
2004-02-10 16:36:57 +01:00
|
|
|
* @return the packet's unique ID or <tt>null</tt> if the packet's id is not available.
|
2003-01-13 17:58:47 +01:00
|
|
|
*/
|
|
|
|
public String getPacketID() {
|
2004-02-10 16:36:57 +01:00
|
|
|
if (ID_NOT_AVAILABLE.equals(packetID)) {
|
|
|
|
return null;
|
|
|
|
}
|
2006-09-16 00:42:06 +02:00
|
|
|
|
2003-04-25 22:21:28 +02:00
|
|
|
if (packetID == null) {
|
|
|
|
packetID = nextID();
|
|
|
|
}
|
2003-01-13 17:58:47 +01:00
|
|
|
return packetID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2006-09-16 00:42:06 +02:00
|
|
|
* Sets the unique ID of the packet. To indicate that a packet has no id
|
2004-02-10 16:36:57 +01:00
|
|
|
* pass the constant ID_NOT_AVAILABLE as the packet's id value.
|
2003-01-13 17:58:47 +01:00
|
|
|
*
|
|
|
|
* @param packetID the unique ID for the packet.
|
|
|
|
*/
|
|
|
|
public void setPacketID(String packetID) {
|
|
|
|
this.packetID = packetID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns who the packet is being sent "to", or <tt>null</tt> if
|
|
|
|
* the value is not set. The XMPP protocol often makes the "to"
|
2007-04-21 22:14:40 +02:00
|
|
|
* attribute optional, so it does not always need to be set.<p>
|
|
|
|
*
|
|
|
|
* The StringUtils class provides several useful methods for dealing with
|
|
|
|
* XMPP addresses such as parsing the
|
|
|
|
* {@link StringUtils#parseBareAddress(String) bare address},
|
|
|
|
* {@link StringUtils#parseName(String) user name},
|
|
|
|
* {@link StringUtils#parseServer(String) server}, and
|
|
|
|
* {@link StringUtils#parseResource(String) resource}.
|
2003-01-13 17:58:47 +01:00
|
|
|
*
|
|
|
|
* @return who the packet is being sent to, or <tt>null</tt> if the
|
|
|
|
* value has not been set.
|
|
|
|
*/
|
|
|
|
public String getTo() {
|
2006-09-15 22:53:18 +02:00
|
|
|
return to;
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets who the packet is being sent "to". The XMPP protocol often makes
|
|
|
|
* the "to" attribute optional, so it does not always need to be set.
|
|
|
|
*
|
|
|
|
* @param to who the packet is being sent to.
|
|
|
|
*/
|
|
|
|
public void setTo(String to) {
|
2006-09-16 00:42:06 +02:00
|
|
|
this.to = to;
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns who the packet is being sent "from" or <tt>null</tt> if
|
|
|
|
* the value is not set. The XMPP protocol often makes the "from"
|
2007-04-21 22:14:40 +02:00
|
|
|
* attribute optional, so it does not always need to be set.<p>
|
|
|
|
*
|
|
|
|
* The StringUtils class provides several useful methods for dealing with
|
|
|
|
* XMPP addresses such as parsing the
|
|
|
|
* {@link StringUtils#parseBareAddress(String) bare address},
|
|
|
|
* {@link StringUtils#parseName(String) user name},
|
|
|
|
* {@link StringUtils#parseServer(String) server}, and
|
|
|
|
* {@link StringUtils#parseResource(String) resource}.
|
2003-01-13 17:58:47 +01:00
|
|
|
*
|
|
|
|
* @return who the packet is being sent from, or <tt>null</tt> if the
|
2007-04-21 22:14:40 +02:00
|
|
|
* value has not been set.
|
2003-01-13 17:58:47 +01:00
|
|
|
*/
|
|
|
|
public String getFrom() {
|
2006-09-15 22:53:18 +02:00
|
|
|
return from;
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets who the packet is being sent "from". The XMPP protocol often
|
|
|
|
* makes the "from" attribute optional, so it does not always need to
|
|
|
|
* be set.
|
|
|
|
*
|
|
|
|
* @param from who the packet is being sent to.
|
|
|
|
*/
|
|
|
|
public void setFrom(String from) {
|
2006-09-16 00:42:06 +02:00
|
|
|
this.from = from;
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the error associated with this packet, or <tt>null</tt> if there are
|
|
|
|
* no errors.
|
|
|
|
*
|
|
|
|
* @return the error sub-packet or <tt>null</tt> if there isn't an error.
|
|
|
|
*/
|
2003-03-07 20:47:08 +01:00
|
|
|
public XMPPError getError() {
|
2003-01-13 17:58:47 +01:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the error for this packet.
|
|
|
|
*
|
|
|
|
* @param error the error to associate with this packet.
|
|
|
|
*/
|
2003-03-07 20:47:08 +01:00
|
|
|
public void setError(XMPPError error) {
|
2003-01-13 17:58:47 +01:00
|
|
|
this.error = error;
|
|
|
|
}
|
|
|
|
|
2003-05-08 17:55:06 +02:00
|
|
|
/**
|
2006-07-18 08:47:38 +02:00
|
|
|
* Returns an unmodifiable collection of the packet extensions attached to the packet.
|
2003-05-08 17:55:06 +02:00
|
|
|
*
|
2006-07-18 08:47:38 +02:00
|
|
|
* @return the packet extensions.
|
2003-05-08 17:55:06 +02:00
|
|
|
*/
|
2006-07-18 08:47:38 +02:00
|
|
|
public synchronized Collection<PacketExtension> getExtensions() {
|
2003-05-08 17:55:06 +02:00
|
|
|
if (packetExtensions == null) {
|
2006-07-18 08:47:38 +02:00
|
|
|
return Collections.emptyList();
|
2003-05-08 17:55:06 +02:00
|
|
|
}
|
2006-07-18 08:47:38 +02:00
|
|
|
return Collections.unmodifiableList(new ArrayList<PacketExtension>(packetExtensions));
|
2003-05-08 17:55:06 +02:00
|
|
|
}
|
|
|
|
|
2006-11-23 22:10:59 +01:00
|
|
|
/**
|
|
|
|
* Returns the first extension of this packet that has the given namespace.
|
|
|
|
*
|
|
|
|
* @param namespace the namespace of the extension that is desired.
|
|
|
|
* @return the packet extension with the given namespace.
|
|
|
|
*/
|
|
|
|
public PacketExtension getExtension(String namespace) {
|
|
|
|
return getExtension(null, namespace);
|
|
|
|
}
|
|
|
|
|
2003-05-08 17:55:06 +02:00
|
|
|
/**
|
|
|
|
* Returns the first packet extension that matches the specified element name and
|
2006-11-23 22:10:59 +01:00
|
|
|
* namespace, or <tt>null</tt> if it doesn't exist. If the provided elementName is null
|
|
|
|
* than only the provided namespace is attempted to be matched. Packet extensions are
|
2004-03-29 23:31:52 +02:00
|
|
|
* are arbitrary XML sub-documents in standard XMPP packets. By default, a
|
|
|
|
* DefaultPacketExtension instance will be returned for each extension. However,
|
|
|
|
* PacketExtensionProvider instances can be registered with the
|
|
|
|
* {@link org.jivesoftware.smack.provider.ProviderManager ProviderManager}
|
2003-05-08 17:55:06 +02:00
|
|
|
* class to handle custom parsing. In that case, the type of the Object
|
|
|
|
* will be determined by the provider.
|
|
|
|
*
|
2006-11-23 22:10:59 +01:00
|
|
|
* @param elementName the XML element name of the packet extension. (May be null)
|
2003-05-08 17:55:06 +02:00
|
|
|
* @param namespace the XML element namespace of the packet extension.
|
|
|
|
* @return the extension, or <tt>null</tt> if it doesn't exist.
|
|
|
|
*/
|
2006-11-23 22:10:59 +01:00
|
|
|
public PacketExtension getExtension(String elementName, String namespace) {
|
|
|
|
if (namespace == null) {
|
2003-05-08 17:55:06 +02:00
|
|
|
return null;
|
|
|
|
}
|
2006-07-18 08:47:38 +02:00
|
|
|
for (PacketExtension ext : packetExtensions) {
|
2006-11-23 22:10:59 +01:00
|
|
|
if ((elementName == null || elementName.equals(ext.getElementName()))
|
|
|
|
&& namespace.equals(ext.getNamespace()))
|
|
|
|
{
|
2003-05-08 17:55:06 +02:00
|
|
|
return ext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a packet extension to the packet.
|
|
|
|
*
|
|
|
|
* @param extension a packet extension.
|
|
|
|
*/
|
2006-11-23 22:10:59 +01:00
|
|
|
public void addExtension(PacketExtension extension) {
|
2003-05-08 17:55:06 +02:00
|
|
|
packetExtensions.add(extension);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a packet extension from the packet.
|
|
|
|
*
|
|
|
|
* @param extension the packet extension to remove.
|
|
|
|
*/
|
2006-11-23 22:10:59 +01:00
|
|
|
public void removeExtension(PacketExtension extension) {
|
|
|
|
packetExtensions.remove(extension);
|
2003-05-08 17:55:06 +02:00
|
|
|
}
|
|
|
|
|
2003-01-13 17:58:47 +01:00
|
|
|
/**
|
|
|
|
* Returns the packet property with the specified name or <tt>null</tt> if the
|
|
|
|
* property doesn't exist. Property values that were orginally primitives will
|
|
|
|
* be returned as their object equivalent. For example, an int property will be
|
|
|
|
* returned as an Integer, a double as a Double, etc.
|
|
|
|
*
|
|
|
|
* @param name the name of the property.
|
|
|
|
* @return the property, or <tt>null</tt> if the property doesn't exist.
|
|
|
|
*/
|
|
|
|
public synchronized Object getProperty(String name) {
|
2003-02-04 18:14:14 +01:00
|
|
|
if (properties == null) {
|
|
|
|
return null;
|
|
|
|
}
|
2003-01-13 17:58:47 +01:00
|
|
|
return properties.get(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets a property with an Object as the value. The value must be Serializable
|
|
|
|
* or an IllegalArgumentException will be thrown.
|
|
|
|
*
|
|
|
|
* @param name the name of the property.
|
|
|
|
* @param value the value of the property.
|
|
|
|
*/
|
|
|
|
public synchronized void setProperty(String name, Object value) {
|
|
|
|
if (!(value instanceof Serializable)) {
|
|
|
|
throw new IllegalArgumentException("Value must be serialiazble");
|
|
|
|
}
|
|
|
|
properties.put(name, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deletes a property.
|
|
|
|
*
|
|
|
|
* @param name the name of the property to delete.
|
|
|
|
*/
|
|
|
|
public synchronized void deleteProperty(String name) {
|
2003-02-04 18:14:14 +01:00
|
|
|
if (properties == null) {
|
|
|
|
return;
|
|
|
|
}
|
2003-01-13 17:58:47 +01:00
|
|
|
properties.remove(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2006-07-18 08:47:38 +02:00
|
|
|
* Returns an unmodifiable collection of all the property names that are set.
|
2003-01-13 17:58:47 +01:00
|
|
|
*
|
2006-07-18 08:47:38 +02:00
|
|
|
* @return all property names.
|
2003-01-13 17:58:47 +01:00
|
|
|
*/
|
2006-07-18 08:47:38 +02:00
|
|
|
public synchronized Collection<String> getPropertyNames() {
|
2003-02-04 18:14:14 +01:00
|
|
|
if (properties == null) {
|
2006-07-18 08:47:38 +02:00
|
|
|
return Collections.emptySet();
|
2003-02-04 18:14:14 +01:00
|
|
|
}
|
2006-07-18 08:47:38 +02:00
|
|
|
return Collections.unmodifiableSet(new HashSet<String>(properties.keySet()));
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the packet as XML. Every concrete extension of Packet must implement
|
2003-05-08 17:55:06 +02:00
|
|
|
* this method. In addition to writing out packet-specific data, every sub-class
|
|
|
|
* should also write out the error and the extensions data if they are defined.
|
2003-01-13 17:58:47 +01:00
|
|
|
*
|
|
|
|
* @return the XML format of the packet as a String.
|
|
|
|
*/
|
|
|
|
public abstract String toXML();
|
|
|
|
|
|
|
|
/**
|
2003-05-08 17:55:06 +02:00
|
|
|
* Returns the extension sub-packets (including properties data) as an XML
|
|
|
|
* String, or the Empty String if there are no packet extensions.
|
2003-01-13 17:58:47 +01:00
|
|
|
*
|
2003-05-08 17:55:06 +02:00
|
|
|
* @return the extension sub-packets as XML or the Empty String if there
|
|
|
|
* are no packet extensions.
|
2003-01-13 17:58:47 +01:00
|
|
|
*/
|
2003-05-27 17:07:13 +02:00
|
|
|
protected synchronized String getExtensionsXML() {
|
2006-07-18 07:14:33 +02:00
|
|
|
StringBuilder buf = new StringBuilder();
|
2003-05-08 17:55:06 +02:00
|
|
|
// Add in all standard extension sub-packets.
|
2006-07-18 08:47:38 +02:00
|
|
|
for (PacketExtension extension : getExtensions()) {
|
2003-05-08 17:55:06 +02:00
|
|
|
buf.append(extension.toXML());
|
|
|
|
}
|
|
|
|
// Add in packet properties.
|
|
|
|
if (properties != null && !properties.isEmpty()) {
|
|
|
|
buf.append("<properties xmlns=\"http://www.jivesoftware.com/xmlns/xmpp/properties\">");
|
|
|
|
// Loop through all properties and write them out.
|
2006-07-18 08:47:38 +02:00
|
|
|
for (String name : getPropertyNames()) {
|
2003-05-08 17:55:06 +02:00
|
|
|
Object value = getProperty(name);
|
|
|
|
buf.append("<property>");
|
|
|
|
buf.append("<name>").append(StringUtils.escapeForXML(name)).append("</name>");
|
|
|
|
buf.append("<value type=\"");
|
|
|
|
if (value instanceof Integer) {
|
|
|
|
buf.append("integer\">").append(value).append("</value>");
|
|
|
|
}
|
|
|
|
else if (value instanceof Long) {
|
|
|
|
buf.append("long\">").append(value).append("</value>");
|
|
|
|
}
|
|
|
|
else if (value instanceof Float) {
|
|
|
|
buf.append("float\">").append(value).append("</value>");
|
|
|
|
}
|
|
|
|
else if (value instanceof Double) {
|
|
|
|
buf.append("double\">").append(value).append("</value>");
|
|
|
|
}
|
|
|
|
else if (value instanceof Boolean) {
|
|
|
|
buf.append("boolean\">").append(value).append("</value>");
|
|
|
|
}
|
|
|
|
else if (value instanceof String) {
|
|
|
|
buf.append("string\">");
|
|
|
|
buf.append(StringUtils.escapeForXML((String)value));
|
|
|
|
buf.append("</value>");
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
2003-05-08 17:55:06 +02:00
|
|
|
// Otherwise, it's a generic Serializable object. Serialized objects are in
|
|
|
|
// a binary format, which won't work well inside of XML. Therefore, we base-64
|
|
|
|
// encode the binary data before adding it.
|
|
|
|
else {
|
2004-07-13 02:39:30 +02:00
|
|
|
ByteArrayOutputStream byteStream = null;
|
|
|
|
ObjectOutputStream out = null;
|
2003-05-08 17:55:06 +02:00
|
|
|
try {
|
2004-07-13 02:39:30 +02:00
|
|
|
byteStream = new ByteArrayOutputStream();
|
|
|
|
out = new ObjectOutputStream(byteStream);
|
2003-05-08 17:55:06 +02:00
|
|
|
out.writeObject(value);
|
|
|
|
buf.append("java-object\">");
|
2003-06-25 22:03:10 +02:00
|
|
|
String encodedVal = StringUtils.encodeBase64(byteStream.toByteArray());
|
2003-05-08 17:55:06 +02:00
|
|
|
buf.append(encodedVal).append("</value>");
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
2004-07-13 02:39:30 +02:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
if (out != null) {
|
2006-07-18 08:47:38 +02:00
|
|
|
try {
|
|
|
|
out.close();
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
// Ignore.
|
|
|
|
}
|
2004-07-13 02:39:30 +02:00
|
|
|
}
|
|
|
|
if (byteStream != null) {
|
2006-07-18 08:47:38 +02:00
|
|
|
try {
|
|
|
|
byteStream.close();
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
// Ignore.
|
|
|
|
}
|
2004-07-13 02:39:30 +02:00
|
|
|
}
|
2003-05-08 17:55:06 +02:00
|
|
|
}
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
2003-05-08 17:55:06 +02:00
|
|
|
buf.append("</property>");
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
2003-05-08 17:55:06 +02:00
|
|
|
buf.append("</properties>");
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
|
|
|
return buf.toString();
|
|
|
|
}
|
2007-04-26 08:22:55 +02:00
|
|
|
|
|
|
|
public String getXmlns() {
|
|
|
|
return this.xmlns;
|
|
|
|
}
|
|
|
|
|
2010-08-15 17:13:05 +02:00
|
|
|
/**
|
|
|
|
* Returns the default language used for all messages containing localized content.
|
|
|
|
*
|
|
|
|
* @return the default language
|
|
|
|
*/
|
|
|
|
public static String getDefaultLanguage() {
|
2007-04-26 08:22:55 +02:00
|
|
|
return DEFAULT_LANGUAGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object o) {
|
|
|
|
if (this == o) return true;
|
|
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
|
|
|
|
|
|
Packet packet = (Packet) o;
|
|
|
|
|
|
|
|
if (error != null ? !error.equals(packet.error) : packet.error != null) { return false; }
|
|
|
|
if (from != null ? !from.equals(packet.from) : packet.from != null) { return false; }
|
|
|
|
if (!packetExtensions.equals(packet.packetExtensions)) { return false; }
|
|
|
|
if (packetID != null ? !packetID.equals(packet.packetID) : packet.packetID != null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (properties != null ? !properties.equals(packet.properties)
|
|
|
|
: packet.properties != null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (to != null ? !to.equals(packet.to) : packet.to != null) { return false; }
|
|
|
|
return !(xmlns != null ? !xmlns.equals(packet.xmlns) : packet.xmlns != null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
int result;
|
|
|
|
result = (xmlns != null ? xmlns.hashCode() : 0);
|
|
|
|
result = 31 * result + (packetID != null ? packetID.hashCode() : 0);
|
|
|
|
result = 31 * result + (to != null ? to.hashCode() : 0);
|
|
|
|
result = 31 * result + (from != null ? from.hashCode() : 0);
|
|
|
|
result = 31 * result + packetExtensions.hashCode();
|
|
|
|
result = 31 * result + properties.hashCode();
|
|
|
|
result = 31 * result + (error != null ? error.hashCode() : 0);
|
|
|
|
return result;
|
|
|
|
}
|
2003-05-08 17:55:06 +02:00
|
|
|
}
|