本文整理匯總了Java中org.xmlpull.v1.XmlPullParser.nextText方法的典型用法代碼示例。如果您正苦於以下問題:Java XmlPullParser.nextText方法的具體用法?Java XmlPullParser.nextText怎麽用?Java XmlPullParser.nextText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.xmlpull.v1.XmlPullParser
的用法示例。
在下文中一共展示了XmlPullParser.nextText方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: action
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void action( Dsmlv2Container container ) throws XmlPullParserException
{
ErrorResponse errorResponse = ( ErrorResponse ) container.getBatchResponse().getCurrentResponse();
XmlPullParser xpp = container.getParser();
try
{
String nextText = xpp.nextText();
if ( !Strings.isEmpty( nextText ) )
{
errorResponse.setMessage( nextText.trim() );
}
}
catch ( IOException ioe )
{
throw new XmlPullParserException( ioe.getMessage(), xpp, ioe );
}
}
示例2: parse
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
* xml解析為對象
*
* @param text
* @return
*/
public static GradleDependencyEntity parse(String text) {
GradleDependencyEntity entity = new GradleDependencyEntity();
XmlPullParserFactory f = null;
try {
f = XmlPullParserFactory.newInstance();
f.setNamespaceAware(true);
XmlPullParser xmlPullParser = f.newPullParser();
xmlPullParser.setInput(new InputStreamReader(new ByteArrayInputStream(text.getBytes())));
int eventType = xmlPullParser.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_DOCUMENT) {
} else if (eventType == XmlPullParser.START_TAG) {
String name = xmlPullParser.getName();
if (name.equals("groupId")) {
entity.setGroupId(xmlPullParser.nextText());
} else if (name.equals("artifactId")) {
entity.setArtifactId(xmlPullParser.nextText());
} else if (name.equals("version")) {
String version = xmlPullParser.nextText();
entity.setVersion(version);
} else if (name.equals("lastUpdated")) {
entity.setUpdateTime(xmlPullParser.nextText());
}
} else if (eventType == XmlPullParser.END_TAG) {
} else if (eventType == XmlPullParser.TEXT) {
}
eventType = xmlPullParser.next();
}
} catch (Exception e) {
e.printStackTrace();
}
return entity;
}
示例3: action
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void action( Dsmlv2Container container ) throws XmlPullParserException
{
CompareRequest compareRequest = ( CompareRequest ) container.getBatchRequest().getCurrentRequest();
XmlPullParser xpp = container.getParser();
try
{
// We have to catch the type Attribute Value before going to the next Text node
String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
// Getting the value
String nextText = xpp.nextText();
if ( !Strings.isEmpty( nextText ) )
{
if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
{
compareRequest.setAssertionValue( Base64.decode( nextText.trim().toCharArray() ) );
}
else
{
compareRequest.setAssertionValue( nextText.trim() );
}
}
}
catch ( IOException ioe )
{
throw new XmlPullParserException( I18n.err( I18n.ERR_03008, ioe.getMessage() ), xpp, ioe );
}
}
示例4: nextText
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
public static String nextText(XmlPullParser var0, String var1, String var2) throws IOException, XmlPullParserException {
if(var2 == null) {
throw new XmlPullParserException("name for element can not be null");
} else {
var0.require(2, var1, var2);
return var0.nextText();
}
}
示例5: parserSimples
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
public static List<String> parserSimples(String rssFeed) throws XmlPullParserException, IOException {
// pegando instancia da XmlPullParserFactory [singleton]
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
// criando novo objeto do tipo XmlPullParser
XmlPullParser parser = factory.newPullParser();
// Definindo a entrada do nosso parser - argumento passado como parametro
parser.setInput(new StringReader(rssFeed));
// Definindo retorno
List<String> items = new ArrayList<String>();
while (parser.next() != XmlPullParser.END_DOCUMENT) {
if (parser.getEventType() == XmlPullParser.START_TAG) {
String tag = parser.getName();
//delimitando que estamos apenas interessados em tags <item>
if (tag.equals("item")) {
String title = "";
while (parser.next() != XmlPullParser.END_TAG) {
if (parser.getEventType() == XmlPullParser.START_TAG) {
String tagAberta = parser.getName();
//pegando as tags <title>
if (tagAberta.equals("title")) {
title = parser.nextText();
items.add(title);
} else {
parser.next();
}
parser.nextTag();
}
}
}
}
}
return items;
}
示例6: process
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
* Be called when parser has found 'layout' node at a time
*/
@Override
public void process(XmlPullParser parser) throws XmlPullParserException, IOException {
int attributesCount = parser.getAttributeCount();
String attributeName, attributeValue;
// Iterate attributes!
for (int i = 0; i < attributesCount; ++i) {
attributeName = parser.getAttributeName(i);
attributeValue = parser.getAttributeValue(i);
// The 'name' attribute is as a layout code of each layout's class
if ( "name".equals(attributeName)) {
// Skip if attribute value is null or empty
if ( attributeValue == null || attributeValue.length() == 0 ) {
continue;
}
// Get layout's class name
String clazzName = parser.nextText();
// Insert new class name
layoutClazzNameMap.put(attributeValue, clazzName);
// Do 'break' because nextText() method has been called
break;
}
}
}
示例7: parseExtension
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
@Override
public PacketExtension parseExtension(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException {
IgnoredMsgXmpp ignoredMsg = null;
boolean stop = false;
String xmlName = null;
int evtType;
while (!stop){
evtType = parser.getEventType();
xmlName = parser.getName();
switch (evtType){
case XmlPullParser.START_TAG:
if ("sdk_version".equals(xmlName)){
String actionText = parser.nextText();
ignoredMsg = new IgnoredMsgXmpp();
ignoredMsg.setSdkversion(actionText);
}
break;
case XmlPullParser.END_TAG:
if(xmlName.equals("sdk_version")){
stop = true;
}
break;
}
}
return ignoredMsg;
}
示例8: createAndAddControlValue
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
* Creates a Control Value parsing the current node and adds it to the given parent
* @param container the DSMLv2Container
* @param parent the parent
* @throws XmlPullParserException
*/
private void createAndAddControlValue( Dsmlv2Container container,
AbstractDsmlMessageDecorator<? extends Message> parent )
throws XmlPullParserException
{
DsmlControl<? extends Control> control = parent.getCurrentControl();
XmlPullParser xpp = container.getParser();
try
{
// We have to catch the type Attribute Value before going to the next Text node
String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
// Getting the value
String nextText = xpp.nextText();
if ( !Strings.isEmpty( nextText ) )
{
if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
{
control.setValue( Base64.decode( nextText.trim().toCharArray() ) );
}
else
{
control.setValue( Strings.getBytesUtf8( nextText.trim() ) );
}
}
}
catch ( IOException ioe )
{
throw new XmlPullParserException( I18n.err( I18n.ERR_03008, ioe.getMessage() ), xpp, ioe );
}
}
示例9: authenticate
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
* Authenticate.
*
* @param connection the connection
*/
private void authenticate(Connection connection)
{
connection.setSharedSecret(null);
connection.setSessionToken(null);
Request castRequest = createAuthenticatedSessionTokenRequest(sharedSecret);
accessor.send(castRequest, connection);
Response response = accessor.getResponse();
try
{
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(false);
XmlPullParser parser= factory.newPullParser();
parser.setInput(response.getInputStream(), "utf8");
XmlUtils.nextStartTag(parser, "response");
XmlUtils.nextStartTag(parser, "status");
XmlUtils.skipSubTree(parser);
XmlUtils.nextStartTag(parser, "wc:info");
//parser.require( XmlPullParser.START_TAG, PARENT_NAMESPACE, PARENT_NAME);
while( parser.nextTag() != XmlPullParser.END_DOCUMENT ) {
if ("shared-secret".equals(parser.getName())) {
sharedSecret = Base64.decodeBase64(parser.nextText().getBytes("UTF-8"));
break;
}
if ("token".equals(parser.getName())) {
sessionToken = parser.nextText();
}
}
}
catch(Exception e)
{
throw new HVSystemException("Failed to get token", e);
}
if (sessionToken == null)
{
throw new HVSystemException( "Application session token not found");
}
connection.setSessionToken(sessionToken);
connection.setSharedSecret(sharedSecret);
}
示例10: parseChannel
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private static XmlTvChannel parseChannel(XmlPullParser parser)
throws IOException, XmlPullParserException {
String id = null;
boolean repeatPrograms = false;
for (int i = 0; i < parser.getAttributeCount(); ++i) {
String attr = parser.getAttributeName(i);
String value = parser.getAttributeValue(i);
if (ATTR_ID.equalsIgnoreCase(attr)) {
id = value;
} else if (ATTR_REPEAT_PROGRAMS.equalsIgnoreCase(attr)) {
repeatPrograms = "TRUE".equalsIgnoreCase(value);
}
}
String displayName = null;
String displayNumber = null;
XmlTvIcon icon = null;
XmlTvAppLink appLink = null;
while (parser.next() != XmlPullParser.END_DOCUMENT) {
if (parser.getEventType() == XmlPullParser.START_TAG) {
if (TAG_DISPLAY_NAME.equalsIgnoreCase(parser.getName())
&& displayName == null) {
// TODO: support multiple display names.
displayName = parser.nextText();
} else if (TAG_DISPLAY_NUMBER.equalsIgnoreCase(parser.getName())
&& displayNumber == null) {
displayNumber = parser.nextText();
} else if (TAG_ICON.equalsIgnoreCase(parser.getName()) && icon == null) {
icon = parseIcon(parser);
} else if (TAG_APP_LINK.equalsIgnoreCase(parser.getName()) && appLink == null) {
appLink = parseAppLink(parser);
}
} else if (TAG_CHANNEL.equalsIgnoreCase(parser.getName())
&& parser.getEventType() == XmlPullParser.END_TAG) {
break;
}
}
if (TextUtils.isEmpty(id) || TextUtils.isEmpty(displayName)) {
throw new IllegalArgumentException("id and display-name can not be null.");
}
// Developers should assign original network ID in the right way not using the fake ID.
int fakeOriginalNetworkId = (displayNumber + displayName).hashCode();
return new XmlTvChannel(id, displayName, displayNumber, icon, appLink,
fakeOriginalNetworkId, 0, 0, repeatPrograms);
}
示例11: getMessageModel
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private MessageModel getMessageModel(Message message) {
long timestamp = 0;
String dialogId = "";
String messageId = message.getStanzaId();
XmlPullParser parser = Xml.newPullParser();
try {
parser.setInput(new StringReader(message.getExtension(
QuickbloxChatExtension.ELEMENT, QuickbloxChatExtension.NAMESPACE
).toXML().toString()));
while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
switch (parser.getEventType()) {
case XmlPullParser.START_TAG:
if (parser.getName().equals("date_sent")) {
timestamp = Long.valueOf(parser.nextText());
}
if (parser.getName().equals("dialog_id")) {
dialogId = parser.nextText();
}
if (message.getType() != Message.Type.chat && parser.getName().equals("message_id")) {
messageId = parser.nextText();
}
break;
default:
break;
}
parser.next();
}
} catch (XmlPullParserException | IOException ex) {
Logger.logExceptionToFabric(ex);
}
int recipientId = 0;
int senderId = 0;
int state = MessageState.DEFAULT;
if (message.getType() == Message.Type.chat) {
recipientId = Integer.valueOf(message.getTo().split("-")[0]);
senderId = Integer.valueOf(message.getFrom().split("-")[0]);
} else if (message.getType() == Message.Type.groupchat) {
senderId = Integer.valueOf(message.getFrom().split("/")[1]);
state = MessageState.DELIVERED;
EventBus.getDefault().post(new PublicMessageSentEvent(message.getStanzaId()));
}
MessageModel messageModel = new MessageModel(
messageId,
"",
"",
new ArrayList<>(),
new ArrayList<>(),
new ArrayList<>(),
dialogId,
timestamp,
message.getBody(),
recipientId,
senderId,
state);
return messageModel;
}
示例12: e
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
public static h e(XmlPullParser xmlPullParser) {
String attributeValue;
String attributeValue2;
String str = "urn:ietf:params:xml:ns:xmpp-stanzas";
List arrayList = new ArrayList();
String str2 = null;
String str3 = null;
String str4 = "-1";
int i = 0;
while (i < xmlPullParser.getAttributeCount()) {
attributeValue = xmlPullParser.getAttributeName(i).equals("code") ? xmlPullParser
.getAttributeValue("", "code") : str4;
attributeValue2 = xmlPullParser.getAttributeName(i).equals("type") ? xmlPullParser
.getAttributeValue("", "type") : str3;
if (xmlPullParser.getAttributeName(i).equals("reason")) {
str2 = xmlPullParser.getAttributeValue("", "reason");
}
i++;
str3 = attributeValue2;
str4 = attributeValue;
}
Object obj = null;
attributeValue2 = null;
attributeValue = null;
while (obj == null) {
int next = xmlPullParser.next();
if (next == 2) {
if (xmlPullParser.getName().equals("text")) {
attributeValue = xmlPullParser.nextText();
} else {
String name = xmlPullParser.getName();
String namespace = xmlPullParser.getNamespace();
if ("urn:ietf:params:xml:ns:xmpp-stanzas".equals(namespace)) {
attributeValue2 = name;
} else {
arrayList.add(a(name, namespace, xmlPullParser));
}
}
} else if (next == 3) {
if (xmlPullParser.getName().equals("error")) {
obj = 1;
}
} else if (next == 4) {
attributeValue = xmlPullParser.getText();
}
}
return new h(Integer.parseInt(str4), str3 == null ? "cancel" : str3, str2,
attributeValue2, attributeValue, arrayList);
}
示例13: parseMediaPresentationDescription
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
protected MediaPresentationDescription parseMediaPresentationDescription(XmlPullParser xpp,
String baseUrl) throws XmlPullParserException, IOException, ParseException {
long availabilityStartTime = parseDateTime(xpp, "availabilityStartTime", -1);
long durationMs = parseDuration(xpp, "mediaPresentationDuration", -1);
long minBufferTimeMs = parseDuration(xpp, "minBufferTime", -1);
String typeString = xpp.getAttributeValue(null, "type");
boolean dynamic = (typeString != null) ? typeString.equals("dynamic") : false;
long minUpdateTimeMs = (dynamic) ? parseDuration(xpp, "minimumUpdatePeriod", -1) : -1;
long timeShiftBufferDepthMs = (dynamic) ? parseDuration(xpp, "timeShiftBufferDepth", -1) : -1;
UtcTimingElement utcTiming = null;
String location = null;
List<Period> periods = new ArrayList<>();
long nextPeriodStartMs = dynamic ? -1 : 0;
boolean seenEarlyAccessPeriod = false;
boolean seenFirstBaseUrl = false;
do {
xpp.next();
if (ParserUtil.isStartTag(xpp, "BaseURL")) {
if (!seenFirstBaseUrl) {
baseUrl = parseBaseUrl(xpp, baseUrl);
seenFirstBaseUrl = true;
}
} else if (ParserUtil.isStartTag(xpp, "UTCTiming")) {
utcTiming = parseUtcTiming(xpp);
} else if (ParserUtil.isStartTag(xpp, "Location")) {
location = xpp.nextText();
} else if (ParserUtil.isStartTag(xpp, "Period") && !seenEarlyAccessPeriod) {
Pair<Period, Long> periodWithDurationMs = parsePeriod(xpp, baseUrl, nextPeriodStartMs);
Period period = periodWithDurationMs.first;
if (period.startMs == -1) {
if (dynamic) {
// This is an early access period. Ignore it. All subsequent periods must also be
// early access.
seenEarlyAccessPeriod = true;
} else {
throw new ParserException("Unable to determine start of period " + periods.size());
}
} else {
long periodDurationMs = periodWithDurationMs.second;
nextPeriodStartMs = periodDurationMs == -1 ? -1 : period.startMs + periodDurationMs;
periods.add(period);
}
}
} while (!ParserUtil.isEndTag(xpp, "MPD"));
if (durationMs == -1) {
if (nextPeriodStartMs != -1) {
// If we know the end time of the final period, we can use it as the duration.
durationMs = nextPeriodStartMs;
} else if (!dynamic) {
throw new ParserException("Unable to determine duration of static manifest.");
}
}
if (periods.isEmpty()) {
throw new ParserException("No periods found.");
}
return buildMediaPresentationDescription(availabilityStartTime, durationMs, minBufferTimeMs,
dynamic, minUpdateTimeMs, timeShiftBufferDepthMs, utcTiming, location, periods);
}
示例14: nextText
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
* Next text.
*
* @param parser the parser
* @param namespace the namespace
* @param name the name
*
* @return the string
*
* @throws IOException Signals that an I/O exception has occurred.
* @throws XmlPullParserException the xml pull parser exception
*/
public static String nextText(XmlPullParser parser, String namespace, String name)
throws IOException, XmlPullParserException
{
if (name == null) {
throw new XmlPullParserException("name for element can not be null");
}
parser.require(XmlPullParser.START_TAG, namespace, name);
return parser.nextText();
}