Search in sources :

Example 11 with MapTag

use of com.dexels.navajo.document.navascript.tags.MapTag in project navajo by Dexels.

the class NS3ToNSXML method parseMappedArrayField.

private MapTag parseMappedArrayField(NS3Compatible parent, XMLElement currentXML) throws Exception {
    currentXML.setAttribute("PROCESSED", "true");
    MapTag ft = new MapTag(myNavascript);
    ft.addParent(parent);
    if (parent != null && parent instanceof MapTag) {
        ft.setParent((MapTag) parent);
    }
    ft.setOldStyleMap(true);
    Vector<XMLElement> children = currentXML.getChildren();
    boolean hasFilter = false;
    for (XMLElement child : children) {
        String name = child.getName();
        String content = (child.getContent() != null && !"".equals(child.getContent()) ? child.getContent() : null);
        if (name.equals("MappableIdentifier")) {
            String fieldRef = parseMappableIdentifier(child);
            ft.setRefAttribute(fieldRef);
        }
        if (name.equals("FieldName")) {
            ft.setRefAttribute(content);
        }
        if (name.equals("TOKEN") && content.equals("filter")) {
            hasFilter = true;
        }
        if (hasFilter && name.equals("Expression")) {
            ExpressionFragment ef = new ExpressionFragment();
            consumeContent(ef, child);
            ft.setFilter(ef.consumedFragment());
        }
        if (name.equals("InnerBody") || name.equals("InnerBodySelection")) {
            List<NS3Compatible> innerBodyElements = parseInnerBody(ft, child);
            for (NS3Compatible ib : innerBodyElements) {
                addChildTag(ft, ib);
            }
        }
    }
    return ft;
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) MapTag(com.dexels.navajo.document.navascript.tags.MapTag) NS3Compatible(com.dexels.navajo.document.navascript.tags.NS3Compatible)

Example 12 with MapTag

use of com.dexels.navajo.document.navascript.tags.MapTag in project navajo by Dexels.

the class NS3ToNSXML method parseMap.

private MapTag parseMap(NS3Compatible parent, XMLElement currentXML) throws Exception {
    currentXML.setAttribute("PROCESSED", "true");
    MapTag mapTag = new MapTag(myNavascript);
    mapTag.addParent(parent);
    Vector<XMLElement> children = currentXML.getChildren();
    for (XMLElement child : children) {
        String name = child.getName();
        String content = (child.getContent() != null && !"".equals(child.getContent()) ? child.getContent() : null);
        if (name.equals("Conditional")) {
            ConditionFragment currentFragment = new ConditionFragment();
            consumeContent(currentFragment, child);
            mapTag.setCondition(currentFragment.consumedFragment());
        }
        if (name.equals("AdapterName")) {
            mapTag.setName(content);
        }
        if (name.equals("ClassName")) {
            // old style map
            mapTag.setOldStyleMap(true);
            mapTag.setObject(content);
        }
        if (name.equals("Include")) {
            IncludeTag it = parseInclude(parent, child);
            mapTag.addInclude(it);
        }
        if (name.equals("KeyValueArguments")) {
            parseMapOrMethodArguments(mapTag, child);
        }
        if (name.equals("InnerBody")) {
            List<NS3Compatible> innerBodyElements = parseInnerBody(mapTag, child);
            for (NS3Compatible ib : innerBodyElements) {
                addChildTag(mapTag, ib);
            }
        }
    }
    return mapTag;
}
Also used : IncludeTag(com.dexels.navajo.document.navascript.tags.IncludeTag) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) MapTag(com.dexels.navajo.document.navascript.tags.MapTag) NS3Compatible(com.dexels.navajo.document.navascript.tags.NS3Compatible)

Example 13 with MapTag

use of com.dexels.navajo.document.navascript.tags.MapTag in project navajo by Dexels.

the class NS3ToNSXML method parseXML.

