ParsingExceptionCallback.java

  1. /**
  2.  *
  3.  * Copyright 2013 Florian Schmaus.
  4.  *
  5.  * Licensed under the Apache License, Version 2.0 (the "License");
  6.  * you may not use this file except in compliance with the License.
  7.  * You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.jivesoftware.smack.parsing;

  18. /**
  19.  * Base class to receive parsing exceptions.
  20.  *
  21.  * If this class is used as callback, then Smack will silently ignore the stanza that caused the parsing exception and
  22.  * place the parser after the faulty stanza.
  23.  *
  24.  * Subclasses may or may not override certain methods of this class. Each of these methods will receive the exception
  25.  * that caused the parsing error and an instance of an Unparsed Packet type. The latter can be used to inspect the
  26.  * stanza that caused the parsing error by using the getContent() (for example {@link UnparsablePacket#getContent()})
  27.  * method.
  28.  *
  29.  * Smack provides 2 predefined ParsingExceptionCallback's: {@link ExceptionLoggingCallback} and {@link ExceptionThrowingCallback}.
  30.  *
  31.  * @author Florian Schmaus
  32.  *
  33.  */
  34. public abstract class ParsingExceptionCallback {

  35.     /**
  36.      * Called when parsing an message stanza caused an exception.
  37.      *
  38.      * @param stanzaData
  39.      * the raw message stanza data that caused the exception
  40.      * @throws Exception
  41.      */
  42.     public void handleUnparsablePacket(UnparsablePacket stanzaData) throws Exception {
  43.     }
  44. }