Search in sources :

Example 1 with XsiDataTypeParser

use of org.whole.lang.xsd.parsers.XsiDataTypeParser in project whole by wholeplatform.

the class XsdLanguageKit method getDataTypeParser.

@Override
public IDataTypeParser getDataTypeParser(DataTypeParsers kind) {
    if (dataTypeParser == null) {
        IMappingStrategy mappingStrategy = MappingStrategyRegistry.instance().getMappingStrategy(getURI());
        if (mappingStrategy == null)
            return super.getDataTypeParser(kind);
        dataTypeParser = new XsiDataTypeParser(mappingStrategy.getDataTypeParsers());
    }
    return dataTypeParser;
}
Also used : IMappingStrategy(org.whole.lang.xsd.codebase.IMappingStrategy) XsiDataTypeParser(org.whole.lang.xsd.parsers.XsiDataTypeParser)

Example 2 with XsiDataTypeParser

use of org.whole.lang.xsd.parsers.XsiDataTypeParser in project whole by wholeplatform.

the class SchemaHelpers method deploySchemaOperations.

public static void deploySchemaOperations(final String languageUri) {
    ILanguageKit lk = ReflectionFactory.getLanguageKit(languageUri, false, null);
    if (!lk.isDynamic())
        return;
    // configure data-type parsers
    IMappingStrategy mappingStrategy = MappingStrategyRegistry.instance().getMappingStrategy(languageUri);
    IDataTypeParser parser = new XsiDataTypeParser(mappingStrategy.getDataTypeParsers());
    DynamicLanguageKit languageKit = (DynamicLanguageKit) lk;
    languageKit.setDataTypeParser(DataTypeParsers.PERSISTENCE, parser);
    languageKit.setDataTypeParser(DataTypeParsers.PRESENTATION, parser);
    // deploy a generic pretty print
    ReflectionFactory.deploy(new AbstractLanguageExtensionDeployer() {

        public void deploy(ReflectionFactory platform) {
            platform.addOperationFactory(languageUri, PrettyPrinterOperation.ID, new IVisitorFactory() {

                public IVisitor create(IOperation operation, int stage) {
                    return new XsiPrettyPrinterVisitor();
                }
            });
        }
    });
}
Also used : IOperation(org.whole.lang.operations.IOperation) IMappingStrategy(org.whole.lang.xsd.codebase.IMappingStrategy) DynamicLanguageKit(org.whole.lang.reflect.DynamicLanguageKit) ReflectionFactory(org.whole.lang.reflect.ReflectionFactory) XsiDataTypeParser(org.whole.lang.xsd.parsers.XsiDataTypeParser) AbstractLanguageExtensionDeployer(org.whole.lang.reflect.AbstractLanguageExtensionDeployer) XsiPrettyPrinterVisitor(org.whole.lang.xsd.visitors.XsiPrettyPrinterVisitor) IDataTypeParser(org.whole.lang.parsers.IDataTypeParser) IVisitorFactory(org.whole.lang.visitors.IVisitorFactory) ILanguageKit(org.whole.lang.reflect.ILanguageKit)

Aggregations

IMappingStrategy (org.whole.lang.xsd.codebase.IMappingStrategy)2 XsiDataTypeParser (org.whole.lang.xsd.parsers.XsiDataTypeParser)2 IOperation (org.whole.lang.operations.IOperation)1 IDataTypeParser (org.whole.lang.parsers.IDataTypeParser)1 AbstractLanguageExtensionDeployer (org.whole.lang.reflect.AbstractLanguageExtensionDeployer)1 DynamicLanguageKit (org.whole.lang.reflect.DynamicLanguageKit)1 ILanguageKit (org.whole.lang.reflect.ILanguageKit)1 ReflectionFactory (org.whole.lang.reflect.ReflectionFactory)1 IVisitorFactory (org.whole.lang.visitors.IVisitorFactory)1 XsiPrettyPrinterVisitor (org.whole.lang.xsd.visitors.XsiPrettyPrinterVisitor)1