Search in sources :

Example 1 with BaseCheckTagImpl

use of com.dexels.navajo.document.base.BaseCheckTagImpl in project navajo by Dexels.

the class NavascriptSaxHandler method text.

@Override
public void text(Reader r) throws Exception {
    StringWriter sw = new StringWriter();
    copyTextBuffer(sw, (PushbackReader) r);
    String text = sw.toString();
    BaseNode n = currentNode.lastElement();
    if (n instanceof BaseCheckTagImpl) {
        ((BaseCheckTagImpl) n).setRule(text);
    } else if (n instanceof BaseExpressionTagImpl) {
        ((BaseExpressionTagImpl) n).setConstant(text);
    } else if (n instanceof BaseFieldTagImpl) {
        ((BaseFieldTagImpl) n).setConstant(text);
    } else if (n instanceof ValueTag) {
        ((ValueTag) n).setValue(text);
    } else if (n instanceof DefineTag) {
        ((DefineTag) n).setExpression(text);
    } else {
        logger.info("Cannot place text under node, it must be a field tag. Correct.");
        if (currentNode.lastElement() instanceof MapTag) {
            currentMap.pop();
        } else {
            throw new Exception("Expected a MapTag to be corrected for a FieldTag not a " + currentNode.lastElement() + " tag.");
        }
        currentNode.pop();
        FieldTag ft = new FieldTag(currentMap.lastElement(), null, ((MapTag) n).getRefAttribute());
        ft.setConstant(text);
        BaseNode p = currentNode.lastElement();
        if (p instanceof MessageTag) {
            MessageTag mt = (MessageTag) p;
            mt.removeLastChild();
            mt.addField(ft);
        }
        currentNode.push(ft);
        currentField.push(ft);
    }
}
Also used : StringWriter(java.io.StringWriter) BaseCheckTagImpl(com.dexels.navajo.document.base.BaseCheckTagImpl) ValueTag(com.dexels.navajo.document.navascript.tags.ValueTag) DefineTag(com.dexels.navajo.document.navascript.tags.DefineTag) BaseNode(com.dexels.navajo.document.base.BaseNode) MessageTag(com.dexels.navajo.document.navascript.tags.MessageTag) FieldTag(com.dexels.navajo.document.navascript.tags.FieldTag) BaseExpressionTagImpl(com.dexels.navajo.document.base.BaseExpressionTagImpl) BaseFieldTagImpl(com.dexels.navajo.document.base.BaseFieldTagImpl) MapTag(com.dexels.navajo.document.navascript.tags.MapTag) IOException(java.io.IOException)

Aggregations

BaseCheckTagImpl (com.dexels.navajo.document.base.BaseCheckTagImpl)1 BaseExpressionTagImpl (com.dexels.navajo.document.base.BaseExpressionTagImpl)1 BaseFieldTagImpl (com.dexels.navajo.document.base.BaseFieldTagImpl)1 BaseNode (com.dexels.navajo.document.base.BaseNode)1 DefineTag (com.dexels.navajo.document.navascript.tags.DefineTag)1 FieldTag (com.dexels.navajo.document.navascript.tags.FieldTag)1 MapTag (com.dexels.navajo.document.navascript.tags.MapTag)1 MessageTag (com.dexels.navajo.document.navascript.tags.MessageTag)1 ValueTag (com.dexels.navajo.document.navascript.tags.ValueTag)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1