use of org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer in project Smack by igniterealtime.
the class JingleFileTransferProvider method parse.
@Override
public JingleFileTransfer parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException, ParseException {
ArrayList<JingleContentDescriptionChildElement> payloads = new ArrayList<>();
JingleFileTransferChild.Builder builder = JingleFileTransferChild.getBuilder();
String elementName;
while (true) {
XmlPullParser.TagEvent tag = parser.nextTag();
switch(tag) {
case START_ELEMENT:
elementName = parser.getName();
switch(elementName) {
case JingleFileTransferChild.ELEM_DATE:
builder.setDate(XmppDateTime.parseXEP0082Date(parser.nextText()));
break;
case JingleFileTransferChild.ELEM_DESC:
builder.setDescription(parser.nextText());
break;
case JingleFileTransferChild.ELEM_MEDIA_TYPE:
builder.setMediaType(parser.nextText());
break;
case JingleFileTransferChild.ELEM_NAME:
builder.setName(parser.nextText());
break;
case JingleFileTransferChild.ELEM_SIZE:
builder.setSize(Integer.parseInt(parser.nextText()));
break;
case Range.ELEMENT:
Range range = parseRangeElement(parser);
builder.setRange(range);
break;
case HashElement.ELEMENT:
HashElement hashElement = HashElementProvider.INSTANCE.parse(parser);
builder.setHash(hashElement);
break;
}
break;
case END_ELEMENT:
elementName = parser.getName();
switch(elementName) {
case JingleFileTransferChild.ELEMENT:
payloads.add(builder.build());
builder = JingleFileTransferChild.getBuilder();
break;
case JingleContentDescription.ELEMENT:
return new JingleFileTransfer(payloads);
}
break;
}
}
}
Aggregations