view m-toolbox/classes/@paramValue/setProperty.m @ 33:5e7477b94d94 database-connection-manager

Add known repositories list to LTPDAPreferences
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% SETPROPERTY set a property to a paramValue
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: SETPROPERTY set a property to a paramValue. If the property
%              name exists then replace the value otherwise add this
%              property.
%
% CALL:        obj = obj.setProperty(propertyName, value);
%
% INPUTS:      propertyName: Property name of the paramValue object
%              value:        Value of the property
%
% VERSION:     $Id: setProperty.m,v 1.2 2010/09/28 17:49:27 ingo Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function obj = setProperty(obj, propertyName, value)
  
  if nargin ~= 3
    error('### This method works only with three inputs.');
  end
  
  obj = copy(obj, nargout);

  if isempty(obj.property)
    % ATTENTION: It is necessary for the STRUCT method to use a different
    %            command if the value is a cell.
    if iscell(value)
      obj.property = struct(propertyName, {value});
    else
      obj.property = struct(propertyName, value);
    end
  else
    obj.property.(propertyName) = value;
  end
  
end