本文整理汇总了Java中org.kxml2.io.KXmlParser.getName方法的典型用法代码示例。如果您正苦于以下问题:Java KXmlParser.getName方法的具体用法?Java KXmlParser.getName怎么用?Java KXmlParser.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kxml2.io.KXmlParser
的用法示例。
在下文中一共展示了KXmlParser.getName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTransactionParserFactory
import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
@Override
protected TransactionParserFactory getTransactionParserFactory() {
return new TransactionParserFactory() {
@Override
public TransactionParser getParser(KXmlParser parser) {
String name = parser.getName();
if ("auth_keys".equals(name)) {
return new KeyRecordParser(parser, username, password) {
@Override
public void commit(ArrayList<UserKeyRecord> parsed) throws IOException {
ManageKeyRecordTask.this.keyRecords = parsed;
}
};
} else {
return null;
}
}
};
}
示例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: buildParserMessage
import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
public static String buildParserMessage(KXmlParser parser) {
String prefix = parser.getPrefix();
if (prefix != null) {
return ". Source: <" + prefix + ":" + parser.getName() + "> tag in namespace: " + parser.getNamespace();
} else {
return ". Source: <" + parser.getName() + ">";
}
}
示例5: _parse
import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
static XmlNode _parse(KXmlParser parser, boolean ignoreWhitespaces) throws Exception {
XmlNode node = new XmlNode();
if (parser.getEventType() != XmlPullParser.START_TAG) {
if (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
return node;
}
throw new Exception("Illegal XML state: " + parser.getName() + ", " + parser.getEventType());
} else {
node.name = parser.getName();
for (int i = 0; i < parser.getAttributeCount(); i++) {
node.attributes.put(parser.getAttributeName(i), parser.getAttributeValue(i));
}
parser.next();
while (parser.getEventType() != XmlPullParser.END_TAG) {
if (parser.getEventType() == XmlPullParser.START_TAG) {
node.children.add(_parse(parser, ignoreWhitespaces));
} else if (parser.getEventType() == XmlPullParser.TEXT && !ignoreWhitespaces || !parser.isWhitespace()) {
node.text += parser.getText();
}
parser.next();
}
}
return node;
}
示例6: buildParserMessage
import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private static String buildParserMessage(KXmlParser parser) {
String prefix = parser.getPrefix();
if (prefix != null) {
return ". Source: <" + prefix + ":" + parser.getName() + "> tag in namespace: " + parser.getNamespace();
} else {
return ". Source: <" + parser.getName() + ">";
}
}
示例7: readTestSuite
import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private Collection<Outcome> readTestSuite(KXmlParser parser)
throws XmlPullParserException, IOException {
Collection<Outcome> outcomes = new ArrayList<Outcome>();
parser.nextTag();
parser.require(XmlPullParser.START_TAG, null, XmlReportConstants.TESTSUITE);
Map<String, String> testSuiteAttributes = createAttributeMap(parser);
String timestamp = testSuiteAttributes.get(XmlReportConstants.TIMESTAMP);
parser.nextTag();
parser.require(XmlPullParser.START_TAG, null, XmlReportConstants.PROPERTIES);
parser.nextTag();
parser.require(XmlPullParser.END_TAG, null, XmlReportConstants.PROPERTIES);
while (parser.nextTag() == XmlPullParser.START_TAG) {
parser.require(XmlPullParser.START_TAG, null, XmlReportConstants.TESTCASE);
Map<String, String> testCaseAttributes = createAttributeMap(parser);
String name = testCaseAttributes.get(XmlReportConstants.ATTR_NAME);
String classname = testCaseAttributes.get(XmlReportConstants.ATTR_CLASSNAME);
Result result = Result.SUCCESS;
String resultOutput = null;
parser.nextTag();
String tagName = parser.getName();
if (resultTagNames.contains(tagName)) {
parser.require(XmlPullParser.START_TAG, null, tagName);
Map<String, String> resultAttributes = createAttributeMap(parser);
String type = resultAttributes.get(XmlReportConstants.ATTR_TYPE);
result = Result.valueOf(type);
resultOutput = parser.nextText();
parser.require(XmlPullParser.END_TAG, null, tagName);
parser.nextTag();
}
// create outcome!
SimpleDateFormat dateFormat = new SimpleDateFormat(XmlReportConstants.DATEFORMAT);
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
dateFormat.setLenient(true);
Date date;
try {
date = dateFormat.parse(timestamp);
} catch (ParseException e) {
throw new RuntimeException(e);
}
outcomes.add(new Outcome(classname + "#" + name, result, resultOutput, date));
parser.require(XmlPullParser.END_TAG, null, XmlReportConstants.TESTCASE);
}
parser.require(XmlPullParser.END_TAG, null, XmlReportConstants.TESTSUITE);
return outcomes;
}
示例8: getParser
import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
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 ("fixture".equalsIgnoreCase(name)) {
req();
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;
}
示例9: process
import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
/**
* This is the entry point for processing a form. New transaction types
* should all be declared here.
*/
public FormRecord process(FormRecord record)
throws InvalidStructureException, IOException, XmlPullParserException,
UnfullfilledRequirementsException {
String form = record.getPath(c);
final File f = new File(form);
final Cipher decrypter =
FormUploadUtil.getDecryptCipher((new SecretKeySpec(record.getAesKey(), "AES")));
InputStream is = new CipherInputStream(new FileInputStream(f), decrypter);
AndroidTransactionParserFactory factory = new AndroidTransactionParserFactory(c, null) {
@Override
public TransactionParser getParser(KXmlParser parser) {
String namespace = parser.getNamespace();
String name = parser.getName();
if (LedgerXmlParsers.STOCK_XML_NAMESPACE.equals(namespace) || "case".equalsIgnoreCase(name)) {
return super.getParser(parser);
} else {
return null;
}
}
};
XmlFormRecordProcessor.process(is, factory);
//Let anyone who is listening know!
Intent i = new Intent("org.commcare.dalvik.api.action.data.update");
i.putStringArrayListExtra("cases", factory.getCreatedAndUpdatedCases());
c.sendBroadcast(i, "org.commcare.dalvik.provider.cases.read");
//Update the record before trying to purge, so we don't block on this, in case
//anything weird happens. We don't want to get into a loop
FormRecord updatedRecord = updateRecordStatus(record, FormRecord.STATUS_UNSENT);
if(factory.wereCaseIndexesDisrupted()) {
if(isBulkProcessing) {
isPurgePending = true;
} else {
performPurge();
}
}
return updatedRecord;
}
示例10: 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;
}