Package org.apache.hivemind.schema

Examples of org.apache.hivemind.schema.Rule


    {
        Element rules = _document.createElement("rules");

        for (Iterator i = em.getRules().iterator(); i.hasNext();)
        {
            Rule r = (Rule) i.next();

            Element rule = null;

            if (r instanceof CreateObjectRule)
            {
                CreateObjectRule cor = (CreateObjectRule) r;
                rule = _document.createElement("create-object");

                rule.setAttribute("class", cor.getClassName());
            }
            else if (r instanceof InvokeParentRule)
            {
                InvokeParentRule ipr = (InvokeParentRule) r;
                rule = _document.createElement("invoke-parent");

                rule.setAttribute("method", ipr.getMethodName());
                if (ipr.getDepth() != 1)
                    rule.setAttribute("depth", Integer.toString(ipr.getDepth()));
            }
            else if (r instanceof PushAttributeRule)
            {
                PushAttributeRule par = (PushAttributeRule) r;
                rule = _document.createElement("push-attribute");

                rule.setAttribute("attribute", par.getAttributeName());
            }
            else if (r instanceof PushContentRule)
            {             
                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");

                rule.setAttribute("property", rcr.getPropertyName());
            }
            else if (r instanceof SetModuleRule)
            {
                SetModuleRule smr = (SetModuleRule) r;
                rule = _document.createElement("set-module");

                rule.setAttribute("property", smr.getPropertyName());
            }
            else if (r instanceof SetParentRule)
            {
                SetParentRule spr = (SetParentRule) r;
                rule = _document.createElement("set-parent");

                rule.setAttribute("property", spr.getPropertyName());
            }
            else if (r instanceof SetPropertyRule)
            {
                SetPropertyRule spr = (SetPropertyRule) r;
                rule = _document.createElement("set-property");

                rule.setAttribute("property", spr.getPropertyName());
                rule.setAttribute("value", spr.getValue());
            }
            else if (r instanceof ConversionDescriptor)
            {
                ConversionDescriptor cd = (ConversionDescriptor) r;
                rule = _document.createElement("conversion");

                rule.setAttribute("class", cd.getClassName());
                if (!cd.getParentMethodName().equals("addElement"))
                    rule.setAttribute("parent-method", cd.getParentMethodName());

                for (Iterator j = cd.getAttributeMappings().iterator(); j.hasNext();)
                {
                    AttributeMappingDescriptor amd = (AttributeMappingDescriptor) j.next();

                    Element map = _document.createElement("map");

                    map.setAttribute("attribute", amd.getAttributeName());
                    map.setAttribute("property", amd.getPropertyName());

                    rule.appendChild(map);
                }
            }
            else
            {
                rule = _document.createElement("custom");

                rule.setAttribute("class", r.getClass().getName());
            }

            if (rule != null)
                rules.appendChild(rule);
        }
View Full Code Here


        List rules = _model.getRules();
        int count = rules.size();

        for (int i = 0; i < count; i++)
        {
            Rule r = (Rule) rules.get(i);

            r.begin(_processor, element);

        }
    }
View Full Code Here

        List rules = _model.getRules();
        int count = rules.size();

        for (int i = count - 1; i >= 0; i--)
        {
            Rule r = (Rule) rules.get(i);

            r.end(_processor, element);

        }
    }
View Full Code Here

     */
    public void begin(SchemaProcessor processor, Element element)
    {
        for (Iterator i = _rules.iterator(); i.hasNext();)
        {
            Rule rule = (Rule) i.next();

            rule.begin(processor, element);
        }
    }
View Full Code Here

     */
    public void end(SchemaProcessor processor, Element element)
    {
        for (ListIterator i = _rules.listIterator(_rules.size()); i.hasPrevious();)
        {
            Rule rule = (Rule) i.previous();

            rule.end(processor, element);
        }
    }
View Full Code Here

        checkAttributes();

        String ruleClassName = getAttribute("class");

        Rule rule = getCustomRule(ruleClassName);

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

        return defaultValue;
    }

    private Rule getCustomRule(String ruleClassName)
    {
        Rule result = (Rule) _ruleMap.get(ruleClassName);

        if (result == null)
        {
            result = instantiateRule(ruleClassName);
View Full Code Here

        List rules = _model.getRules();
        int count = rules.size();

        for (int i = 0; i < count; i++)
        {
            Rule r = (Rule) rules.get(i);

            r.begin(_processor, element);

        }
    }
View Full Code Here

        List rules = _model.getRules();
        int count = rules.size();

        for (int i = count - 1; i >= 0; i--)
        {
            Rule r = (Rule) rules.get(i);

            r.end(_processor, element);

        }
    }
View Full Code Here

     */
    public void begin(SchemaProcessor processor, Element element)
    {
        for (Iterator i = _rules.iterator(); i.hasNext();)
        {
            Rule rule = (Rule) i.next();

            rule.begin(processor, element);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.hivemind.schema.Rule

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.