Scilab Home page | Wiki | Bug tracker | Forge | Mailing list archives | ATOMS | File exchange
Please login or create an account
Change language to: Français - Português - Русский - 日本語
Scilab Help >> Java from Scilab > jgetfield

jgetfield

Get the field value of a Java object

Syntax

jgetfield(object, fieldName [, unwrap])

Parameters

object

A mlist typed _JObj or _JClass or a Scilab variable

fieldName

A string giving the field name

unwrap

A single boolean

Description

Get the value of the field named fieldName. If the optional third argument is true, then the value is automatically unwrapped.

This function also works with beans properties which may not be mapped to a public java field.

Examples

c = jcompile("Test", ["public class Test {";
                      "public int field;";
                      "public Test(int n) {";
                      "field = n;";
                      "}";
                      "}";]);
t = c.new(128);
v = jgetfield(t, "field")

// or easier
t.field

jremove c t v;
jimport java.util.Date;

d = Date.new();
d.minutes, // will call d.getMinutes()
jgetfield(d, "minutes"), // will also call d.getMinutes()

jremove Date d;

See Also

History

VersionDescription
5.5.0 Function introduced. Based on the 'JIMS' module. The main difference in the behavior compared to the JIMS module is that jautoUnwrap is enabled by default.
Scilab Enterprises
Copyright (c) 2011-2015 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Wed Jun 15 08:27:54 CEST 2016