gusucode.com > datatools工具箱 matlab源码程序 > datatools/inspector/matlab/+internal/+matlab/+inspector/Utils.m
classdef Utils % This class is unsupported and might change or be removed without % notice in a future version. % Utilities class used by the Property Inspector. % Copyright 2013-2015 The MathWorks, Inc. methods (Static = true) function s = createStructForObject(obj) % Creates a structure from a given object. This is used % instead of calling struct(obj) directly, because some objects % lie about their properties. For example, calling % properties(obj) is different than getting the metaclass % information for the class and looking at the public % properties in its PropertyList. The inspector looks at the % properties of the object, as if calling properties(obj). s = struct; p = properties(obj); for i = 1:length(p) propName = p{i}; try s.(propName) = obj.(propName); catch % Typically this won't fail, but it can sometimes with % dependent properties that become invalid (for % example, property d is determined by a+b, but b is a % matrix and b is a char array). Set to empty in this % case. s.(propName) = []; end end end % % The following functions are only used by the Java Desktop % Property Inspector % function state = compare(obj1,obj2,propName) % Java utility method for comparing a property shared by 2 % objects to determine if the property values are the same. state = isequal(get(obj1,propName),get(obj2,propName)); end function jobj = java(obj) if numel(obj)==1 jobj = java(obj); return end jobj = javaArray(class(java(obj(1))),numel(obj)); for k=1:numel(obj) jobj(k) = java(obj(k)); end end function outStr = getPossibleMessageCatalogString(inStr) l = lasterror; %#ok<LERR> try outStr = getString(message(inStr)); catch outStr = inStr; end lasterror(l); %#ok<LERR> end end end