Codemesh Runtime v3 C++ API Reference  3.9.205
Public Member Functions | Friends | List of all members
xmog_java_field Class Reference

A class implementing the xmog_java_dynamic interface for accessing Java fields via JNI or Codemesh's remoting protocol. More...

#include <xmog_java_field.h>

Inheritance diagram for xmog_java_field:
Inheritance graph
[legend]
Collaboration diagram for xmog_java_field:
Collaboration graph
[legend]

Public Member Functions

 xmog_java_field (xmog_java_class *clazz, jfieldID fid, bool bStatic=false)
 The constructor that takes an externally calculated jfieldID as input. More...
 
 xmog_java_field (xmog_java_class *clazz, const char *name, const char *type, bool bStatic=false)
 The constructor that takes all information required to calculate a jfieldID as input. More...
 
 ~xmog_java_field ()
 Removes the field instance from the declaring class' list of fields.
 
void * operator new (size_t)
 Overloaded operator new that allows us to detect whether the instance is heap-allocated or not.
 
void operator delete (void *)
 Overloaded operator delete that is safe to use for non heap-allocated instances.
 
xmog_java_fieldnext ()
 Returns the next field declared by the same type.
 
xmog_java_classclazz ()
 Returns the declaring class.
 
const char * name ()
 Returns the field's name.
 
const char * type ()
 Returns the field's type in internal form.
 
bool is_static () const
 Returns true if the field is static, false otherwise.
 
void set_fieldID (jfieldID fid)
 Sets the field's ID. More...
 
jfieldID get_fieldID ()
 Returns the field's ID.
 
int initializeFieldID (xmog_localenv *env)
 Calculates the fieldID based on the information maintained by this instance. More...
 
