Search in sources :

Example 6 with XMLElement

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

the class NS3ToNSXML method parseMethodOrSetter.

private FieldTag parseMethodOrSetter(MapTag parent, XMLElement currentXML) throws Exception {
    FieldTag ft = new FieldTag(parent);
    ft.setParent(parent);
    ft.addParent(parent);
    Vector<XMLElement> children = currentXML.getChildren();
    for (XMLElement child : children) {
        String name = child.getName();
        if (name.equals("Conditional")) {
            ConditionFragment currentFragment = new ConditionFragment();
            consumeContent(currentFragment, child);
            ft.setCondition(currentFragment.consumedFragment());
        }
        if (name.equals("AdapterMethod")) {
            parseAdapterMethod(ft, child);
        }
        if (name.equals("SetterField")) {
            parseAdapterField(ft, child);
        }
    }
    return ft;
}
Also used : FieldTag(com.dexels.navajo.document.navascript.tags.FieldTag) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 7 with XMLElement

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

the class NS3ToNSXML method parseVarArrayElement.

private ParamTag parseVarArrayElement(ParamTag parent, XMLElement currentXML) throws Exception {
    ParamTag paramElt = new ParamTag(myNavascript);
    paramElt.setType(Message.MSG_TYPE_ARRAY_ELEMENT);
    Vector<XMLElement> children = currentXML.getChildren();
    for (XMLElement child : children) {
        String name = child.getName();
        if (name.equals("Var")) {
            ParamTag pt = parseVar(paramElt, child);
            paramElt.addParam(pt);
        }
    }
    return paramElt;
}
Also used : ParamTag(com.dexels.navajo.document.navascript.tags.ParamTag) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 8 with XMLElement

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

the class NS3ToNSXML method parseConditionalExpressions.

/**
 * parent is ParamTag or PropertyTag or FieldTag
 *
 * Conditional
 * Expression
 * Conditional
 * TOKEN else
 * Expression
 *
 * @param parent
 * @param xe
 */
private List<ExpressionTag> parseConditionalExpressions(NS3Compatible parent, XMLElement currentXML) {
    List<ExpressionTag> expressions = new ArrayList<>();
    currentXML.setAttribute("PROCESSED", "true");
    Vector<XMLElement> children = currentXML.getChildren();
    ConditionFragment conditionFragment = null;
    for (XMLElement child : children) {
        String name = child.getName();
        String content = (child.getContent() != null && !"".equals(child.getContent()) ? child.getContent() : null);
        if (name.equals("Conditional")) {
            conditionFragment = new ConditionFragment();
            consumeContent(conditionFragment, child);
        }
        if (name.equals("StringConstant")) {
            String constant = content.replaceAll("\"", "");
            ExpressionTag et = new ExpressionTag(myNavascript);
            if (conditionFragment != null) {
                et.setCondition(conditionFragment.consumedFragment());
            }
            et.setConstant(constant);
            expressions.add(et);
            conditionFragment = null;
        }
        if (name.equals("Expression")) {
            ExpressionFragment ef = new ExpressionFragment();
            consumeContent(ef, child);
            ExpressionTag et = new ExpressionTag(myNavascript);
            if (conditionFragment != null) {
                et.setCondition(conditionFragment.consumedFragment());
            }
            et.setValue(ef.consumedFragment());
            expressions.add(et);
            conditionFragment = null;
        }
        if (name.equals("TOKEN") && content.trim().equals("else")) {
            conditionFragment = null;
        }
    }
    return expressions;
}
Also used : ArrayList(java.util.ArrayList) ExpressionTag(com.dexels.navajo.document.navascript.tags.ExpressionTag) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 9 with XMLElement

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

the class NS3ToNSXML method parseMappedMessage.

private MapTag parseMappedMessage(NS3Compatible parent, XMLElement currentXML) throws Exception {
    MapTag mapTag = new MapTag(myNavascript);
    mapTag.setOldStyleMap(true);
    mapTag.setName("map");
    mapTag.setRefAttribute("[/@]");
    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("InnerBody")) {
            List<NS3Compatible> innerBodyElements = parseInnerBody(mapTag, child);
            for (NS3Compatible ib : innerBodyElements) {
                addChildTag(mapTag, ib);
            }
        }
    }
    return mapTag;
}
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 10 with XMLElement

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

the class NS3ToNSXML method parseNavascript.

public InputStream parseNavascript(String fileContent) throws Exception {
    navascript parser = new navascript(fileContent, this);
    input = fileContent;
    parser.parse_Navascript();
    String result = xmlString.toString();
    // System.err.println(result);
    XMLElement xe = new CaseSensitiveXMLElement(true);
    xe.parseString(result);
    parseXML(myNavascript, xe, 0);
    PipedInputStream in = new PipedInputStream();
    PipedOutputStream out = new PipedOutputStream(in);
    new Thread() {

        public void run() {
            myNavascript.write(out);
            try {
                out.close();
            } catch (IOException e) {
                logger.error(e.getLocalizedMessage(), e);
            }
        }
    }.start();
    return in;
}
Also used : com.dexels.navajo.mapping.compiler.navascript.parser.navascript(com.dexels.navajo.mapping.compiler.navascript.parser.navascript) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) IOException(java.io.IOException) 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