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


Java ResourceLoader类代码示例

本文整理汇总了Java中com.espertech.esper.util.ResourceLoader的典型用法代码示例。如果您正苦于以下问题:Java ResourceLoader类的具体用法?Java ResourceLoader怎么用?Java ResourceLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testEvent

import com.espertech.esper.util.ResourceLoader; //导入依赖的package包/类
public void testEvent() throws Exception {
    //URL url = ResourceLoader.resolveClassPathOrURLResource("schema", "regression/typeTestSchema.xsd");
    URL url = ResourceLoader.resolveClassPathOrURLResource("schema", "regression/simpleSchema.xsd", this.getClass().getClassLoader());
    String uri = url.toURI().toString();

    DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
    registry.addSource(new DOMXSImplementationSourceImpl());
    XSImplementation impl = (XSImplementation) registry.getDOMImplementation("XS-Loader");
    XSLoader schemaLoader = impl.createXSLoader(null);
    XSModel xsModel = schemaLoader.loadURI(uri);

    XSNamedMap elements = xsModel.getComponents(XSConstants.ELEMENT_DECLARATION);
    for (int i = 0; i < elements.getLength(); i++) {
        XSObject object = elements.item(i);
        //System.out.println("name '" + object.getName() + "' namespace '" + object.getNamespace());
    }

    XSElementDeclaration dec = (XSElementDeclaration) elements.item(0);

    XSComplexTypeDefinition complexActualElement = (XSComplexTypeDefinition) dec.getTypeDefinition();
    printSchemaDef(complexActualElement, 2);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:23,代码来源:TestXSDSchemaMapper.java

示例2: testEvent

import com.espertech.esper.util.ResourceLoader; //导入依赖的package包/类
public void testEvent() throws Exception
{
    //URL url = ResourceLoader.resolveClassPathOrURLResource("schema", "regression/typeTestSchema.xsd");
    URL url = ResourceLoader.resolveClassPathOrURLResource("schema", "regression/simpleSchema.xsd");
    String uri = url.toURI().toString();

    DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
    registry.addSource(new DOMXSImplementationSourceImpl());
    XSImplementation impl =(XSImplementation) registry.getDOMImplementation("XS-Loader");
    XSLoader schemaLoader = impl.createXSLoader(null);
    XSModel xsModel = schemaLoader.loadURI(uri);

    XSNamedMap elements = xsModel.getComponents(XSConstants.ELEMENT_DECLARATION);
    for (int i = 0; i < elements.getLength(); i++)
    {
        XSObject object = elements.item(i);
        //System.out.println("name '" + object.getName() + "' namespace '" + object.getNamespace());
    }

    XSElementDeclaration dec = (XSElementDeclaration) elements.item(0);

    XSComplexTypeDefinition complexActualElement = (XSComplexTypeDefinition) dec.getTypeDefinition();
    printSchemaDef(complexActualElement, 2);
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:25,代码来源:TestXSDSchemaMapper.java

示例3: testExtendedElements

import com.espertech.esper.util.ResourceLoader; //导入依赖的package包/类
public void testExtendedElements() throws Exception {
    URL url = ResourceLoader.resolveClassPathOrURLResource("schema", "regression/schemaWithExtensions.xsd", this.getClass().getClassLoader());
    String schemaUri = url.toURI().toString();
    SchemaModel model = XSDSchemaMapper.loadAndMap(schemaUri, null, SupportEngineImportServiceFactory.make());

    SchemaElementComplex complexEvent = model.getComponents().get(0);
    verifyComplexElement(complexEvent, "complexEvent", XSSimpleType.COMPLEX_TYPE, false);
    verifySizes(complexEvent, 0, 0, 1);

    SchemaElementComplex mainElement = complexEvent.getChildren().get(0);
    verifyComplexElement(mainElement, "mainElement", XSSimpleType.COMPLEX_TYPE, false);
    verifySizes(mainElement, 0, 0, 4);

    SchemaElementComplex baseType4 = mainElement.getChildren().get(0);
    verifyComplexElement(baseType4, "baseType4", XSSimpleType.COMPLEX_TYPE, false);
    verifySizes(baseType4, 0, 0, 0);

    SchemaElementComplex aType2 = mainElement.getChildren().get(1);
    verifyComplexElement(aType2, "aType2", XSSimpleType.COMPLEX_TYPE, false);
    verifySizes(aType2, 0, 2, 1);

    SchemaElementComplex aType3 = mainElement.getChildren().get(2);
    verifyComplexElement(aType3, "aType3", XSSimpleType.COMPLEX_TYPE, false);
    verifySizes(aType3, 0, 1, 2);

    SchemaElementComplex aType3baseType4 = aType3.getChildren().get(0);
    verifyComplexElement(aType3baseType4, "baseType4", XSSimpleType.COMPLEX_TYPE, false);
    verifySizes(aType3baseType4, 0, 0, 0);

    SchemaElementComplex aType3type2 = aType3.getChildren().get(1);
    verifyComplexElement(aType3type2, "aType2", XSSimpleType.COMPLEX_TYPE, false);
    verifySizes(aType3type2, 0, 2, 1);

    SchemaElementComplex aType4 = mainElement.getChildren().get(3);
    verifyComplexElement(aType4, "aType4", XSSimpleType.COMPLEX_TYPE, false);
    verifySizes(aType4, 0, 0, 1);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:38,代码来源:TestXSDSchemaMapper.java

示例4: testMap

import com.espertech.esper.util.ResourceLoader; //导入依赖的package包/类
public void testMap() throws Exception {
    URL url = ResourceLoader.resolveClassPathOrURLResource("schema", "regression/simpleSchema.xsd", Thread.currentThread().getContextClassLoader());
    String schemaUri = url.toURI().toString();

    SchemaModel model = XSDSchemaMapper.loadAndMap(schemaUri, null, SupportEngineImportServiceFactory.make());
    assertEquals(1, model.getComponents().size());

    SchemaElementComplex simpleEvent = model.getComponents().get(0);
    verifyComplexElement(simpleEvent, "simpleEvent", XSSimpleType.COMPLEX_TYPE, false);
    verifySizes(simpleEvent, 0, 0, 3);

    SchemaElementComplex nested1 = simpleEvent.getChildren().get(0);
    verifyComplexElement(nested1, "nested1", XSSimpleType.COMPLEX_TYPE, false);
    verifySizes(nested1, 1, 2, 1);
    assertEquals("attr1", nested1.getAttributes().get(0).getName());
    assertEquals(null, nested1.getAttributes().get(0).getNamespace());
    assertEquals(XSSimpleType.PRIMITIVE_STRING, nested1.getAttributes().get(0).getXsSimpleType());
    assertEquals("prop1", nested1.getSimpleElements().get(0).getName());
    assertEquals(XSSimpleType.PRIMITIVE_STRING, nested1.getSimpleElements().get(0).getXsSimpleType());
    assertEquals("prop2", nested1.getSimpleElements().get(1).getName());
    assertEquals(XSSimpleType.PRIMITIVE_BOOLEAN, nested1.getSimpleElements().get(1).getXsSimpleType());

    SchemaElementComplex nested2 = nested1.getChildren().get(0);
    verifyComplexElement(nested2, "nested2", XSSimpleType.COMPLEX_TYPE, false);
    verifySizes(nested2, 0, 1, 0);
    verifySimpleElement(nested2.getSimpleElements().get(0), "prop3", XSSimpleType.PRIMITIVE_DECIMAL);

    SchemaElementComplex prop4 = simpleEvent.getChildren().get(1);
    verifyElement(prop4, "prop4");
    verifySizes(prop4, 1, 0, 0);
    assertEquals("attr2", prop4.getAttributes().get(0).getName());
    assertEquals(XSSimpleType.PRIMITIVE_BOOLEAN, prop4.getAttributes().get(0).getXsSimpleType());
    assertEquals(XSSimpleType.PRIMITIVE_STRING, (short) prop4.getOptionalSimpleType());

    SchemaElementComplex nested3 = simpleEvent.getChildren().get(2);
    verifyComplexElement(nested3, "nested3", XSSimpleType.COMPLEX_TYPE, false);
    verifySizes(nested3, 0, 0, 1);

    SchemaElementComplex nested4 = nested3.getChildren().get(0);
    verifyComplexElement(nested4, "nested4", XSSimpleType.COMPLEX_TYPE, true);
    verifySizes(nested4, 1, 4, 0);
    assertEquals("id", nested4.getAttributes().get(0).getName());
    assertEquals(XSSimpleType.PRIMITIVE_STRING, nested4.getAttributes().get(0).getXsSimpleType());
    verifySimpleElement(nested4.getSimpleElements().get(0), "prop5", XSSimpleType.PRIMITIVE_STRING);
    verifySimpleElement(nested4.getSimpleElements().get(1), "prop6", XSSimpleType.PRIMITIVE_STRING);
    verifySimpleElement(nested4.getSimpleElements().get(2), "prop7", XSSimpleType.PRIMITIVE_STRING);
    verifySimpleElement(nested4.getSimpleElements().get(3), "prop8", XSSimpleType.PRIMITIVE_STRING);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:49,代码来源:TestXSDSchemaMapper.java

示例5: readSchemaInternal

import com.espertech.esper.util.ResourceLoader; //导入依赖的package包/类
private static XSModel readSchemaInternal(String schemaResource, String schemaText) throws IllegalAccessException, InstantiationException, ClassNotFoundException,
        ConfigurationException, URISyntaxException
{
    LSInputImpl input = null;
    String baseURI = null;
    if (schemaResource != null) {
        URL url = ResourceLoader.resolveClassPathOrURLResource("schema", schemaResource);
        baseURI = url.toURI().toString();
    }
    else {
        input = new LSInputImpl(schemaText);
    }

    // Uses Xerxes internal classes
    DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
    registry.addSource(new DOMXSImplementationSourceImpl());
    Object xsImplementation = registry.getDOMImplementation("XS-Loader");
    if (xsImplementation == null) {
        throw new ConfigurationException("Failed to retrieve XS-Loader implementation from registry obtained via DOMImplementationRegistry.newInstance, please check that registry.getDOMImplementation(\"XS-Loader\") returns an instance");
    }
    if (!JavaClassHelper.isImplementsInterface(xsImplementation.getClass(), XSImplementation.class)) {
        String message = "The XS-Loader instance returned by the DOM registry class '" + xsImplementation.getClass().getName() + "' does not implement the interface '" + XSImplementation.class.getName() + "'; If you have a another Xerces distribution in your classpath please ensure the classpath order loads the JRE Xerces distribution or set the DOMImplementationRegistry.PROPERTY system property";
        throw new ConfigurationException(message);
    }
    XSImplementation impl =(XSImplementation) xsImplementation; 
    XSLoader schemaLoader = impl.createXSLoader(null);
    XSModel xsModel;
    if (input != null) {
        xsModel = schemaLoader.load((mf.org.w3c.dom.ls.LSInput) input);
    }
    else {
        xsModel = schemaLoader.loadURI(baseURI);
    }

    if (xsModel == null)
    {
        throw new ConfigurationException("Failed to read schema via URL '" + schemaResource + '\'');
    }

    return xsModel;
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:42,代码来源:XSDSchemaMapper.java


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