Package org.apache.hivemind

Examples of org.apache.hivemind.Element


        ContributionDescriptor cd = (ContributionDescriptor) l.get(0);

        l = cd.getElements();
        assertEquals(2, l.size());

        Element e = (Element) l.get(0);

        assertEquals("foo1", e.getElementName());
        assertEquals(0, e.getElements().size());
        assertEquals("foo1 content", e.getContent());
        checkAttributes(e, new String[]
        { "bar", "baz" });

        e = (Element) l.get(1);

        assertEquals("foo2", e.getElementName());
        assertEquals(1, e.getElements().size());
        assertEquals("", e.getContent());
        checkAttributes(e, new String[]
        { "zip", "zap", "fred", "barney" });

        l = e.getElements();
        e = (Element) l.get(0);

        assertEquals("foo3", e.getElementName());
        assertEquals(0, e.getElements().size());
        assertEquals("", e.getContent());
        checkAttributes(e, new String[]
        { "gnip", "gnop" });
    }
View Full Code Here


        assertEquals(expectedColumn, e.getLocation().getColumnNumber());
    }

    public void testMinimal() throws Exception
    {
        Element root = parse("minimal.sdl");

        assertElement("module", 15, 1, root);

        assertEquals(0, root.getAttributes().size());
        assertEquals(true, root.isEmpty());
        assertEquals("", root.getContent());
    }
View Full Code Here

        assertEquals("", root.getContent());
    }

    public void testElementLiteralContent() throws Exception
    {
        Element root = parse("elementLiteralContent.sdl");

        List l = root.getElements();

        assertEquals(6, l.size());

        Element e = (Element) l.get(0);

        assertElement("string", 17, 3, e);

        assertEquals("Now is the time", e.getContent());

        e = (Element) l.get(1);

        assertEquals(" For all good men ", e.getContent());

        e = (Element) l.get(2);

        // The parser runs the individual numeric values together!

        assertEquals("3.1459", e.getContent());

        e = (Element) l.get(3);

        assertEquals("org.apache.hivemind", e.getContent());

        e = (Element) l.get(4);

        assertEquals("The value of PI is 3.1459, give or take.", e.getContent());

        e = (Element) l.get(5);

        assertEquals("${env.current.dir}", e.getContent());

    }
View Full Code Here

        assertEquals("Attribute count", attributesAndValues.length / 2, e.getAttributes().size());
    }

    public void testAttributes() throws Exception
    {
        Element root = parse("attributes.sdl");

        List l = root.getElements();

        assertEquals(7, l.size());

        Element e = (Element) l.get(0);

        checkAttributes(e, new String[] { "a", "b", "c", "d" });

        e = (Element) l.get(1);
View Full Code Here

        ContributionDescriptor cd = (ContributionDescriptor) l.get(0);

        l = cd.getElements();
        assertEquals(2, l.size());

        Element e = (Element) l.get(0);

        assertEquals("foo1", e.getElementName());
        assertEquals(0, e.getElements().size());
        assertEquals("foo1 content", e.getContent());
        checkAttributes(e, new String[] { "bar", "baz" });

        e = (Element) l.get(1);

        assertEquals("foo2", e.getElementName());
        assertEquals(1, e.getElements().size());
        assertEquals("", e.getContent());
        checkAttributes(e, new String[] { "zip", "zap", "fred", "barney" });

        l = e.getElements();
        e = (Element) l.get(0);

        assertEquals("foo3", e.getElementName());
        assertEquals(0, e.getElements().size());
        assertEquals("", e.getContent());
        checkAttributes(e, new String[] { "gnip", "gnop" });
    }
View Full Code Here

        List l = r.getConfiguration("hivemind.test.config.NoSchema");

        assertEquals(2, l.size());

        Element e = (Element) l.get(0);
        assertEquals("datum", e.getElementName());
        assertEquals("key1", e.getAttributeValue("key"));
        assertEquals("value1", e.getAttributeValue("value"));

        // Show that symbols are NOT expanded in non-schema
        // contributions.

        e = (Element) l.get(1);
        assertEquals("datum", e.getElementName());
        assertEquals("key2", e.getAttributeValue("key"));
        assertEquals("${value2}", e.getAttributeValue("value"));
    }
View Full Code Here

        List l = r.getConfiguration("hivemind.test.config.UnresolvedSchema");

        assertEquals(1, l.size());

        Element e = (Element) l.get(0);

        assertEquals("buffy", e.getAttributeValue("key"));
        assertEquals("angel", e.getAttributeValue("value"));
    }
View Full Code Here

        ContributionDescriptor cd = (ContributionDescriptor) l.get(0);

        l = cd.getElements();
        assertEquals(2, l.size());

        Element e = (Element) l.get(0);

        assertEquals("foo1", e.getElementName());
        assertEquals(0, e.getElements().size());
        assertEquals("foo1 content", e.getContent());
        checkAttributes(e, new String[]
        { "bar", "baz" });

        e = (Element) l.get(1);

        assertEquals("foo2", e.getElementName());
        assertEquals(1, e.getElements().size());
        assertEquals("", e.getContent());
        checkAttributes(e, new String[]
        { "zip", "zap", "fred", "barney" });

        l = e.getElements();
        e = (Element) l.get(0);

        assertEquals("foo3", e.getElementName());
        assertEquals(0, e.getElements().size());
        assertEquals("", e.getContent());
        checkAttributes(e, new String[]
        { "gnip", "gnop" });
    }
View Full Code Here

     */
    public void addKeyedElement(Object element)
    {
        if (_canElementsBeMapped)
        {
            Element currentElement = peekElement();
            String keyAttribute = _activeElement.getModel().getKeyAttribute();

            if (keyAttribute == null) {
                // check for unique attribute
                for (Iterator j = _activeElement.getModel().getAttributeModels().iterator(); j.hasNext();)
                {
                    AttributeModel attributeModel = (AttributeModel) j.next();
   
                    if (attributeModel.isUnique())
                        keyAttribute = attributeModel.getName();
                }
            }

            String expandedKey = getSymbolExpander().expandSymbols(
                    currentElement.getAttributeValue(keyAttribute),
                    currentElement.getLocation());

            Translator t = getAttributeTranslator(keyAttribute);

            Object finalValue = t.translate(
                    getContributingModule(),
                    Object.class,
                    expandedKey,
                    currentElement.getLocation());
           
            Map container = (Map) _stack.get(0);
            container.put(finalValue, element);

        }
View Full Code Here

        int count = elements.size();

        for (int i = 0; i < count; i++)
        {
            Element e = (Element) elements.get(i);

            processRootElement(e);
        }
       
        _contributingModule = null;
View Full Code Here

TOP

Related Classes of org.apache.hivemind.Element

Copyright © 2018 www.massapicom. 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.