Examples of StringResourceMap


Examples of org.metagrid.gatekeeper.common.io.test.StringResourceMap

    throws Exception
        {

        //
        // Local map of XML resources.
        StringResourceMap resources = new StringResourceMap(
            new StringResource(
                new URI("urn://orange/000"),
                    "<node xmlns='urn:metagrid' ident='urn://orange/000' type='urn:metagrid.orange'>"
                  + "  <properties>"
                  + "    <property type='urn:metagrid.orange.weight'>000</property>"
                  + "    <property type='urn:metagrid.fruit.modified'>2008-11-29T06:25:50.379+0000</property>"
                  + "  </properties>"
                  + "</node>"
                ),
            new StringResource(
                new URI("urn://orange/001"),
                    "<node xmlns='urn:metagrid' ident='urn://orange/001' type='urn:metagrid.orange'>"
                  + "  <properties>"
                  + "    <property type='urn:metagrid.orange.weight'>001</property>"
                  + "    <property type='urn:metagrid.fruit.modified'>2008-11-29T06:25:50.379+0000</property>"
                  + "  </properties>"
                  + "</node>"
                ),
            new StringResource(
                new URI("urn://apple/000"),
                    "<node xmlns='urn:metagrid' ident='urn://apple/*' type='urn:metagrid.apple'>"
                  + "  <properties>"
                  + "    <property type='urn:metagrid.apple.weight'>002</property>"
                  + "    <property type='urn:metagrid.fruit.modified'>2008-11-29T06:25:50.379+0000</property>"
                  + "  </properties>"
                  + "</node>"
                ),
            new StringResource(
                new URI("urn://apple/001"),
                    "<node xmlns='urn:metagrid' type='urn:metagrid.apple'>"
                  + "  <properties>"
                  + "    <property type='urn:metagrid.apple.weight'>003</property>"
                  + "    <property type='urn:metagrid.fruit.modified'>2008-11-29T06:25:50.379+0000</property>"
                  + "  </properties>"
                  + "</node>"
                )
            );

//
// These are probably fairly common components.
// If so, need to create these as ready made components.

        //
        // Outer reader map, based on element QName.
        XMLNodeReaderMap<Node> reader = new XMLNestedReaderImpl<QName,Node>()
            {
            @Override
            public QName key(XMLNodeReader<Node> reader)
                {
                return reader.qname();
                }
            @Override
            public QName key(StartElement element)
                {
                return element.getName();
                }
            @Override
            public XMLNodeReaderMap<Node> inner(XMLNodeReader<Node> reader)
                {
                return new XMLNodeReaderTypeMap<Node>(
                    reader.qname(),
                    (XMLNodeReader<Node>)reader
                    );
                }
            @Override
            public URI ident(StartElement element, URIHandler handler)
            throws XMLReaderException
                {
                throw new UnsupportedOperationException();
                }
            @Override
            public URI type(StartElement element)
        throws XMLReaderException
                {
                throw new UnsupportedOperationException();
                }
            };

        //
        // Create our AppleBeanFactory.
        final AppleBeanFactory apples  = new AppleBeanFactoryImpl();
        //
        // Create our OrangeBeanFactory.
        final OrangeBeanFactory oranges = new OrangeBeanFactoryImpl();

        //
        // Add our AppleNode reader.
        reader.add(
// Fails    new XMLNodeReaderImpl<Node>(
// Fails    new XMLNodeReaderImpl<AppleNode>(
// Using generics makes this non-generic.
//          new XMLNodeReaderImpl<AppleNode>(
            new XMLNodeReaderImpl(
                new AppleNodeServerImpl(
                    new FruitBeanImpl.StringIdentBuilder<AppleBean>(
                        new URI(
                            "urn://apple/"
                            )
                        ),
                    apples
                    ).creator()
                )
            );
        //
        // Add our OrangeNode reader.
        reader.add(
//          new XMLNodeReaderImpl<OrangeNode>(
            new XMLNodeReaderImpl(
                new OrangeNodeServerImpl(
                    new FruitBeanImpl.StringIdentBuilder<OrangeBean>(
                        new URI(
                            "urn://orange/"
                            )
                        ),
                    oranges
                    ).creator()
                )
            );

        log.debug("----------");
        log.debug("URI [urn://orange/000]");
        Node node = reader.read(
            resources.get(
                new URI("urn://orange/000")
                ).reader()
            );
        //
        // Check the OrangeNode weight.
        assertEquals(
            "0",
            node.properties().get(
                OrangeNode.WEIGHT_PROPERTY_URI
                ).value()
            );

        //
        // Parse the next OrangeNode ...
        log.debug("----------");
        log.debug("URI [urn://orange/001]");
        node = reader.read(
            resources.get(
                new URI("urn://orange/001")
                ).reader()
            );
        //
        // Check the OrangeNode weight.
        assertEquals(
            "1",
            node.properties().get(
                OrangeNode.WEIGHT_PROPERTY_URI
                ).value()
            );

        //
        // Parse the first AppleBean ...
        log.debug("----------");
        log.debug("URI [urn://apple/000]");
        node = reader.read(
            resources.get(
                new URI("urn://apple/000")
                ).reader()
            );
        //
        // Check the AppleNode weight.
        assertEquals(
            "2",
            node.properties().get(
                AppleNode.WEIGHT_PROPERTY_URI
                ).value()
            );

        //
        // Parse the next AppleNode ...
        log.debug("----------");
        log.debug("URI [urn://apple/001]");
        node = reader.read(
            resources.get(
                new URI("urn://apple/001")
                ).reader()
            );
        //
        // Check the AppleNode weight.
View Full Code Here

Examples of org.metagrid.gatekeeper.common.io.test.StringResourceMap

    throws Exception
        {

        //
        // Local map of XML resources.
        StringResourceMap resources = new StringResourceMap(
            new StringResource(
                new URI("urn://test/000"),

                "<node xmlns='urn:metagrid' ident='urn://outer/000' type='urn:node.outer.one'>"
                      + "<properties>"
                          + "<property type='urn:test.outer.int'>000</property>"
                          + "<property type='urn:test.outer.date'>2008-11-29T06:25:50.379+0000</property>"
                      + "</properties>"
                      + "<nodes>"
                          + "<node xmlns='urn:metagrid' ident='urn://inner.one/000' type='urn:node.inner.one'>"
                              + "<properties>"
                                  + "<property type='urn:test.inner.int'>000</property>"
                                  + "<property type='urn:test.inner.date'>2008-11-29T06:25:50.379+0000</property>"
                              + "</properties>"
                          + "</node>"
                            + "<node xmlns='urn:metagrid' ident='urn://inner.one/001' type='urn:node.inner.one'>"
                                + "<properties>"
                                    + "<property type='urn:test.inner.int'>000</property>"
                                    + "<property type='urn:test.inner.date'>2008-11-29T06:25:50.379+0000</property>"
                                + "</properties>"
                            + "</node>"
                          + "<node xmlns='urn:metagrid' ident='urn://inner.two/000' type='urn:node.inner.two'>"
                              + "<properties>"
                                    + "<property type='urn:test.inner.int'>000</property>"
                                  + "<property type='urn:test.inner.date'>2008-11-29T06:25:50.379+0000</property>"
                              + "</properties>"
                          + "</node>"
                      + "</nodes>"
                  + "</node>"
               
                )
        );

        //
        // Create our outer node reader.
        XMLNodeReader<ComplexNodeOne> outerreader = new ComplexNodeOneReader(
            new ComplexNodeOne.Factory()
        );

        Node outernode = outerreader.read(
        resources.get(
        URI.create(
          "urn://test/000"
          )
        ).reader()
        );
View Full Code Here

Examples of org.metagrid.gatekeeper.common.io.test.StringResourceMap

    throws Exception
        {

        //
        // Local map of XML resources.
        StringResourceMap resources = new StringResourceMap(
            new StringResource(
                new URI("urn://test/000"),

                "<node xmlns='urn:metagrid' ident='urn://outer/000' type='urn:node.outer.two'>"
                        + "<properties>"
                            + "<property type='urn:test.outer.int'>000</property>"
                            + "<property type='urn:test.outer.date'>2008-11-29T06:25:50.379+0000</property>"
                        + "</properties>"
                        + "<nodes>"
                            + "<node xmlns='urn:metagrid' ident='urn://inner.one/000' type='urn:node.inner.one'>"
                                + "<properties>"
                                    + "<property type='urn:test.inner.int'>000</property>"
                                    + "<property type='urn:test.inner.date'>2008-11-29T06:25:50.379+0000</property>"
                                + "</properties>"
                            + "</node>"
                            + "<node xmlns='urn:metagrid' ident='urn://inner.one/001' type='urn:node.inner.one'>"
                                + "<properties>"
                                    + "<property type='urn:test.inner.int'>000</property>"
                                    + "<property type='urn:test.inner.date'>2008-11-29T06:25:50.379+0000</property>"
                                + "</properties>"
                            + "</node>"
                            + "<node xmlns='urn:metagrid' ident='urn://inner.two/000' type='urn:node.inner.two'>"
                                + "<properties>"
                                    + "<property type='urn:test.inner.int'>000</property>"
                                    + "<property type='urn:test.inner.date'>2008-11-29T06:25:50.379+0000</property>"
                                + "</properties>"
                            + "</node>"
                        + "</nodes>"
                    + "</node>"
               
                )
            );

        //
        // Create our outer node reader.
        XMLNodeReader<ComplexNodeTwo> reader = new ComplexNodeTwoReader();

        Node complex = reader.read(
            new ComplexNodeTwo.Factory(),
            resources.get(
                URI.create(
                    "urn://test/000"
                    )
                ).reader()
            );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.