private void parseXML(NS3Compatible parent, XMLElement xe, int level) throws Exception {
    if (xe.getAttribute("PROCESSED") != null) {
        return;
    }
    String name = xe.getName();
    String content = (xe.getContent() != null && !"".equals(xe.getContent()) ? xe.getContent() : null);
    if (name.equals("DebugDefinition")) {
        parseHeaderDefinitions(xe);
    } else if (name.equals("Validations")) {
        ValidationsTag vt = parseValidations(parent, xe);
        myNavascript.addValidations(vt);
    } else if (name.equals("Var")) {
        ParamTag pt = parseVar(parent, xe);
        addChildTag(parent, pt);
    } else if (name.equals("Message")) {
        MessageTag mt = parseMessage(parent, xe);
        addChildTag(parent, mt);
    } else if (name.equals("ConditionalEmptyMessage")) {
        BlockTag mt = parseConditionalBlock(parent, xe, true);
        addChildTag(parent, mt);
    } else if (name.equals("Loop")) {
        LoopTag mt = parseLoop(parent, xe);
        addChildTag(parent, mt);
    } else if (name.equals("Synchronized")) {
        SynchronizedTag st = parseSynchronizedBlock(parent, xe);
        addChildTag(parent, st);
    } else if (name.equals("Map")) {
        MapTag mt = parseMap(parent, xe);
        addChildTag(parent, mt);
    } else if (name.equals("Break")) {
        BreakTag mt = parseBreak(parent, xe);
        addChildTag(parent, mt);
    } else if (name.equals("Include")) {
        IncludeTag it = parseInclude(parent, xe);
        addChildTag(parent, it);
    } else if (name.equals("Define")) {
        DefineTag dt = parseDefine(parent, xe);
        addDefine(dt);
    } else if (name.equals("Print")) {
        DebugTag dt = parsePrint(parent, xe);
        addChildTag(parent, dt);
    } else if (name.equals("Log")) {
        LogTag dt = parseLog(parent, xe);
        addChildTag(parent, dt);
    } else if (name.equals("Finally")) {
        FinallyTag ft = parseFinally(parent, xe);
        addChildTag(parent, ft);
    } else if (name.equals("Methods")) {
        MethodsTag mt = parseMethods(parent, xe);
        addChildTag(parent, mt);
    } else {
        Vector<XMLElement> children = xe.getChildren();
        for (XMLElement x : children) {
            if (x.getAttribute("PROCESSED") == null) {
                parseXML(parent, x, level + 1);
            }
        }
    }
}
Also used : ParamTag(com.dexels.navajo.document.navascript.tags.ParamTag) LoopTag(com.dexels.navajo.document.navascript.tags.LoopTag) DebugTag(com.dexels.navajo.document.navascript.tags.DebugTag) ValidationsTag(com.dexels.navajo.document.navascript.tags.ValidationsTag) LogTag(com.dexels.navajo.document.navascript.tags.LogTag) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) BreakTag(com.dexels.navajo.document.navascript.tags.BreakTag) MapTag(com.dexels.navajo.document.navascript.tags.MapTag) FinallyTag(com.dexels.navajo.document.navascript.tags.FinallyTag) MethodsTag(com.dexels.navajo.document.navascript.tags.MethodsTag) BlockTag(com.dexels.navajo.document.navascript.tags.BlockTag) DefineTag(com.dexels.navajo.document.navascript.tags.DefineTag) IncludeTag(com.dexels.navajo.document.navascript.tags.IncludeTag) MessageTag(com.dexels.navajo.document.navascript.tags.MessageTag) SynchronizedTag(com.dexels.navajo.document.navascript.tags.SynchronizedTag)

Example 14 with MapTag

use of com.dexels.navajo.document.navascript.tags.MapTag in project navajo by Dexels.

the class NS3ToNSXML method parseLoop.

private LoopTag parseLoop(NS3Compatible parent, XMLElement currentXML) throws Exception {
    // Define arraymessage adapter
    LoopTag mt = new LoopTag(myNavascript);
    // mt.setName("arraymessage");
    mt.addParent(parent);
    // Define map for mapped array message of array field
    MapTag ref = new MapTag(myNavascript);
    ref.setOldStyleMap(true);
    mt.addMap(ref);
    Vector<XMLElement> children = currentXML.getChildren();
    boolean hasFilter = false;
    for (XMLElement child : children) {
        String name = child.getName();
        String content = (child.getContent() != null && !"".equals(child.getContent()) ? child.getContent() : null);
        if (name.equals("Conditional")) {
            ConditionFragment currentFragment = new ConditionFragment();
            consumeContent(currentFragment, child);
            mt.setCondition(currentFragment.consumedFragment());
        }
        if (name.equals("MsgIdentifier")) {
            ref.setRefAttribute("[" + content + "]");
        }
        if (name.equals("MappableIdentifier")) {
            String fieldRef = parseMappableIdentifier(child);
            ref.setRefAttribute(fieldRef);
        }
        if (name.equals("TOKEN") && content.equals("filter")) {
            hasFilter = true;
        }
        if (hasFilter && name.equals("Expression")) {
            ExpressionFragment ef = new ExpressionFragment();
            consumeContent(ef, child);
            ref.setFilter(ef.consumedFragment());
        }
        if (name.equals("InnerBody") || name.equals("InnerBodySelection")) {
            List<NS3Compatible> innerBodyElements = parseInnerBody(ref, child);
            for (NS3Compatible ib : innerBodyElements) {
                addChildTag(ref, ib);
            }
        }
    }
    return mt;
}
Also used : LoopTag(com.dexels.navajo.document.navascript.tags.LoopTag) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) MapTag(com.dexels.navajo.document.navascript.tags.MapTag) NS3Compatible(com.dexels.navajo.document.navascript.tags.NS3Compatible)

