All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alogic.xscript.plugins.ArrayItem Maven / Gradle / Ivy

There is a newer version: 1.6.17
Show newest version
package com.alogic.xscript.plugins;

import org.apache.commons.lang3.StringUtils;

import com.alogic.xscript.ExecuteWatcher;
import com.alogic.xscript.Logiclet;
import com.alogic.xscript.LogicletContext;
import com.alogic.xscript.doc.XsArray;
import com.alogic.xscript.doc.XsObject;
import com.anysoft.util.Properties;
import com.anysoft.util.PropertiesConstants;

/**
 * 为数组增加子项
 * 
 * @author duanyy
 * @version 1.6.8.14 [20170509 duanyy] 
* - 增加xscript的中间文档模型,以便支持多种报文协议
* * @version 1.6.9.3 [20170615 duanyy]
* - 当文档为空的时候,不加入到父节点中
* * @version 1.6.12.4 [20171029 duanyy]
* - 支持bridge机制;
*/ public class ArrayItem extends Segment { protected String id = "$array"; protected String $bridgeId = ""; public ArrayItem(String tag, Logiclet p) { super(tag, p); } @Override public void configure(Properties p){ super.configure(p); id = PropertiesConstants.getString(p,"id",id,true); $bridgeId = PropertiesConstants.getRaw(p,"bridge",""); } protected void onExecute(XsObject root,XsObject current, LogicletContext ctx, ExecuteWatcher watcher) { XsArray list = ctx.getObject(id); if (list != null){ XsObject template = list.newObject(); String bridgeId = PropertiesConstants.transform(ctx, $bridgeId, ""); try { if (StringUtils.isNotEmpty(bridgeId)){ ctx.setObject(bridgeId, template); } super.onExecute(root, template, ctx, watcher); if (!template.isNull()){ list.add(template); } }finally{ if (StringUtils.isNotEmpty(bridgeId)){ ctx.removeObject(bridgeId); } } } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy