<?xml version="1.0" encoding="UTF-8"?>
<!--
*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2010 - 2011 - Calixte DENIZET <calixte@contrib.scilab.org>
*
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
*
*
-->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" version="5.0-subset Scilab" xml:lang="en" xml:id="jgetfield">
    <refnamediv>
        <refname>jgetfield</refname>
        <refpurpose>Get the field value of a Java object</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>
            jgetfield(object, fieldName [, unwrap])
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Parameters</title>
        <variablelist>
            <varlistentry>
                <term>object</term>
                <listitem>
                    <para>A mlist typed _JObj or _JClass or a Scilab variable</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>fieldName</term>
                <listitem>
                    <para>A string giving the field name</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>unwrap</term>
                <listitem>
                    <para>A single boolean</para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            Get the value of the field named fieldName. If the optional third argument is true, then the value is automatically unwrapped.
        </para>
        <para>
            This function also works with beans properties which may not be mapped to a public java field.
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
               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;
      ]]></programlisting>
        <programlisting role="example"><![CDATA[
jimport java.util.Date;

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

jremove Date d;
      ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="jsetfield">jsetfield</link>
            </member>
        </simplelist>
    </refsection>
    <refsection>
        <title>History</title>
        <revhistory>
            <revision>
                <revnumber>5.5.0</revnumber>
                <revremark>
                    Function introduced. Based on the 'JIMS' module. The main difference in the behavior compared to the JIMS module is that <link linkend="jautoUnwrap">jautoUnwrap</link> is enabled by default.
                </revremark>
            </revision>
        </revhistory>
    </refsection>
</refentry>

