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

com.alogic.xscript.plugins.IfExist 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.XsObject;
import com.anysoft.util.Properties;
import com.anysoft.util.PropertiesConstants;

/**
 * 如果某个变量存在,则执行
 * @author yyduan
 *
 * @since 1.6.10.9
 */
public class IfExist extends Segment{
	protected String id = "";
	
	public IfExist(String tag, Logiclet p) {
		super(tag, p);
	}	
	
	@Override
	public void configure(Properties p){
		super.configure(p);
		id = PropertiesConstants.getRaw(p,"id",id);
	}

	@Override
	protected void onExecute(XsObject root,XsObject current, LogicletContext ctx,
			ExecuteWatcher watcher) {
		String varId = PropertiesConstants.transform(ctx, id,"");
		if (StringUtils.isNotEmpty(varId)){
			String value = PropertiesConstants.getString(ctx,varId,"");
			if (StringUtils.isNotEmpty(value)){
				super.onExecute(root, current, ctx, watcher);
			}
		}
	}	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy