Package org.apache.hivemind.schema.rules

Examples of org.apache.hivemind.schema.rules.ReadAttributeRule


        em.setElementName("fred");
        em.addAttributeModel(am);

        em.addRule(new CreateObjectRule(StringHolderImpl.class.getName()));

        ReadAttributeRule rule = new ReadAttributeRule();
        rule.setPropertyName("value");
        rule.setAttributeName("wife");

        em.addRule(rule);

        em.addRule(new InvokeParentRule("addElement"));
View Full Code Here


        em.addAttributeModel(am);

        em.addRule(new CreateObjectRule("StringHolderImpl"));

        ReadAttributeRule rule = new ReadAttributeRule();
        rule.setAttributeName("name");
        rule.setPropertyName("value");

        em.addRule(rule);

        em.addRule(new InvokeParentRule("addElement"));
View Full Code Here

        assertEquals(4, rl.size());

        CreateObjectRule rule1 = (CreateObjectRule) rl.get(0);
        assertEquals("package.Foo1", rule1.getClassName());

        ReadAttributeRule rule2 = (ReadAttributeRule) rl.get(1);

        assertEquals("bazomatic", rule2.getPropertyName());
        assertEquals("bar", rule2.getAttributeName());
        assertEquals(true, rule2.getSkipIfNull());

        ReadContentRule rule3 = (ReadContentRule) rl.get(2);

        assertEquals("description", rule3.getPropertyName());
View Full Code Here

            {             
                rule = _document.createElement("push-content");
            }
            else if (r instanceof ReadAttributeRule)
            {
                ReadAttributeRule rar = (ReadAttributeRule) r;
                rule = _document.createElement("read-attribute");

                rule.setAttribute("property", rar.getPropertyName());
                rule.setAttribute("attribute", rar.getAttributeName());
                if (!rar.getSkipIfNull())
                    rule.setAttribute("skip-if-null", "false");
                if (rar.getTranslator() != null)
                    rule.setAttribute("translator", rar.getTranslator());
            }
            else if (r instanceof ReadContentRule)
            {
                ReadContentRule rcr = (ReadContentRule) r;
                rule = _document.createElement("read-content");
View Full Code Here

        assertEquals(5, rl.size());

        CreateObjectRule rule1 = (CreateObjectRule) rl.get(0);
        assertEquals("package.Foo1", rule1.getClassName());

        ReadAttributeRule rule2 = (ReadAttributeRule) rl.get(1);

        assertEquals("bazomatic", rule2.getPropertyName());
        assertEquals("bar", rule2.getAttributeName());
        assertEquals(true, rule2.getSkipIfNull());

        ReadContentRule rule3 = (ReadContentRule) rl.get(2);

        assertEquals("description", rule3.getPropertyName());
View Full Code Here

    }

    private void enterReadAttribute(String elementName)
    {
        ElementModelImpl elementModel = (ElementModelImpl) peekObject();
        ReadAttributeRule rule = new ReadAttributeRule();

        push(elementName, rule, STATE_NO_CONTENT);

        checkAttributes();

        rule.setPropertyName(getAttribute("property"));
        rule.setAttributeName(getAttribute("attribute"));
        rule.setSkipIfNull(getBooleanAttribute("skip-if-null", true));
        rule.setTranslator(getAttribute("translator"));

        elementModel.addRule(rule);
    }
View Full Code Here

            AttributeMappingDescriptor amd = (AttributeMappingDescriptor) _attributeNameMappingMap
                    .get(attributeName);

            if (amd == null)
            {
                _rules.add(new ReadAttributeRule(attributeName,
                        constructPropertyName(attributeName), null, getLocation()));
            }
            else
            {
                String propertyName = amd.getPropertyName();
                if (propertyName == null)
                    propertyName = constructPropertyName(attributeName);

                _rules.add(new ReadAttributeRule(attributeName, propertyName, null, amd
                        .getLocation()));

                _attributeNameMappingMap.remove(attributeName);
            }
        }
View Full Code Here

    public void testReadAttributeRule()
    {
        ElementImpl element = new ElementImpl();
        element.setElementName("myelement");

        ReadAttributeRule rule = new ReadAttributeRule();

        rule.setAttributeName("fred");
        rule.setPropertyName("value");

        MockControl control = newControl(SchemaProcessor.class);
        SchemaProcessor mockProcessor = (SchemaProcessor) control.getMock();

        mockProcessor.getAttributeDefault("fred");
        control.setReturnValue("${flintstone}");

        mockProcessor.getContributingModule();

        MockControl moduleControl = newControl(Module.class);
        Module mockModule = (Module) moduleControl.getMock();

        control.setReturnValue(mockModule);
       
        MockControl symbolExpanderControl = newControl(SymbolExpander.class);
        SymbolExpander symbolExpander = (SymbolExpander) symbolExpanderControl.getMock();
       
        mockProcessor.getSymbolExpander();
        control.setReturnValue(symbolExpander);

        mockProcessor.peek();

        StringHolderImpl target = new StringHolderImpl();
        control.setReturnValue(target);

        mockProcessor.getAttributeTranslator("fred");
        control.setReturnValue(new NullTranslator());

        mockProcessor.getContributingModule();
        control.setReturnValue(mockModule);

        symbolExpander.expandSymbols("${flintstone}", element.getLocation());
        symbolExpanderControl.setReturnValue("FLINTSTONE");

        replayControls();

        rule.begin(mockProcessor, element);
        rule.end(mockProcessor, element);

        verifyControls();

        assertEquals("FLINTSTONE", target.getValue());
    }
View Full Code Here

        em.setElementName("fred");
        em.addAttributeModel(am);

        em.addRule(new CreateObjectRule(StringHolderImpl.class.getName()));

        ReadAttributeRule rule = new ReadAttributeRule();
        rule.setPropertyName("value");
        rule.setAttributeName("wife");

        em.addRule(rule);

        em.addRule(new InvokeParentRule("addElement"));
View Full Code Here

        em.addAttributeModel(am);

        em.addRule(new CreateObjectRule("StringHolderImpl"));

        ReadAttributeRule rule = new ReadAttributeRule();
        rule.setAttributeName("name");
        rule.setPropertyName("value");

        em.addRule(rule);

        em.addRule(new InvokeParentRule("addElement"));
View Full Code Here

TOP

Related Classes of org.apache.hivemind.schema.rules.ReadAttributeRule

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.