mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-12-08 14:11:07 +01:00
Use CharSequence instead of String in parseContent()
and parseContentDepth(). This also means that the type of some fields changed from String to CharSequence. Also add Matcher for CharSequences.
This commit is contained in:
parent
54b18e3575
commit
f671b9e781
10 changed files with 80 additions and 34 deletions
|
|
@ -25,10 +25,10 @@ package org.jivesoftware.smack.parsing;
|
|||
*
|
||||
*/
|
||||
public class UnparsablePacket {
|
||||
private final String content;
|
||||
private final CharSequence content;
|
||||
private final Exception e;
|
||||
|
||||
public UnparsablePacket(final String content, final Exception e) {
|
||||
public UnparsablePacket(final CharSequence content, final Exception e) {
|
||||
this.content = content;
|
||||
this.e = e;
|
||||
}
|
||||
|
|
@ -46,7 +46,7 @@ public class UnparsablePacket {
|
|||
*
|
||||
* @return the raw stanza data
|
||||
*/
|
||||
public String getContent() {
|
||||
public CharSequence getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -288,13 +288,13 @@ public class PacketParserUtils {
|
|||
* @throws XmlPullParserException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String parseElement(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
public static CharSequence parseElement(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
assert(parser.getEventType() == XmlPullParser.START_TAG);
|
||||
return parseContentDepth(parser, parser.getDepth());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the content of a element as string.
|
||||
* Returns the content of a element.
|
||||
* <p>
|
||||
* The parser must be positioned on the START_TAG of the element which content is going to get
|
||||
* returned. If the current element is the empty element, then the empty string is returned. If
|
||||
|
|
@ -305,11 +305,11 @@ public class PacketParserUtils {
|
|||
* Note that only the outermost namespace attributes ("xmlns") will be returned, not nested ones.
|
||||
*
|
||||
* @param parser the XML pull parser
|
||||
* @return the content of a tag as string
|
||||
* @return the content of a tag
|
||||
* @throws XmlPullParserException if parser encounters invalid XML
|
||||
* @throws IOException if an IO error occurs
|
||||
*/
|
||||
public static String parseContent(XmlPullParser parser)
|
||||
public static CharSequence parseContent(XmlPullParser parser)
|
||||
throws XmlPullParserException, IOException {
|
||||
assert(parser.getEventType() == XmlPullParser.START_TAG);
|
||||
if (parser.isEmptyElementTag()) {
|
||||
|
|
@ -338,7 +338,7 @@ public class PacketParserUtils {
|
|||
* @throws XmlPullParserException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String parseContentDepth(XmlPullParser parser, int depth) throws XmlPullParserException, IOException {
|
||||
public static CharSequence parseContentDepth(XmlPullParser parser, int depth) throws XmlPullParserException, IOException {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
int event = parser.getEventType();
|
||||
boolean isEmptyElement = false;
|
||||
|
|
@ -389,7 +389,7 @@ public class PacketParserUtils {
|
|||
}
|
||||
event = parser.next();
|
||||
}
|
||||
return xml.toString();
|
||||
return xml;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -995,15 +995,15 @@ public class PacketParserUtils {
|
|||
*
|
||||
*/
|
||||
public static class UnparsedResultIQ extends IQ {
|
||||
public UnparsedResultIQ(String content) {
|
||||
this.str = content;
|
||||
public UnparsedResultIQ(CharSequence content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
private final String str;
|
||||
private final CharSequence content;
|
||||
|
||||
@Override
|
||||
public String getChildElementXML() {
|
||||
return this.str;
|
||||
public CharSequence getChildElementXML() {
|
||||
return this.content;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue