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

Please note that the recommended version of Scilab is 6.0.1. This page might be outdated.
See the recommended documentation of this function

Ajuda do Scilab >> Java from Scilab > jsetfield

jsetfield

Set the field of a Java object

Syntax

jsetfield(object, fieldName, value)

Parameters

object

A mlist typed _JObj or _JClass or a Scilab variable

fieldName

A string giving the field name

value

A Scilab variable or mlist typed _JObj as new field value

Description

Set the field named fieldName to the given value.

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);
t.field
jsetfield(t, "field", 256);
t.field

// But it is easier to use...
t.field = 512;
t.field
jremove c t;
jimport java.util.Date;

d = Date.new();
d.minutes = 3; // will call d.setMinutes(3);
jsetfield(d, "minutes", 3); // will call d.setMinutes(3);

jremove Date d;

See also

  • jgetfield — Get the field value of a Java object

History

VersãoDescrição
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-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Feb 14 15:09:57 CET 2017