/**
 *
 * Copyright © 2014 Florian Schmaus
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jivesoftware.smackx.delay.provider;

import java.util.Date;

import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.jivesoftware.smackx.delay.packet.DelayInformation;
import org.xmlpull.v1.XmlPullParser;

public abstract class AbstractDelayInformationProvider implements PacketExtensionProvider {

    @Override
    public final PacketExtension parseExtension(XmlPullParser parser) throws Exception {
        String stampString = (parser.getAttributeValue("", "stamp"));
        String from = parser.getAttributeValue("", "from");
        String reason = null;
        if (!parser.isEmptyElementTag()) {
            parser.next();
            assert(parser.getEventType() == XmlPullParser.TEXT);
            reason = parser.getText();
        }
        parser.next();
        assert(parser.getEventType() == XmlPullParser.END_TAG);
        Date stamp = parseDate(stampString);
        return new DelayInformation(stamp, from, reason);
    }

    protected abstract Date parseDate(String string) throws Exception;
}

@@ -1295,24 +1295,36 @@
 %0A           
+ int event =
  parser.next
@@ -1343,39 +1343,175 @@
     
-assert(parser.getEventType() ==
+switch (event) %7B%0A            case XmlPullParser.TEXT:%0A                reason = parser.getText();%0A                parser.next();%0A                break;%0A            case
  Xml
@@ -1525,15 +1525,21 @@
 ser.
-TEXT);%0A
+END_TAG:%0A    
     
@@ -1559,36 +1559,170 @@
 n = 
-parser.getText();%0A        %7D%0A
+%22%22;%0A                break;%0A            default:%0A                throw new IllegalStateException(%22Unexpected event: %22 + event);%0A            %7D%0A        %7D else %7B%0A    
     
@@ -1732,32 +1732,42 @@
  parser.next();%0A
+        %7D%0A
         assert(p

Make AbstractDelayInformationProvider handle empty string as reason