Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

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]
List of all members.

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.
 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.
 ~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.
jfieldID get_fieldID ()
 Returns the field's ID.
int initializeFieldID (xmog_localenv *env)
 Calculates the fieldID based on the information maintained by this instance.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
virtual void set_bool (xmog_base *obj, bool b, xmog_localenv *env=NULL)
 Sets the value of a boolean field.
virtual void set_jboolean (xmog_base *obj, jboolean b, xmog_localenv *env=NULL)
 Sets the value of a boolean field.
virtual void set_byte (xmog_base *obj, jbyte b, xmog_localenv *env=NULL)
 Sets the value of a byte field.
virtual void set_char (xmog_base *obj, jchar ch, xmog_localenv *env=NULL)
 Sets the value of a char field.
virtual void set_double (xmog_base *obj, jdouble d, xmog_localenv *env=NULL)
 Sets the value of a double field.
virtual void set_float (xmog_base *obj, jfloat f, xmog_localenv *env=NULL)
 Sets the value of a float field.
virtual void set_int (xmog_base *obj, jint i, xmog_localenv *env=NULL)
 Sets the value of an int field.
virtual void set_long (xmog_base *obj, jlong l, xmog_localenv *env=NULL)
 Sets the value of a long field.
virtual void set_short (xmog_base *obj, jshort sh, xmog_localenv *env=NULL)
 Sets the value of a short field.
virtual void set_jobject (xmog_base *obj, jobject o, xmog_localenv *env=NULL)
 Sets the value of an object field.

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::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:
clazz the declaring type.
fid the fieldID.
bStatic true if we have a static field, false otherwise.

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:
clazz the declaring type.
name the field name. The caller owns the string.
type the field type in internal format. The caller owns the string.
bStatic true if we have a static field, false otherwise.


Member Function Documentation

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:
obj pointer to the owning instance or NULL if the field is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the field is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the field is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the field is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the field is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the field is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the field is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the field is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is xmog_base::GLOBAL.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the field is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the field is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the field is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

int xmog_java_field::initializeFieldID xmog_localenv env  ) 
 

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

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

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:
obj pointer to the owning instance or NULL if the field is static.
b the new value of the field.
env the local environment used in this call. This value may be NULL.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the field is static.
b the new value of the field.
env the local environment used in this call. This value may be NULL.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the field is static.
ch the new value of the field.
env the local environment used in this call. This value may be NULL.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the field is static.
d the new value of the field.
env the local environment used in this call. This value may be NULL.

Implements xmog_java_dynamic.

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.

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:
obj pointer to the owning instance or NULL if the field is static.
f the new value of the field.
env the local environment used in this call. This value may be NULL.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the field is static.
i the new value of the field.
env the local environment used in this call. This value may be NULL.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the field is static.
b the new value of the field.
env the local environment used in this call. This value may be NULL.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the field is static.
o the new value of the field.
env the local environment used in this call. This value may be NULL.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the field is static.
l the new value of the field.
env the local environment used in this call. This value may be NULL.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the field is static.
sh the new value of the field.
env the 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:
Generated on Wed May 31 14:01:29 2006 for Shared Codemesh Runtime Library API Reference by  doxygen 1.4.1