Search in sources :

Example 1 with XMLElement

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

the class NS3ToNSXML method parseAdapterField.

private void parseAdapterField(FieldTag parent, XMLElement currentXML) throws Exception {
    // MethodName
    Vector<XMLElement> children = currentXML.getChildren();
    parent.setOldSkool(true);
    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);
            parent.setCondition(currentFragment.consumedFragment());
        }
        if (name.equals("FieldName")) {
            parent.setFieldName(content);
        }
        if (name.equals("ConditionalExpressions")) {
            List<ExpressionTag> expressions = parseConditionalExpressions(parent, child);
            for (ExpressionTag et : expressions) {
                parent.addExpression(et);
            }
        }
        if (name.equals("MappedArrayField")) {
            // <map ref="$"
            MapTag maf = parseMappedArrayField((MapTag) parent.getParent(), child);
            parent.addMap(maf);
        }
        if (name.equals("MappedMessage")) {
            // map ref="[/@]"
            MapTag mt = parseMappedMessage(parent, child);
            parent.addMap(mt);
        }
        if (name.equals("MappedArrayMessage")) {
            MapTag mt = parsedMappedArrayMessage(parent, child);
            parent.addMap(mt);
        }
        if (name.equals("StringConstant")) {
            String c = content.replaceAll("\"", "");
            ExpressionTag et = new ExpressionTag(myNavascript);
            et.setConstant(c);
            parent.addExpression(et);
        }
    }
}
Also used : ExpressionTag(com.dexels.navajo.document.navascript.tags.ExpressionTag) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) MapTag(com.dexels.navajo.document.navascript.tags.MapTag)

Example 2 with XMLElement

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

the class NS3ToNSXML method parseBreakParameters.

private void parseBreakParameters(BreakTag p, XMLElement currentXML) {
    currentXML.setAttribute("PROCESSED", "true");
    Vector<XMLElement> children = currentXML.getChildren();
    String parameter = null;
    for (XMLElement child : children) {
        String name = child.getName();
        String content = (child.getContent() != null && !"".equals(child.getContent()) ? child.getContent() : null);
        if (name.equals("BreakParameter")) {
            parseBreakParameters(p, child);
        }
        if (name.equals("TOKEN") && content.trim().equals("code")) {
            parameter = "code";
        }
        if (name.equals("TOKEN") && content.trim().equals("description")) {
            parameter = "description";
        }
        if (name.equals("LiteralOrExpression")) {
            String c = null;
            if (isLiteral(child)) {
                c = parseStringConstant(child);
            } else {
                c = parseExpression(child);
            }
            if (parameter != null) {
                if (parameter.equals("code")) {
                    p.setConditionId(c);
                } else if (parameter.equals("description")) {
                    p.setConditionDescription(c);
                }
            }
            parameter = null;
        }
    }
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 3 with XMLElement

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

the class NS3ToNSXML method parseInnerBody.

private List<NS3Compatible> parseInnerBody(NS3Compatible parent, XMLElement currentXML) throws Exception {
    currentXML.setAttribute("PROCESSED", "true");
    List<NS3Compatible> bodyElts = new ArrayList<>();
    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("Print")) {
            DebugTag pt = parsePrint(parent, child);
            bodyElts.add(pt);
        }
        if (name.equals("Log")) {
            LogTag pt = parseLog(parent, child);
            bodyElts.add(pt);
        }
        if (name.equals("Property")) {
            NS3Compatible pt = parseProperty(parent, child);
            bodyElts.add(pt);
        }
        if (name.equals("Option")) {
            // Find type of option: name, value or selected
            NS3Compatible pt = parseProperty(parent, child);
            bodyElts.add(pt);
        }
        if (name.equals("Map")) {
            MapTag mt = parseMap(parent, child);
            bodyElts.add(mt);
        }
        if (name.equals("Var")) {
            ParamTag pt = parseVar(parent, child);
            bodyElts.add(pt);
        }
        if (name.equals("Break")) {
            BreakTag mt = parseBreak(parent, child);
            bodyElts.add(mt);
        }
        if (name.equals("Include")) {
            IncludeTag mt = parseInclude(parent, child);
            bodyElts.add(mt);
        }
        if (name.equals("Message")) {
            MessageTag pt = parseMessage(parent, child);
            bodyElts.add(pt);
        }
        if (name.equals("Synchronized")) {
            SynchronizedTag st = parseSynchronizedBlock(parent, child);
            bodyElts.add(st);
        }
        if (name.equals("ConditionalEmptyMessage")) {
            BlockTag pt = parseConditionalBlock(parent, child, true);
            bodyElts.add(pt);
        }
        if (name.equals("TopLevelStatement")) {
            bodyElts.addAll(parseInnerBody(parent, child));
        }
        if (name.equals("MethodOrSetter")) {
            MapTag parentMap = findClosestMapTag(parent, "");
            FieldTag ft = parseMethodOrSetter(parentMap, child);
            bodyElts.add(ft);
        }
        if (name.equals("Loop")) {
            LoopTag mt = parseLoop(parent, child);
            bodyElts.add(mt);
        }
    }
    return bodyElts;
}
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) ArrayList(java.util.ArrayList) 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) NS3Compatible(com.dexels.navajo.document.navascript.tags.NS3Compatible) MapTag(com.dexels.navajo.document.navascript.tags.MapTag) BlockTag(com.dexels.navajo.document.navascript.tags.BlockTag) IncludeTag(com.dexels.navajo.document.navascript.tags.IncludeTag) MessageTag(com.dexels.navajo.document.navascript.tags.MessageTag) FieldTag(com.dexels.navajo.document.navascript.tags.FieldTag) SynchronizedTag(com.dexels.navajo.document.navascript.tags.SynchronizedTag)