Example 15 with MapTag

use of com.dexels.navajo.document.navascript.tags.MapTag in project navajo by Dexels.

the class NS3ToNSXML method parseMessage.

private MessageTag parseMessage(NS3Compatible parent, XMLElement currentXML) throws Exception {
    currentXML.setAttribute("PROCESSED", "true");
    Vector<XMLElement> children = currentXML.getChildren();
    MessageTag msgTag = new MessageTag(myNavascript);
    msgTag.addParent(parent);
    for (XMLElement child : children) {
        String name = child.getName();
        String content = (child.getContent() != null && !"".equals(child.getContent()) ? child.getContent() : null);
        if (name.equals("TOKEN") && content.equals("[")) {
            msgTag.setType(Message.MSG_TYPE_ARRAY);
        }
        if (name.equals("Conditional")) {
            ConditionFragment currentFragment = new ConditionFragment();
            consumeContent(currentFragment, child);
            msgTag.setCondition(currentFragment.consumedFragment());
        }
        if (name.equals("MappedArrayMessage")) {
            // <map ref="[]"
            MapTag mt = parsedMappedArrayMessage(null, child);
            msgTag.addMap(mt);
        }
        if (name.equals("MappedArrayField")) {
            // <map ref="$"
            MapTag maf = parseMappedArrayField(findClosestMapTag(parent, ""), child);
            msgTag.addMap(maf);
        }
        if (name.equals("MsgIdentifier")) {
            msgTag.setName(content);
        }
        if (name.equals("MessageArguments")) {
            parseMessageArguments(msgTag, child);
        }
        if (name.equals("InnerBody")) {
            List<NS3Compatible> innerBodyElements = parseInnerBody(msgTag, child);
            for (NS3Compatible ib : innerBodyElements) {
                addChildTag(msgTag, ib);
            }
        }
        if (name.equals("MessageArray")) {
            msgTag.setType(Message.MSG_TYPE_ARRAY);
            Vector<XMLElement> messageChildren = child.getChildren();
            int count = 0;
            for (XMLElement messageChild : messageChildren) {
                if (messageChild.getName().equals("MessageArrayElement")) {
                    MessageTag messageElt = parseMessage(parent, messageChild);
                    messageElt.setType(Message.MSG_TYPE_ARRAY_ELEMENT);
                    messageElt.setName(msgTag.getName());
                    messageElt.setIndex(count);
                    msgTag.addMessage(messageElt);
                    count++;
                }
            }
        }
    }
    return msgTag;
}
Also used : MessageTag(com.dexels.navajo.document.navascript.tags.MessageTag) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) MapTag(com.dexels.navajo.document.navascript.tags.MapTag) NS3Compatible(com.dexels.navajo.document.navascript.tags.NS3Compatible)

Aggregations

MapTag (com.dexels.navajo.document.navascript.tags.MapTag)15 CaseSensitiveXMLElement (com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement)12 XMLElement (com.dexels.navajo.document.nanoimpl.XMLElement)12 NS3Compatible (com.dexels.navajo.document.navascript.tags.NS3Compatible)7 FieldTag (com.dexels.navajo.document.navascript.tags.FieldTag)6 MessageTag (com.dexels.navajo.document.navascript.tags.MessageTag)5 ParamTag (com.dexels.navajo.document.navascript.tags.ParamTag)5 ExpressionTag (com.dexels.navajo.document.navascript.tags.ExpressionTag)4 IncludeTag (com.dexels.navajo.document.navascript.tags.IncludeTag)4 BlockTag (com.dexels.navajo.document.navascript.tags.BlockTag)3 BreakTag (com.dexels.navajo.document.navascript.tags.BreakTag)3 DebugTag (com.dexels.navajo.document.navascript.tags.DebugTag)3 DefineTag (com.dexels.navajo.document.navascript.tags.DefineTag)3 LogTag (com.dexels.navajo.document.navascript.tags.LogTag)3 LoopTag (com.dexels.navajo.document.navascript.tags.LoopTag)3 SynchronizedTag (com.dexels.navajo.document.navascript.tags.SynchronizedTag)3 BaseNode (com.dexels.navajo.document.base.BaseNode)2 FinallyTag (com.dexels.navajo.document.navascript.tags.FinallyTag)2 MethodsTag (com.dexels.navajo.document.navascript.tags.MethodsTag)2 NavascriptTag (com.dexels.navajo.document.navascript.tags.NavascriptTag)2