Scripting Module - Some Question

Let me offer something simpler:

public class Datasets {

	protected static final Pattern munger = Pattern.compile("\\W+");
	public static String mungeColumnName(@ScriptArg("columnname") String columnName) {
		String munged = munger.matcher(columnName).replaceAll("_");
		if (Character.isDigit(munged.charAt(0)))
			return "_"+munged;
		return munged;
	}

	public static final Class<?> TransientDataset = TransientDataset.class;
}

This shows a dead-simple class containing only statics to expose. One is a function, the other is a class. (The latter’s constructors and static fields are trivial to use in jython having that one-line.)

The above is added to a script manager with this:

		manager.addScriptModule("system.dataset", Datasets.class, new MetaDocProvider("Datasets"));

(My MetaDocProvider just looks up functions and arguments in the shared localization bundle.)

Pssst! Simulation Aids is free…

2 Likes