Example 4 with XMLElement

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

the class NS3ToNSXML method parsedMappedArrayMessage.

private MapTag parsedMappedArrayMessage(NS3Compatible parent, XMLElement currentXML) throws Exception {
    MapTag mapTag = new MapTag(myNavascript);
    mapTag.addParent(parent);
    Vector<XMLElement> children = currentXML.getChildren();
    mapTag.setOldStyleMap(true);
    if (parent != null && parent instanceof FieldTag) {
        mapTag.setName(((FieldTag) parent).getParent().getObject());
    }
    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("MsgIdentifier")) {
            mapTag.setRefAttribute("[" + content + "]");
        }
        if (name.equals("TOKEN") && content.equals("filter")) {
            hasFilter = true;
        }
        if (hasFilter && name.equals("Expression")) {
            ExpressionFragment ef = new ExpressionFragment();
            consumeContent(ef, child);
            mapTag.setFilter(ef.consumedFragment());
        }
        if (name.equals("InnerBody") || name.equals("InnerBodySelection")) {
            List<NS3Compatible> innerBodyElements = parseInnerBody(mapTag, child);
            for (NS3Compatible ib : innerBodyElements) {
                addChildTag(mapTag, ib);
            }
        }
    }
    return mapTag;
}
Also used : FieldTag(com.dexels.navajo.document.navascript.tags.FieldTag) 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 5 with XMLElement

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

the class NS3ToNSXML method parseMapOrMethodArguments.

private void parseMapOrMethodArguments(NS3Compatible parent, XMLElement currentXML) {
    Vector<XMLElement> children = currentXML.getChildren();
    String key = null;
    for (XMLElement child : children) {
        String name = child.getName();
        String content = (child.getContent() != null && !"".equals(child.getContent()) ? child.getContent() : null);
        if (name.equals("ParamKeyName")) {
            key = content;
        }
        if (name.equals("LiteralOrExpression")) {
            String c = null;
            if (isLiteral(child)) {
                c = parseStringConstant(child);
            } else {
                c = parseExpression(child);
            }
            if (key != null) {
                if (parent instanceof MapTag) {
                    ((MapTag) parent).addAttributeNameValue(key, c);
                }
                if (parent instanceof FieldTag) {
                    ((FieldTag) parent).addAttributeNameValue(key, c);
                }
            }
            key = null;
        }
    }
}
Also used : FieldTag(com.dexels.navajo.document.navascript.tags.FieldTag) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) MapTag(com.dexels.navajo.document.navascript.tags.MapTag)

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