Mercurial > hg > ltpda
diff m-toolbox/classes/@LTPDAworkbench/mpl2jpl.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/classes/@LTPDAworkbench/mpl2jpl.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,72 @@ +% MPL2JPL converts a MATALB plist object into a java plist object. +% +% CALL: jpl = LTPDAworkbench.mpl2jpl(mpl) +% +% M Hewitson 13-11-08 +% +% $Id: mpl2jpl.m,v 1.15 2011/04/18 16:57:17 ingo Exp $ +% +function jpl = mpl2jpl(mpl) + % build java plist + if isempty(mpl) + jpl = mpipeline.plisttable.JPlist(''); + else + jpl = mpipeline.plisttable.JPlist(mpl.name); + for aa=1:numel(mpl.params) + pv = mpipeline.plisttable.JParamValue; + if isa(mpl.params(aa).val, 'paramValue') + options = mpl.params(aa).val.getOptions; + for ll=1:numel(options) + pval = convertVal(options{ll}); + type = class(pval); + pv.addOption(pval, type); + end + pv.setValIndex(mpl.params(aa).val.valIndex-1); + pv.setSelection(mpl.params(aa).val.selection); + else + pval = convertVal(mpl.params(aa).val); + pv.addOption(pval, class(pval)); + end + p = mpipeline.plisttable.JParam(mpl.params(aa).key, pv, mpl.params(aa).desc); + jpl.add(p); + end + end +end + +function jval = convertVal(val) + + if ischar(val) + jval = val; + elseif isnumeric(val) + if numel(val) == 1 + jval = val; + else + jval = utils.helper.mat2str(val); + end + elseif iscell(val) + jval = utils.prog.mcell2str(val); + elseif islogical(val) + if val + jval = true; + else + jval = false; + end + elseif isa(val, 'ltpda_nuo') + jval = string(val); + elseif isa(val, 'ltpda_uo') + try + jval = string(val); + catch + % The 'string' method will fail when the object have more than one + % history step. In this case build we a PLIST which constructs the + % object from the properties. + pl = val.generateConstructorPlist(); + jval = string(pl); + end + else + jval = char(val); + end + +end + +