本文整理汇总了Java中org.jivesoftware.smack.util.PacketParserUtils.newXmppParser方法的典型用法代码示例。如果您正苦于以下问题:Java PacketParserUtils.newXmppParser方法的具体用法?Java PacketParserUtils.newXmppParser怎么用?Java PacketParserUtils.newXmppParser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.util.PacketParserUtils
的用法示例。
在下文中一共展示了PacketParserUtils.newXmppParser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openStream
import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
/**
* Resets the parser using the latest connection's reader. Reseting the parser is necessary
* when the plain connection has been secured or when a new opening stream element is going
* to be sent by the server.
*
* @throws SmackException if the parser could not be reset.
*/
void openStream() throws SmackException {
// If possible, provide the receiving entity of the stream open tag, i.e. the server, as much information as
// possible. The 'to' attribute is *always* available. The 'from' attribute if set by the user and no external
// mechanism is used to determine the local entity (user). And the 'id' attribute is available after the first
// response from the server (see e.g. RFC 6120 § 9.1.1 Step 2.)
CharSequence to = getServiceName();
CharSequence from = null;
CharSequence localpart = config.getUsername();
if (localpart != null) {
from = XmppStringUtils.completeJidFrom(localpart, to);
}
String id = getStreamId();
// 发送一个SteamOpen
send(new StreamOpen(to, from, id));
try {
packetReader.parser = PacketParserUtils.newXmppParser(reader);
}
catch (XmlPullParserException e) {
throw new SmackException(e);
}
}
示例2: openStream
import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
/**
* Resets the parser using the latest connection's reader. Reseting the parser is necessary
* when the plain connection has been secured or when a new opening stream element is going
* to be sent by the server.
*
* @throws SmackException if the parser could not be reset.
* @throws InterruptedException
*/
void openStream() throws SmackException, InterruptedException {
// If possible, provide the receiving entity of the stream open tag, i.e. the server, as much information as
// possible. The 'to' attribute is *always* available. The 'from' attribute if set by the user and no external
// mechanism is used to determine the local entity (user). And the 'id' attribute is available after the first
// response from the server (see e.g. RFC 6120 § 9.1.1 Step 2.)
CharSequence to = getXMPPServiceDomain();
CharSequence from = null;
CharSequence localpart = config.getUsername();
if (localpart != null) {
from = XmppStringUtils.completeJidFrom(localpart, to);
}
String id = getStreamId();
sendNonza(new StreamOpen(to, from, id));
try {
packetReader.parser = PacketParserUtils.newXmppParser(reader);
}
catch (XmlPullParserException e) {
throw new SmackException(e);
}
}
示例3: parsesWell
import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@Test
public void parsesWell() throws IOException, XmlPullParserException {
XmlPullParser parser = PacketParserUtils.newXmppParser();
parser.setInput(getClass().getResourceAsStream(XHTML_EXTENSION_SAMPLE_RESOURCE_NAME), "UTF-8");
parser.next();
XHTMLExtensionProvider provider = new XHTMLExtensionProvider();
ExtensionElement extension = provider.parse(parser, parser.getDepth());
assertThat(extension, instanceOf(XHTMLExtension.class));
XHTMLExtension attachmentsInfo = (XHTMLExtension) extension;
assertThat(sampleXhtml(), equalsCharSequence(attachmentsInfo.getBodies().get(0)));
}
示例4: testLayoutFromFile
import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@Test
public void testLayoutFromFile() throws XmlPullParserException, IOException, SmackException {
DataFormProvider pr = new DataFormProvider();
XmlPullParser parser = PacketParserUtils.newXmppParser();
parser.setInput(new InputStreamReader(this.getClass().getResourceAsStream(TEST_INPUT_1), "UTF-8"));
parser.next();
DataForm form = pr.parse(parser);
assertNotNull( form);
assertEquals(1 , form.getExtensionElements().size());
DataLayout layout = (DataLayout) form.getExtensionElements().get(0);
assertEquals(5 , layout.getPageLayout().size());
assertEquals("Label - & \u00E9 \u00E1 ", layout.getLabel());
Section section = (Section) layout.getPageLayout().get(1);
assertEquals("section Label - & \u00E9 \u00E1 ", section.getLabel());
Text text = (Text)layout.getPageLayout().get(2);
assertEquals("PageText - & \u00E9 \u00E1 ", text.getText());
section = (Section) layout.getPageLayout().get(3);
assertEquals("<html>Number of Persons by<br/> Nationality and Status</html>", section.getLabel());
text = (Text) layout.getPageLayout().get(4);
assertEquals("<html><font color='red'><em>DO NOT DELAY</em></font><br/>supply further information</html>", text.getText());
assertNotNull( layout.toXML());
String output = layout.toXML().toString();
assertEquals(TEST_OUTPUT_SPECIAL, output);
}