use of org.jivesoftware.smack.xml.XmlPullParserException in project Smack by igniterealtime.
the class WebSocketRemoteConnectionEndpointLookup method lookup.
public static Result lookup(DomainBareJid domainBareJid) {
List<RemoteConnectionEndpointLookupFailure> lookupFailures = new ArrayList<>(1);
List<URI> rcUriList = null;
try {
// Look for remote connection endpoints by making use of http lookup method described inside XEP-0156.
rcUriList = HttpLookupMethod.lookup(domainBareJid, LinkRelation.WEBSOCKET);
} catch (IOException | XmlPullParserException | URISyntaxException e) {
lookupFailures.add(new RemoteConnectionEndpointLookupFailure.HttpLookupFailure(domainBareJid, e));
return new Result(lookupFailures);
}
List<SecureWebSocketRemoteConnectionEndpoint> discoveredSecureEndpoints = new ArrayList<>(rcUriList.size());
List<InsecureWebSocketRemoteConnectionEndpoint> discoveredInsecureEndpoints = new ArrayList<>(rcUriList.size());
for (URI webSocketUri : rcUriList) {
WebSocketRemoteConnectionEndpoint wsRce = WebSocketRemoteConnectionEndpoint.from(webSocketUri);
if (wsRce instanceof SecureWebSocketRemoteConnectionEndpoint) {
SecureWebSocketRemoteConnectionEndpoint secureWsRce = (SecureWebSocketRemoteConnectionEndpoint) wsRce;
discoveredSecureEndpoints.add(secureWsRce);
} else if (wsRce instanceof InsecureWebSocketRemoteConnectionEndpoint) {
InsecureWebSocketRemoteConnectionEndpoint insecureWsRce = (InsecureWebSocketRemoteConnectionEndpoint) wsRce;
discoveredInsecureEndpoints.add(insecureWsRce);
} else {
// WebSocketRemoteConnectionEndpoint.from() must return an instance which type is one of the above.
throw new AssertionError();
}
}
return new Result(discoveredSecureEndpoints, discoveredInsecureEndpoints, lookupFailures);
}
use of org.jivesoftware.smack.xml.XmlPullParserException in project Smack by igniterealtime.
the class Xpp3XmlPullParserFactory method newXmlPullParser.
@Override
public Xpp3XmlPullParser newXmlPullParser(Reader reader) throws XmlPullParserException {
org.xmlpull.v1.XmlPullParser xpp3XmlPullParser;
try {
xpp3XmlPullParser = XPP3_XML_PULL_PARSER_FACTORY.newPullParser();
xpp3XmlPullParser.setFeature(org.xmlpull.v1.XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
xpp3XmlPullParser.setInput(reader);
} catch (org.xmlpull.v1.XmlPullParserException e) {
throw new XmlPullParserException(e);
}
if (XML_PULL_PARSER_SUPPORTS_ROUNDTRIP) {
try {
xpp3XmlPullParser.setFeature(FEATURE_XML_ROUNDTRIP, true);
} catch (org.xmlpull.v1.XmlPullParserException e) {
LOGGER.log(Level.SEVERE, "XmlPullParser does not support XML_ROUNDTRIP, although it was first determined to be supported", e);
}
}
return new Xpp3XmlPullParser(xpp3XmlPullParser);
}
use of org.jivesoftware.smack.xml.XmlPullParserException in project Smack by igniterealtime.
the class StaxXmlPullParser method nextTag.
@Override
public TagEvent nextTag() throws IOException, XmlPullParserException {
preNextEvent();
int staxEventInt;
try {
staxEventInt = xmlStreamReader.nextTag();
} catch (XMLStreamException e) {
throw new XmlPullParserException(e);
}
switch(staxEventInt) {
case XMLStreamConstants.START_ELEMENT:
depth++;
return TagEvent.START_ELEMENT;
case XMLStreamConstants.END_ELEMENT:
delayedDepthDecrement = true;
return TagEvent.END_ELEMENT;
default:
throw new AssertionError();
}
}
use of org.jivesoftware.smack.xml.XmlPullParserException in project Smack by igniterealtime.
the class StaxXmlPullParser method next.
@Override
public Event next() throws XmlPullParserException {
preNextEvent();
int staxEventInt;
try {
staxEventInt = xmlStreamReader.next();
} catch (XMLStreamException e) {
throw new XmlPullParserException(e);
}
Event event = staxEventIntegerToEvent(staxEventInt);
switch(event) {
case START_ELEMENT:
depth++;
break;
case END_ELEMENT:
delayedDepthDecrement = true;
break;
default:
// Catch all for incomplete switch (MissingCasesInEnumSwitch) statement.
break;
}
return event;
}
use of org.jivesoftware.smack.xml.XmlPullParserException in project Smack by igniterealtime.
the class StaxXmlPullParser method nextText.
@Override
public String nextText() throws IOException, XmlPullParserException {
final String nextText;
try {
nextText = xmlStreamReader.getElementText();
} catch (XMLStreamException e) {
throw new XmlPullParserException(e);
}
// XMLStreamReader.getElementText() will forward to the next END_ELEMENT, hence we need to set
// delayedDepthDecrement to true.
delayedDepthDecrement = true;
return nextText;
}
Aggregations