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 java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alogic.xscript.ExecuteWatcher;
import com.alogic.xscript.Logiclet;
import com.alogic.xscript.LogicletContext;
import com.anysoft.util.Properties;
import com.anysoft.util.PropertiesConstants;

/**
 * 为数组增加子项
 * 
 * @author duanyy
 *
 */
public class ArrayItem extends Segment {
	protected String id = "$array";
	
	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);
	}
	
	protected void onExecute(Map root,
			Map current, LogicletContext ctx, ExecuteWatcher watcher) {
		List list = ctx.getObject(id);
		if (list != null){
			Map template = new HashMap();
			list.add(template);
			super.onExecute(root, (Map)template, ctx, watcher);			
		}
	}	
}