annotate scripts/miscellaneous/ismethod.m @ 30564:796f54d4ddbf stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021. In all .txi and .texi files except gpl.txi and gpl.texi in the doc/liboctave and doc/interpreter directories, change the copyright to "Octave Project Developers", the same as used for other source files. Update copyright notices for 2022 (not done since 2019). For gpl.txi and gpl.texi, change the copyright notice to be "Free Software Foundation, Inc." and leave the date at 2007 only because this file only contains the text of the GPL, not anything created by the Octave Project Developers. Add Paul Thomas to contributors.in.
author John W. Eaton <jwe@octave.org>
date Tue, 28 Dec 2021 18:22:40 -0500
parents 7854d5752dd2
children 83f9f8bda883
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
3 ## Copyright (C) 2012-2022 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26779
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
26741
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 ##
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 ## This file is part of Octave.
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 ##
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 ## (at your option) any later version.
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 ##
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 ## GNU General Public License for more details.
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 ##
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
26741
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 ## -*- texinfo -*-
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 ## @deftypefn {} {} ismethod (@var{obj}, @var{method})
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 ## @deftypefnx {} {} ismethod (@var{class_name}, @var{method})
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 ## Return true if the string @var{method} is a valid method of the object
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 ## @var{obj} or of the class @var{clsname}.
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 ## @seealso{isprop, isobject, isjava, methods}
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 ## @end deftypefn
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 function retval = ismethod (obj, method)
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 if (nargin != 2)
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 print_usage ();
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 endif
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 if (! (ischar (obj) || isobject (obj) || isjava (obj)))
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 error ("ismethod: first argument must be object or class name");
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 endif
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 if (! ischar (method))
28924
975333a621c1 maint: capitalize input parameters in error() messages.
Rik <rik@octave.org>
parents: 27923
diff changeset
45 error ("ismethod: METHOD must be a string");
26741
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 endif
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 method_list = methods (obj);
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 retval = ismember (method, method_list);
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51
9cadeae949f2 make ismethod work for classdef and java objects (bug #55487)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 endfunction
26762
c4e53014f248 * ismethod.m: New tests.
John W. Eaton <jwe@octave.org>
parents: 26741
diff changeset
53
28931
c5b1bbb95a66 maint: start %!demo or %!test blocks 2 newlines after endfunction.
Rik <rik@octave.org>
parents: 28924
diff changeset
54
26777
52f42a818717 ismethod.m: Make test conditional on HAVE_JAVA.
Markus Mützel <markus.muetzel@gmx.de>
parents: 26762
diff changeset
55 %!testif HAVE_JAVA; usejava ("jvm")
26779
1218f6fa3856 ismethod.m: Add ';' to BIST test in cset 52f42a818717.
Rik <rik@octave.org>
parents: 26777
diff changeset
56 %! assert (ismethod (javaObject ("java.lang.String", "Yo"), "hashCode"));
26777
52f42a818717 ismethod.m: Make test conditional on HAVE_JAVA.
Markus Mützel <markus.muetzel@gmx.de>
parents: 26762
diff changeset
57
26762
c4e53014f248 * ismethod.m: New tests.
John W. Eaton <jwe@octave.org>
parents: 26741
diff changeset
58 %!assert (ismethod (ftp (), "ascii"))
c4e53014f248 * ismethod.m: New tests.
John W. Eaton <jwe@octave.org>
parents: 26741
diff changeset
59 %!assert (ismethod (inputParser (), "addRequired"))