Search in sources :

Example 11 with NS3Compatible

use of com.dexels.navajo.document.navascript.tags.NS3Compatible 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

NS3Compatible (com.dexels.navajo.document.navascript.tags.NS3Compatible)11 CaseSensitiveXMLElement (com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement)10 XMLElement (com.dexels.navajo.document.nanoimpl.XMLElement)10 MapTag (com.dexels.navajo.document.navascript.tags.MapTag)7 BlockTag (com.dexels.navajo.document.navascript.tags.BlockTag)2 FieldTag (com.dexels.navajo.document.navascript.tags.FieldTag)2 IncludeTag (com.dexels.navajo.document.navascript.tags.IncludeTag)2 LoopTag (com.dexels.navajo.document.navascript.tags.LoopTag)2 MessageTag (com.dexels.navajo.document.navascript.tags.MessageTag)2 SynchronizedTag (com.dexels.navajo.document.navascript.tags.SynchronizedTag)2 BreakTag (com.dexels.navajo.document.navascript.tags.BreakTag)1 CommentBlock (com.dexels.navajo.document.navascript.tags.CommentBlock)1 DebugTag (com.dexels.navajo.document.navascript.tags.DebugTag)1 FinallyTag (com.dexels.navajo.document.navascript.tags.FinallyTag)1 LogTag (com.dexels.navajo.document.navascript.tags.LogTag)1 ParamTag (com.dexels.navajo.document.navascript.tags.ParamTag)1 ArrayList (java.util.ArrayList)1