当前位置: 首页>>代码示例>>Java>>正文


Java KXmlParser.getName方法代码示例

本文整理汇总了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;
            }
        }
    };
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:23,代码来源:ManageKeyRecordTask.java

示例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;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:36,代码来源:J2METransactionParserFactory.java

示例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();

    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:37,代码来源:DisplayFormsHttpState.java

示例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() + ">";
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:9,代码来源:InvalidStorageStructureException.java

示例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;
}
 
开发者ID:Ericsson-LMF,项目名称:IoT-Gateway,代码行数:29,代码来源:XmlParser.java

示例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() + ">";
    }
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:9,代码来源:InvalidStructureException.java

示例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;
}
 
开发者ID:dryganets,项目名称:vogar,代码行数:56,代码来源:XmlReportReader.java

示例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;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:50,代码来源:CommCareTransactionParserFactory.java

示例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;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:50,代码来源:FormRecordProcessor.java

示例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;
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:63,代码来源:CommCareTransactionParserFactory.java


注:本文中的org.kxml2.io.KXmlParser.getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。