Home > classes > @timespan > string.m

string

PURPOSE ^

STRING writes a command string that can be used to recreate the input timespan object.

SYNOPSIS ^

function cmd = string(objs, varargin)

DESCRIPTION ^

 STRING writes a command string that can be used to recreate the input timespan object.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: STRING writes a command string that can be used to recreate the
              input timespan object.

 CALL:        cmd = string(obj)

 INPUT:       obj - timespan object

 OUTPUT:      cmd - command string to create the input object

 VERSION:     $Id: string.m,v 1.2 2008/02/23 19:49:11 hewitson Exp $

 HISTORY:     15-02-2008 Diepholz
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function cmd = string(objs, varargin)
0002 % STRING writes a command string that can be used to recreate the input timespan object.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: STRING writes a command string that can be used to recreate the
0007 %              input timespan object.
0008 %
0009 % CALL:        cmd = string(obj)
0010 %
0011 % INPUT:       obj - timespan object
0012 %
0013 % OUTPUT:      cmd - command string to create the input object
0014 %
0015 % VERSION:     $Id: string.m,v 1.2 2008/02/23 19:49:11 hewitson Exp $
0016 %
0017 % HISTORY:     15-02-2008 Diepholz
0018 %                 Creation
0019 %
0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0021 
0022 VERSION  = '$Id: string.m,v 1.2 2008/02/23 19:49:11 hewitson Exp $';
0023 CATEGORY = 'Output';
0024 
0025 % Check if this is a call for parameters
0026 if nargin == 2
0027   if isa(objs, 'timespan') && ischar(varargin{1})
0028     in = char(varargin{1});
0029     if strcmp(in, 'Params')
0030       cmd = plist;
0031       return
0032     elseif strcmp(in, 'Version')
0033       cmd = VERSION;
0034       return
0035     elseif strcmp(in, 'Category')
0036       cmd = CATEGORY;
0037       return
0038     end
0039   end
0040 end
0041 
0042 
0043 %%% Wrap the command only in bracket if the there are more than one object
0044 if length(objs) > 1
0045   cmd = '[';
0046 else
0047   cmd = '';
0048 end
0049 
0050 for j=1:length(objs)
0051   obj = objs(j);
0052   if ~isempty(obj.plist)
0053     cmd = [cmd sprintf('timespan(%s)', string(obj.plist))];
0054   else
0055     ts_start    = obj.start;
0056     ts_end      = obj.end;
0057     ts_timezone = obj.timezone;
0058     ts_format   = obj.timeformat;
0059 
0060     %% Convert the java object into a string
0061     ts_timezone = char(ts_timezone.getID);
0062 
0063     cmd = [cmd 'timespan( plist(''start'', '''       char(ts_start) ''', ' ...
0064       '''end'', '''         char(ts_end)   ''', ' ...
0065       '''timezone'', '''       ts_timezone ''', ' ...
0066       '''timeformat'', ''' char(ts_format) ''') ) '];
0067   end
0068 end
0069 
0070 if length(objs) > 1
0071   cmd = [cmd ']'];
0072 end
0073 
0074 % END

Generated on Mon 31-Mar-2008 13:54:54 by m2html © 2003