本文整理汇总了Java中org.kxml2.io.KXmlParser.getAttributeValue方法的典型用法代码示例。如果您正苦于以下问题:Java KXmlParser.getAttributeValue方法的具体用法?Java KXmlParser.getAttributeValue怎么用?Java KXmlParser.getAttributeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kxml2.io.KXmlParser
的用法示例。
在下文中一共展示了KXmlParser.getAttributeValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAttributeMap
import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private Map<String, String> createAttributeMap(KXmlParser parser) {
Map<String, String> attributeMap = new HashMap<String, String>();
int attributeCount = parser.getAttributeCount();
for (int i = 0; i < attributeCount; i++) {
String attributeName = parser.getAttributeName(i);
String attributeValue = parser.getAttributeValue(i);
attributeMap.put(attributeName, attributeValue);
}
return attributeMap;
}
示例2: getParser
import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
@Override
public TransactionParser getParser(KXmlParser parser) {
String namespace = parser.getNamespace();
String name = parser.getName();
if("message".equalsIgnoreCase(name)) {
return new TransactionParser<String>(parser) {
String nature = parser.getAttributeValue(null, "nature");
public void commit(String parsed) throws IOException {
}
public String parse() throws InvalidStructureException,IOException, XmlPullParserException, UnfullfilledRequirementsException {
message = parser.nextText();
if(nature != null) {
if(message != null) {
messages.put(nature, message);
}
}
return message;
}
};
}
// check for super AFTER so that we default to overridden case
TransactionParser superParser = super.getParser(parser);
if(superParser != null){
return superParser;
}
return null;
}
示例3: processSurveyList
import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
public void processSurveyList(KXmlParser parser, Hashtable formInfo) throws XmlPullParserException{
try {
//boolean inItem = false;
parser.nextTag();
parser.require(XmlPullParser.START_TAG, null, "forms");
while( parser.nextTag() != XmlPullParser.END_TAG ){
//parser file names
parser.require(XmlPullParser.START_TAG, null, null);
String name = parser.getName();
String url = parser.getAttributeValue(null, "url");
String text = parser.nextText();
if(name.equals("form"))
{
//inItem = true;
//items.addElement(text);
formInfo.put(text, url);
}
else
//inItem = false;
parser.require(XmlPullParser.END_TAG, null, "form");
}
parser.require(XmlPullParser.END_TAG, null, "forms");
parser.next();
parser.require(XmlPullParser.END_DOCUMENT, null, null);
} catch (IOException e) {
// TODO: handle exception
System.out.println("XML parser error");
e.printStackTrace();
}
}
示例4: getParser
import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
@Override
public TransactionParser getParser(KXmlParser parser) {
String namespace = parser.getNamespace();
String name = parser.getName();
if (LedgerXmlParsers.STOCK_XML_NAMESPACE.equals(namespace)) {
if (stockParser == null) {
throw new RuntimeException("Couldn't process Stock transaction without initialization!");
}
req();
return stockParser.getParser(parser);
} else if ("case".equalsIgnoreCase(name)) {
if (caseParser == null) {
throw new RuntimeException("Couldn't receive Case transaction without initialization!");
}
req();
return caseParser.getParser(parser);
} else if ("registration".equalsIgnoreCase(name)) {
if (userParser == null) {
throw new RuntimeException("Couldn't receive User transaction without initialization!");
}
req();
return userParser.getParser(parser);
} else if (FixtureIndexSchemaParser.INDICE_SCHEMA.equalsIgnoreCase(name)) {
return new FixtureIndexSchemaParser(parser, fixtureSchemas, processedFixtures);
} else if ("fixture".equalsIgnoreCase(name)) {
String id = parser.getAttributeValue(null, "id");
String isIndexedAttr = parser.getAttributeValue(null, "indexed");
boolean isIndexed = "true".equals(isIndexedAttr);
req();
processedFixtures.add(id);
if (isIndexed) {
FixtureIndexSchema schema = fixtureSchemas.get(id);
return new IndexedFixtureXmlParser(parser, id, schema, sandbox);
} else {
return fixtureParser.getParser(parser);
}
} else if ("sync".equalsIgnoreCase(name) &&
"http://commcarehq.org/sync".equals(namespace)) {
return new TransactionParser<String>(parser) {
@Override
public void commit(String parsed) throws IOException {
}
@Override
public String parse() throws InvalidStructureException,
IOException, XmlPullParserException,
UnfullfilledRequirementsException {
this.checkNode("sync");
this.nextTag("restore_id");
String syncToken = parser.nextText();
if (syncToken == null) {
throw new InvalidStructureException("Sync block must contain restore_id with valid ID inside!", parser);
}
sandbox.setSyncToken(syncToken);
return syncToken;
}
};
}
return null;
}