Smack

org.jivesoftware.smack.packet
Class XMPPError

java.lang.Object
  extended by org.jivesoftware.smack.packet.XMPPError

public class XMPPError
extends Object

Represents a XMPP error sub-packet. Typically, a server responds to a request that has problems by sending the packet back and including an error packet. Each error has a code, type, error condition as well as as an optional text explanation. Typical errors are:


>
CodeXMPP ErrorType
500interna-server-errorWAIT
403forbiddenAUTH
400bad-requestMODIFY
404item-not-foundCANCEL
409conflictCANCEL
501feature-not-implementedCANCEL
302goneMODIFY
400jid-malformedMODIFY
406no-acceptable MODIFY
405not-allowedCANCEL
401not-authorizedAUTH
402payment-requiredAUTH
404recipient-unavailableWAIT
302redirectMODIFY
407registration-requiredAUTH
404remote-server-not-foundCANCEL
504remote-server-timeoutWAIT
502remote-server-errorCANCEL
500resource-constraintWAIT
503service-unavailableCANCEL
407subscription-requiredAUTH
500undefined-conditionWAIT
400unexpected-conditionWAIT
408request-timeoutCANCEL

Author:
Matt Tucker

Nested Class Summary
static class XMPPError.Condition
          A class to represent predefined error conditions.
static class XMPPError.Type
          A class to represent the type of the Error.
 
Constructor Summary
XMPPError(int code)
          Deprecated. new errors should be created using the constructor XMPPError(condition)
XMPPError(int code, String message)
          Deprecated. new errors should be created using the constructor XMPPError(condition, message)
XMPPError(int code, XMPPError.Type type, String condition, String message, List<PacketExtension> extension)
          Creates a new error with the specified code, type, condition and message.
XMPPError(XMPPError.Condition condition)
          Creates a new error with the specified condition infering the type and code.
XMPPError(XMPPError.Condition condition, String messageText)
          Creates a new error with the specified condition and message infering the type and code.
 
Method Summary
 void addExtension(PacketExtension extension)
          Adds a packet extension to the error.
 int getCode()
          Returns the error code.
 String getCondition()
          Returns the error condition.
 PacketExtension getExtension(String elementName, String namespace)
          Returns the first patcket extension that matches the specified element name and namespace, or null if it doesn't exist.
 List<PacketExtension> getExtensions()
          Returns an Iterator for the error extensions attached to the xmppError.
 String getMessage()
          Returns the message describing the error, or null if there is no message.
 XMPPError.Type getType()
          Returns the error type.
 void setExtension(List<PacketExtension> extension)
          Set the packet extension to the error.
 String toString()
           
 String toXML()
          Returns the error as XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XMPPError

public XMPPError(XMPPError.Condition condition)
Creates a new error with the specified condition infering the type and code. If the Condition is predefined, client code should be like: new XMPPError(XMPPError.Condition.remote_server_timeout); If the Condition is not predefined, invocations should be like new XMPPError(new XMPPError.Condition("my_own_error"));

Parameters:
condition - the error condition.

XMPPError

public XMPPError(XMPPError.Condition condition,
                 String messageText)
Creates a new error with the specified condition and message infering the type and code. If the Condition is predefined, client code should be like: new XMPPError(XMPPError.Condition.remote_server_timeout, "Error Explanation"); If the Condition is not predefined, invocations should be like new XMPPError(new XMPPError.Condition("my_own_error"), "Error Explanation");

Parameters:
condition - the error condition.
messageText - a message describing the error.

XMPPError

public XMPPError(int code)
Deprecated. new errors should be created using the constructor XMPPError(condition)

Creates a new error with the specified code and no message.

Parameters:
code - the error code.

XMPPError

public XMPPError(int code,
                 String message)
Deprecated. new errors should be created using the constructor XMPPError(condition, message)

Creates a new error with the specified code and message. deprecated

Parameters:
code - the error code.
message - a message describing the error.

XMPPError

public XMPPError(int code,
                 XMPPError.Type type,
                 String condition,
                 String message,
                 List<PacketExtension> extension)
Creates a new error with the specified code, type, condition and message. This constructor is used when the condition is not recognized automatically by XMPPError i.e. there is not a defined instance of ErrorCondition or it does not applies the default specification.

Parameters:
code - the error code.
type - the error type.
condition - the error condition.
message - a message describing the error.
Method Detail

getCondition

public String getCondition()
Returns the error condition.

Returns:
the error condition.

getType

public XMPPError.Type getType()
Returns the error type.

Returns:
the error type.

getCode

public int getCode()
Returns the error code.

Returns:
the error code.

getMessage

public String getMessage()
Returns the message describing the error, or null if there is no message.

Returns:
the message describing the error, or null if there is no message.

toXML

public String toXML()
Returns the error as XML.

Returns:
the error as XML.

toString

public String toString()
Overrides:
toString in class Object

getExtensions

public List<PacketExtension> getExtensions()
Returns an Iterator for the error extensions attached to the xmppError. An application MAY provide application-specific error information by including a properly-namespaced child in the error element.

Returns:
an Iterator for the error extensions.

getExtension

public PacketExtension getExtension(String elementName,
                                    String namespace)
Returns the first patcket extension that matches the specified element name and namespace, or null if it doesn't exist.

Parameters:
elementName - the XML element name of the packet extension.
namespace - the XML element namespace of the packet extension.
Returns:
the extension, or null if it doesn't exist.

addExtension

public void addExtension(PacketExtension extension)
Adds a packet extension to the error.

Parameters:
extension - a packet extension.

setExtension

public void setExtension(List<PacketExtension> extension)
Set the packet extension to the error.

Parameters:
extension - a packet extension.

Smack

Copyright © 2003-2007 Jive Software.