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


Java KXmlParser.getNamespace方法代码示例

本文整理汇总了Java中org.kxml2.io.KXmlParser.getNamespace方法的典型用法代码示例。如果您正苦于以下问题:Java KXmlParser.getNamespace方法的具体用法?Java KXmlParser.getNamespace怎么用?Java KXmlParser.getNamespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.kxml2.io.KXmlParser的用法示例。


在下文中一共展示了KXmlParser.getNamespace方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: getParser

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
@Override
public TransactionParser getParser(KXmlParser parser) {
    String namespace = parser.getNamespace();
    if (namespace != null && formInstanceNamespaces != null && formInstanceNamespaces.containsKey(namespace)) {
        req();
        return formInstanceParser.getParser(parser);
    }
    return super.getParser(parser);
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:10,代码来源:AndroidTransactionParserFactory.java

示例4: 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

示例5: 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

示例6: 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

示例7: getFactory

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
/**
 * Get a form instance and case enabled parsing factory
 */
private static TransactionParserFactory getFactory(final SQLiteDatabase db, final boolean bulkProcessingEnabled) {
    final Hashtable<String, String> formInstanceNamespaces;
    if (CommCareApplication.instance().getCurrentApp() != null) {
        formInstanceNamespaces = FormSaveUtil.getNamespaceToFilePathMap(CommCareApplication.instance());
    } else {
        formInstanceNamespaces = null;
    }
    return new TransactionParserFactory() {
        @Override
        public TransactionParser getParser(KXmlParser parser) {
            String namespace = parser.getNamespace();
            if (namespace != null && formInstanceNamespaces != null && formInstanceNamespaces.containsKey(namespace)) {
                return new FormInstanceXmlParser(parser, CommCareApplication.instance(),
                        Collections.unmodifiableMap(formInstanceNamespaces),
                        CommCareApplication.instance().getCurrentApp().fsPath(GlobalConstants.FILE_CC_FORMS));
            } else if (CaseXmlParser.CASE_XML_NAMESPACE.equals(parser.getNamespace()) && "case".equalsIgnoreCase(parser.getName())) {

                //Note - this isn't even actually bulk processing. since this class is static
                //there's no good lifecycle to manage the bulk processor in, but at least
                //this will validate that the bulk processor works.
                EntityStorageCache entityStorageCache = null;

                if (CommCareApplication.instance().getCurrentApp() != null) {
                    entityStorageCache = new EntityStorageCache("case", db, AppUtils.getCurrentAppId());
                }

                if (bulkProcessingEnabled) {
                    return new AndroidBulkCaseXmlParser(parser, getCaseStorage(db), entityStorageCache, new AndroidCaseIndexTable(db)) {
                        @Override
                        protected SQLiteDatabase getDbHandle() {
                            return db;
                        }
                    };

                } else {
                    return new AndroidCaseXmlParser(parser, getCaseStorage(db), entityStorageCache, new AndroidCaseIndexTable(db)) {
                        @Override
                        protected SQLiteDatabase getDbHandle() {
                            return db;
                        }
                    };
                }


            } else if (LedgerXmlParsers.STOCK_XML_NAMESPACE.equals(namespace)) {
                return new LedgerXmlParsers(parser, getLedgerStorage(db));
            }
            return null;
        }
    };
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:55,代码来源:TestUtils.java

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