Search in sources :

Example 81 with XMLElement

use of com.dexels.navajo.document.nanoimpl.XMLElement in project navajo by Dexels.

the class NS3ToNSXML method parseConditionalBlock.

private BlockTag parseConditionalBlock(NS3Compatible parent, XMLElement currentXML, boolean isEmptyMessage) throws Exception {
    BlockTag bt = new BlockTag(myNavascript);
    bt.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);
            bt.setCondition(currentFragment.consumedFragment());
        }
        if (name.equals("InnerBody")) {
            List<NS3Compatible> innerBodyElements = parseInnerBody(bt, child);
            for (NS3Compatible ib : innerBodyElements) {
                addChildTag(bt, ib);
            }
        }
    }
    return bt;
}
Also used : BlockTag(com.dexels.navajo.document.navascript.tags.BlockTag) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) NS3Compatible(com.dexels.navajo.document.navascript.tags.NS3Compatible)

Example 82 with XMLElement

use of com.dexels.navajo.document.nanoimpl.XMLElement 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)

Example 83 with XMLElement

use of com.dexels.navajo.document.nanoimpl.XMLElement in project navajo by Dexels.

the class NS3ToNSXML method parseSynchronizedArguments.

private void parseSynchronizedArguments(String key, SynchronizedTag p, XMLElement currentXML) {
    currentXML.setAttribute("PROCESSED", "true");
    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("SContextType")) {
            p.setContext(content);
        }
        if (name.equals("SKey")) {
            key = "key";
        }
        if (name.equals("STimeout")) {
            key = "timeout";
        }
        if (name.equals("SBreakOnNoLock")) {
            key = "breakOnNoLock";
        }
        if (name.equals("LiteralOrExpression") || name.equals("Expression")) {
            String c = null;
            if (name.equals("Expression")) {
                ExpressionFragment ef = new ExpressionFragment();
                consumeContent(ef, child);
                c = ef.consumedFragment();
            } else {
                if (isLiteral(child)) {
                    c = parseStringConstant(child);
                } else {
                    c = parseExpression(child);
                }
            }
            if (key != null) {
                if (key.equals("key")) {
                    p.setKey(c);
                }
                if (key.equals("timeout")) {
                    p.setTimeout(c);
                }
                if (key.equals("breakOnNoLock")) {
                    p.setBreakOnNoLock(c);
                }
            }
            key = null;
        }
        parseSynchronizedArguments(key, p, child);
    }
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 84 with XMLElement

use of com.dexels.navajo.document.nanoimpl.XMLElement in project navajo by Dexels.

the class NS3ToNSXML method parsePropertyArguments.

private void parsePropertyArguments(PropertyTag p, XMLElement currentXML) {
    currentXML.setAttribute("PROCESSED", "true");
    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("PropertyTypeValue")) {
            p.setType(content);
        }
        if (name.equals("PropertyDirectionValue")) {
            p.setDirection(content);
        }
        if (name.equals("PropertyCardinalityValue")) {
            p.setCardinality(content);
        }
        if (name.equals("PropertyDescription")) {
            boolean isLiteral = isLiteral(child);
            if (isLiteral) {
                p.setDescription(parseStringConstant(child));
            }
        }
        parsePropertyArguments(p, child);
    }
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 85 with XMLElement

use of com.dexels.navajo.document.nanoimpl.XMLElement in project navajo by Dexels.

the class NS3ToNSXML method parseAdapterMethod.

private void parseAdapterMethod(FieldTag parent, XMLElement currentXML) {
    // MethodName
    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("MethodName")) {
            parent.setFieldName(content);
        }
        if (name.equals("KeyValueArguments")) {
            parseMapOrMethodArguments(parent, child);
        }
    }
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Aggregations

XMLElement (com.dexels.navajo.document.nanoimpl.XMLElement)120 CaseSensitiveXMLElement (com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement)109 MapTag (com.dexels.navajo.document.navascript.tags.MapTag)12 IOException (java.io.IOException)12 NS3Compatible (com.dexels.navajo.document.navascript.tags.NS3Compatible)10 ArrayList (java.util.ArrayList)8 ParamTag (com.dexels.navajo.document.navascript.tags.ParamTag)7 InputStreamReader (java.io.InputStreamReader)7 HashMap (java.util.HashMap)7 APIException (com.dexels.navajo.article.APIException)6 ExpressionTag (com.dexels.navajo.document.navascript.tags.ExpressionTag)5 FieldTag (com.dexels.navajo.document.navascript.tags.FieldTag)5 FileInputStream (java.io.FileInputStream)5 FileReader (java.io.FileReader)5 Property (com.dexels.navajo.document.Property)4 IncludeTag (com.dexels.navajo.document.navascript.tags.IncludeTag)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 File (java.io.File)4 Message (com.dexels.navajo.document.Message)3 BlockTag (com.dexels.navajo.document.navascript.tags.BlockTag)3