virtual bool get_bool (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Returns the value of a boolean field. More...
 
virtual jboolean get_jboolean (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Returns the value of a boolean field. More...
 
virtual jbyte get_byte (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Returns the value of a byte field. More...
 
virtual jchar get_char (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Returns the value of a char field. More...
 
virtual jdouble get_double (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Returns the value of a double field. More...
 
virtual jfloat get_float (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Returns the value of a float field. More...
 
virtual jint get_int (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Returns the value of an int field. More...
 
virtual jlong get_long (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Returns the value of a long field. More...
 
virtual jshort get_short (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Returns the value of a short field. More...
 
virtual jobject get_jobject (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=xmog_base::GLOBAL)
 Returns the value of an object field. More...
 
virtual void get_void (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Not implemented for this type. More...
 
virtual void set_bool (xmog_base *obj, bool b, xmog_localenv *env=NULL)
 Sets the value of a boolean field. More...
 
virtual void set_jboolean (xmog_base *obj, jboolean b, xmog_localenv *env=NULL)
 Sets the value of a boolean field. More...
 
virtual void set_byte (xmog_base *obj, jbyte b, xmog_localenv *env=NULL)
 Sets the value of a byte field. More...
 
virtual void set_char (xmog_base *obj, jchar ch, xmog_localenv *env=NULL)
 Sets the value of a char field. More...
 
virtual void set_double (xmog_base *obj, jdouble d, xmog_localenv *env=NULL)
 Sets the value of a double field. More...
 
virtual void set_float (xmog_base *obj, jfloat f, xmog_localenv *env=NULL)
 Sets the value of a float field. More...
 
virtual void set_int (xmog_base *obj, jint i, xmog_localenv *env=NULL)
 Sets the value of an int field. More...
 
virtual void set_long (xmog_base *obj, jlong l, xmog_localenv *env=NULL)
 Sets the value of a long field. More...
 
virtual void set_short (xmog_base *obj, jshort sh, xmog_localenv *env=NULL)
 Sets the value of a short field. More...
 
virtual void set_jobject (xmog_base *obj, jobject o, xmog_localenv *env=NULL)
 Sets the value of an object field. More...
 
- Public Member Functions inherited from xmog_java_dynamic
int handleException (int error_code, xmog_localenv *env=NULL)
 Handles an exception.
 

Friends

class xmog_java_class
 

Detailed Description

A class implementing the xmog_java_dynamic interface for accessing Java fields via JNI or Codemesh's remoting protocol.

This type is a specialization of the xmog_java_dynamic interface that knows how to get and set field values of Java instances. This type is a support type that is used by the actual proxy fields. Each declared field is represented by exactly one instance of an xmog_java_field. That instance is then used by a concrete field to access the underlying Java instance. The following snippet illustrates the infrastructure:

xmog_java_class clsContext( "javax/naming/Context", true );
xmog_java_field fPROVIDER_URL( &clsContext, "PROVIDER_URL", "Ljava/lang/String;", true );

and the following snippet illustrates how the generated code uses the infrastructure:

java::lang::String javax::naming::Context::PROVIDER_URL( NULL, &fPROVIDER_URL );

Constructor & Destructor Documentation

◆ xmog_java_field() [1/2]

xmog_java_field::xmog_java_field ( xmog_java_class clazz,
jfieldID  fid,
bool  bStatic = false 
)

The constructor that takes an externally calculated jfieldID as input.

This constructor allows us to create an easy to use wrapper instance for an existing jfieldID. This constructor adds the field instance to the list of fields maintained by the declaring class.

Parameters
clazzthe declaring type.
fidthe fieldID.
bStatictrue if we have a static field, false otherwise.

◆ xmog_java_field() [2/2]

xmog_java_field::xmog_java_field ( xmog_java_class clazz,
const char *  name,
const char *  type,
bool  bStatic = false 
)

The constructor that takes all information required to calculate a jfieldID as input.

This constructor adds the field instance to the list of fields maintained by the declaring class.

Parameters
clazzthe declaring type.
namethe field name. The caller owns the string.
typethe field type in internal format. The caller owns the string.
bStatictrue if we have a static field, false otherwise.

Member Function Documentation

◆ get_bool()

virtual bool xmog_java_field::get_bool ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Returns the value of a boolean field.

Parameters
objpointer to the owning instance or NULL if the field is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ get_byte()

virtual jbyte xmog_java_field::get_byte ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Returns the value of a byte field.

Parameters
objpointer to the owning instance or NULL if the field is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ get_char()

virtual jchar xmog_java_field::get_char ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Returns the value of a char field.

Parameters
objpointer to the owning instance or NULL if the field is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ get_double()

virtual jdouble xmog_java_field::get_double ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Returns the value of a double field.

Parameters
objpointer to the owning instance or NULL if the field is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ get_float()

virtual jfloat xmog_java_field::get_float ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Returns the value of a float field.

Parameters
objpointer to the owning instance or NULL if the field is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ get_int()

virtual jint xmog_java_field::get_int ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Returns the value of an int field.

Parameters
objpointer to the owning instance or NULL if the field is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ get_jboolean()

virtual jboolean xmog_java_field::get_jboolean ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Returns the value of a boolean field.

Parameters
objpointer to the owning instance or NULL if the field is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ get_jobject()

virtual jobject xmog_java_field::get_jobject ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = xmog_base::GLOBAL 
)
virtual

Returns the value of an object field.

Parameters
objpointer to the owning instance or NULL if the field is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is xmog_base::GLOBAL.

Implements xmog_java_dynamic.

◆ get_long()

virtual jlong xmog_java_field::get_long ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Returns the value of a long field.

Parameters
objpointer to the owning instance or NULL if the field is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ get_short()

virtual jshort xmog_java_field::get_short ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Returns the value of a short field.

Parameters
objpointer to the owning instance or NULL if the field is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ get_void()

virtual void xmog_java_field::get_void ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Not implemented for this type.

There are no fields of type void.

Parameters
objpointer to the owning instance or NULL if the field is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ initializeFieldID()

int xmog_java_field::initializeFieldID ( xmog_localenv env)

Calculates the fieldID based on the information maintained by this instance.

Parameters
envthe local environment used for this operation.
Returns
0 if everything worked out, -1 otherwise.

◆ set_bool()

virtual void xmog_java_field::set_bool ( xmog_base obj,
bool  b,
xmog_localenv env = NULL 
)
virtual

Sets the value of a boolean field.

Parameters
objpointer to the owning instance or NULL if the field is static.
bthe new value of the field.
envthe local environment used in this call. This value may be NULL.

Implements xmog_java_dynamic.

◆ set_byte()

virtual void xmog_java_field::set_byte ( xmog_base obj,
jbyte  b,
xmog_localenv env = NULL 
)
virtual

Sets the value of a byte field.

Parameters
objpointer to the owning instance or NULL if the field is static.
bthe new value of the field.
envthe local environment used in this call. This value may be NULL.

Implements xmog_java_dynamic.

◆ set_char()

virtual void xmog_java_field::set_char ( xmog_base obj,
jchar  ch,
xmog_localenv env = NULL 
)
virtual

Sets the value of a char field.

Parameters
objpointer to the owning instance or NULL if the field is static.
chthe new value of the field.
envthe local environment used in this call. This value may be NULL.

Implements xmog_java_dynamic.

◆ set_double()

virtual void xmog_java_field::set_double ( xmog_base obj,
jdouble  d,
xmog_localenv env = NULL 
)
virtual

Sets the value of a double field.

Parameters
objpointer to the owning instance or NULL if the field is static.
dthe new value of the field.
envthe local environment used in this call. This value may be NULL.

Implements xmog_java_dynamic.

◆ set_fieldID()

void xmog_java_field::set_fieldID ( jfieldID  fid)

Sets the field's ID.

This method is used when we perform bulk initialization of elements declared by a type in the remoting protocol.

◆ set_float()

virtual void xmog_java_field::set_float ( xmog_base obj,
jfloat  f,
xmog_localenv env = NULL 
)
virtual

Sets the value of a float field.

Parameters
objpointer to the owning instance or NULL if the field is static.
fthe new value of the field.
envthe local environment used in this call. This value may be NULL.

Implements xmog_java_dynamic.

◆ set_int()

virtual void xmog_java_field::set_int ( xmog_base obj,
jint  i,
xmog_localenv env = NULL 
)
virtual

Sets the value of an int field.

Parameters
objpointer to the owning instance or NULL if the field is static.
ithe new value of the field.
envthe local environment used in this call. This value may be NULL.

Implements xmog_java_dynamic.

◆ set_jboolean()

virtual void xmog_java_field::set_jboolean ( xmog_base obj,
jboolean  b,
xmog_localenv env = NULL 
)
virtual

Sets the value of a boolean field.

Parameters
objpointer to the owning instance or NULL if the field is static.
bthe new value of the field.
envthe local environment used in this call. This value may be NULL.

Implements xmog_java_dynamic.

◆ set_jobject()

virtual void xmog_java_field::set_jobject ( xmog_base obj,
jobject  o,
xmog_localenv env = NULL 
)
virtual

Sets the value of an object field.

Parameters
objpointer to the owning instance or NULL if the field is static.
othe new value of the field.
envthe local environment used in this call. This value may be NULL.

Implements xmog_java_dynamic.

◆ set_long()

virtual void xmog_java_field::set_long ( xmog_base obj,
jlong  l,
xmog_localenv env = NULL 
)
virtual

Sets the value of a long field.

Parameters
objpointer to the owning instance or NULL if the field is static.
lthe new value of the field.
envthe local environment used in this call. This value may be NULL.

Implements xmog_java_dynamic.

◆ set_short()

virtual void xmog_java_field::set_short ( xmog_base obj,
jshort  sh,
xmog_localenv env = NULL 
)
virtual

Sets the value of a short field.

Parameters
objpointer to the owning instance or NULL if the field is static.
shthe new value of the field.
envthe local environment used in this call. This value may be NULL.

Implements xmog_java_dynamic.


The documentation for this class was generated from the following file:
xmog_java_field
A class implementing the xmog_java_dynamic interface for accessing Java fields via JNI or Codemesh's ...
Definition: xmog_java_field.h:36
xmog_java_class
A C++ wrapper for Java types.
Definition: xmog_java_class.h:31

Copyright (c) 1999-2020 by Codemesh, Inc., ALL RIGHTS RESERVED.