Java 类org.jivesoftware.smackx.forward.packet.Forwarded 实例源码

项目:Smack    文件:CarbonManagerProvider.java   
@Override
public CarbonExtension parse(XmlPullParser parser, int initialDepth)
                throws SmackException, XmlPullParserException, IOException {
    Direction dir = Direction.valueOf(parser.getName());
    Forwarded fwd = null;

    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG && parser.getName().equals("forwarded")) {
            fwd = FORWARDED_PROVIDER.parse(parser);
        }
        else if (eventType == XmlPullParser.END_TAG && dir == Direction.valueOf(parser.getName()))
            done = true;
    }
    if (fwd == null)
        throw new SmackException("sent/received must contain exactly one <forwarded> tag");
    return new CarbonExtension(dir, fwd);
}
项目:Smack    文件:ForwardedProvider.java   
@Override
public Forwarded parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
    DelayInformation di = null;
    Stanza packet = null;

    outerloop: while (true) {
        int eventType = parser.next();
        switch (eventType) {
        case XmlPullParser.START_TAG:
            String name = parser.getName();
            String namespace = parser.getNamespace();
            switch (name) {
            case DelayInformation.ELEMENT:
                if (DelayInformation.NAMESPACE.equals(namespace)) {
                    di = DelayInformationProvider.INSTANCE.parse(parser, parser.getDepth());
                } else {
                    LOGGER.warning("Namespace '" + namespace + "' does not match expected namespace '"
                                    + DelayInformation.NAMESPACE + "'");
                }
                break;
            case Message.ELEMENT:
                packet = PacketParserUtils.parseMessage(parser);
                break;
            default:
                LOGGER.warning("Unsupported forwarded packet type: " + name);
            }
            break;
        case XmlPullParser.END_TAG:
            if (parser.getDepth() == initialDepth) {
                break outerloop;
            }
            break;
        }
    }

    if (packet == null)
        throw new SmackException("forwarded extension must contain a packet");
    return new Forwarded(di, packet);
}
项目:Smack    文件:CarbonExtension.java   
/**
 * Construct a Carbon message extension.
 * 
 * @param dir Determines if the carbon is being sent/received
 * @param fwd The forwarded message.
 */
public CarbonExtension(Direction dir, Forwarded fwd) {
    this.dir = dir;
    this.fwd = fwd;
}
项目:Smack    文件:CarbonExtension.java   
/**
 * Get the forwarded packet.
 *
 * @return the {@link Forwarded} message contained in this Carbon.
 */
public Forwarded getForwarded() {
    return fwd;
}