| External Interfaces/API | ![]() |
Finding the Public Data Fields of an Object
To list the public fields that belong to a Java object, use the fieldnames function, which takes either of these forms
names = fieldnames(obj) names = fieldnames(obj,'-full')
Calling fieldnames without '-full' returns the names of all the data fields (including inherited) on the object. With the '-full' qualifier, fieldnames returns the full description of the data fields defined for the object, including type, attributes, and inheritance information.
Suppose, for example, that you constructed a Frame object with
frame = java.awt.Frame;
To obtain the full description of the data fields on frame, you could use the command
fieldnames(frame,'-full')
Sample output from this command follows:
ans =
'static final int WIDTH
% Inherited from java.awt.image.ImageObserver'
'static final int HEIGHT
% Inherited from java.awt.image.ImageObserver'
[1x74 char]
'static final int SOMEBITS
% Inherited from java.awt.image.ImageObserver'
'static final int FRAMEBITS
% Inherited from java.awt.image.ImageObserver'
'static final int ALLBITS
% Inherited from java.awt.image.ImageObserver'
'static final int ERROR
% Inherited from java.awt.image.ImageObserver'
'static final int ABORT
% Inherited from java.awt.image.ImageObserver'
'static final float TOP_ALIGNMENT
% Inherited from java.awt.Component'
'static final float CENTER_ALIGNMENT
% Inherited from java.awt.Component'
'static final float BOTTOM_ALIGNMENT
% Inherited from java.awt.Component'
'static final float LEFT_ALIGNMENT
% Inherited from java.awt.Component'
'static final float RIGHT_ALIGNMENT
% Inherited from java.awt.Component'
.
.
.
| Saving and Loading Java Objects to MAT-Files | Accessing Private and Public Data | ![]() |