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

The wrapper for exceptions that occur on the Java side. More...

#include <xmog_exception.h>

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

Public Member Functions

 xmog_exception ()
 The default constructor.
 
 xmog_exception (const xmog_exception &rhs, xmog_localenv *pEnv=NULL)
 The copy constructor. More...
 
 xmog_exception (jobject inst, xmog_flags flags)
 The constructor for a preexisting exception instance. More...
 
void get_message (xmog_base *msg, xmog_localenv *env=NULL)
 Returns the exception instance's message object in the provided proxy instance. More...
 
virtual char * get_message_chars (xmog_localenv *env=NULL, xmog_base *enc=NULL)
 Returns the error message for this instance. More...
 
virtual unsigned short * get_message_u16 (xmog_localenv *env=NULL)
 Returns the error message for this instance. More...
 
- Public Member Functions inherited from xmog_java_ref
 xmog_java_ref ()
 The default constructor.
 
 xmog_java_ref (const xmog_null &)
 The from null constructor. More...
 
 xmog_java_ref (xmog_java_array *_arr, jint _index)
 The array element constructor. More...
 
 xmog_java_ref (xmog_java_class *_clazz, xmog_java_dynamic *_dynamic, xmog_flags _flags)
 The constructor that allows the dynamic resolution of class-related information. More...
 
XMOG_EXPLICIT xmog_java_ref (xmog_base *_delegate, bool _owns_delegate=true)
 The constructor that allows the creation of an instance to handle all requests by delegating to another instance. More...
 
 xmog_java_ref (xmog_java_ref *_ref, xmog_java_dynamic *_dynamic, xmog_flags _flags)
 The constructor that allows the dynamic resolution of instance-related information. More...
 
 xmog_java_ref (jobject _local, xmog_flags _flags)
 The constructor that sets an existing JNI reference into a wrapper instance. More...
 
 ~xmog_java_ref ()
 Deletes the reference we hold to the wrapped Java instance.
 
bool operator== (const xmog_null &) const
 Compares the instance for equality with null.
 
bool operator== (const xmog_java_ref &) const
 Compares the instance for equality with another instance. More...
 
bool operator!= (const xmog_null &) const
 Compares the instance for inequality with null.
 
bool operator!= (const xmog_java_ref &) const
 Compares the instance for inequality with another instance. More...
 
bool operator! () const
 Returns true if the instance refers to null, false otherwise.
 
jboolean xmog_equals (const xmog_java_ref &_rhs, xmog_localenv *env=NULL)
 Returns true if both instances are null or satisfy the equality test. More...
 
jint xmog_hashCode (xmog_localenv *env=NULL)
 Returns the Java instance's hashCode. More...
 
jobject xmog_toString (xmog_localenv *env=NULL)
 Returns the Java instance's toString() valus as a global reference. More...
 
virtual jobject get_jobject_ (xmog_localenv *env=NULL) const
 Returns this instance's object reference. More...
 
virtual void xmog_monitor_enter (xmog_localenv *env=NULL) const
 Attempts to enter into a lock on the object.
 
virtual void xmog_monitor_exit (xmog_localenv *env=NULL) const
 Leaves a lock in the object.
 
- Public Member Functions inherited from xmog_base
 xmog_base ()
 The default contructor. More...
 
 xmog_base (xmog_java_array *_ref, jint _index)
 The constructor for Java array elements. More...
 
 xmog_base (xmog_java_ref *_ref, xmog_java_dynamic *_dynamic, xmog_flags _flags)
 The constructor for indirect and user-defined types. More...
 
 xmog_base (xmog_java_class *_clazz, xmog_java_dynamic *_dynamic, xmog_flags _flags)
 The constructor for indirect and user-defined types. More...
 
XMOG_EXPLICIT xmog_base (xmog_base *_delegate, bool _owns_delegate=true)
 The constructor for delegating objects. More...
 
 xmog_base (jobject _local, xmog_flags _flags)
 The constructor for direct types. More...
 
virtual ~xmog_base ()
 The virtual destructor.
 
virtual void copy_jobject_ (xmog_base *_rhs, xmog_localenv *env=NULL)
 Sets this instance's object reference to a duplicate of the given object's reference. More...
 
virtual jobject get_owning_jobject_ (xmog_localenv *env=NULL)
 Returns this instance's owner. More...
 
virtual jobject get_released_local_jobject_ (xmog_localenv *env=NULL) const
 Returns this instance's object reference as a local reference and removes it from this instance's ownership. More...
 
virtual bool is_null_ (xmog_localenv *env=NULL) const
 Tests the instance for null.
 
virtual bool is_same_ (const xmog_base &_rhs, xmog_localenv *env=NULL) const
 Tests whether this instance references the same instance as the other instance.
 
virtual jobject duplicate_jobject_ (xmog_localenv *env=NULL) const
 Returns a duplicate of this instance's object reference. More...
 
virtual void set_jobject_ (xmog_base *_rhs, xmog_localenv *env=NULL)
 Sets this instance's object reference to the given object's reference. More...
 
virtual void transfer_jobject_ (xmog_base *_rhs, xmog_localenv *env=NULL)
 Sets this instance's object reference to the given object's reference and removes ownership from the other object. More...
 
virtual xmog_basexmog_to_ (xmog_flags flags, xmog_localenv *env=NULL)
 Converts a reference from one reference type to another. More...
 
virtual xmog_basexmog_fill_with_standalone_for_ (xmog_base *_rhs, xmog_localenv *env=NULL)
 Populates the object with a stand-alone reference based on another object. More...
 
virtual xmog_java_classxmog_get_java_peer (xmog_localenv *env=NULL)
 Returns NULL if the type does not have a Java peer type, a pointer to the type's xmog_java_class otherwise. More...
 
virtual int xmog_create_java_peer (xmog_java_class *clazz, xmog_localenv *env=NULL, xmog_flags flags=xmog_base::GLOBAL)
 Creates a Java peer instance for this type.
More...
 
virtual int xmog_to_java_peer (xmog_localenv *env=NULL)
 Sets the native instance's state into the Java peer instance. More...
 
virtual void xmog_lazy_write (xmog_localenv *env=NULL)
 Performs a lazy write operation on the instance. More...
 
virtual void xmog_invalidate (xmog_localenv *env=NULL)
 Invalidates any cached values in the instance. More...
 
void release_standalone (xmog_localenv *env=NULL)
 Releases the internally maintained object if the instance is a stand-alone (direct) instance and not an indirect instance. More...
 
void release_delegate ()
 Releases the internally maintained delegate.
 

Static Public Member Functions

static void throw_java_exception (xmog_exception *pe=NULL, const char *msg=NULL, xmog_localenv *env=NULL)
 Throws a Java exception corresponding with the passed exception instance. More...
 

Additional Inherited Members

- Public Types inherited from xmog_base
enum  flags {
  STAND_ALONE = 1, ARRAY_ELEMENT = 2, DYNAMIC = 4, DELEGATE = 8,
  LOCAL = 16, WEAK_GLOBAL = 32, GLOBAL = 64, REMOTE = 128,
  CACHING = 256, CACHE_INVALID = 512, CACHE_DIRTY = 1024, CACHE_LAZY_WRITE = 2048,
  OWNS_DELEGATE = 4096, STRING_DIRTY = 8192, STRING_PTR = 16384, STRING_WPTR = 32768,
  INDIRECT = 65536, NONVIRT = 131072, SUPPRESS_LOGGING = 262144, CATEGORY = 15,
  TYPE = 240, CACHE = 3840
}
 The possible flag values. More...
 
- Public Attributes inherited from xmog_base
XMOG_JOBJECT_HOLDER owner_
 The owner or identity of the object. More...
 
union {
   xmog_java_dynamic *   dynamic_
 A pointer to an object that can access indirectly specified information.
 
   jint   index_
 The index of an array element.
 
}; 
 Data or object that provides assistance in accessing indirectly specified elements. More...
 
xmog_flags flags_
 The flags governing the type and other housekeeping information.
 

Detailed Description

The wrapper for exceptions that occur on the Java side.

This class is mixed into all generated proxy exception types and therefore has to extend xmog_java_ref virtually. By mixing this type into all generated exception proxy types and by having the generic exception type implement this interface, we can allow the developer to catch all exceptions that are part of the framework (typed and generic) via the xmog_exception type.

A catch-all handler could look like this:

try
{
// do things that could throw exceptions (framework or proxy)
}
catch( xmog_exception & e )
{
// get the exception message using the default encoding
char * msg = e.get_message_chars();
// print it to the console if there is something to print
if( msg )
cout << msg << endl;
// release the message string
xmog_util::setString( msg, NULL );
}

Constructor & Destructor Documentation

◆ xmog_exception() [1/2]

xmog_exception::xmog_exception ( const xmog_exception rhs,
xmog_localenv pEnv = NULL 
)

The copy constructor.

Parameters
rhsthe exception we're copying.
pEnvthe optional local environment. Defaults to NULL.

◆ xmog_exception() [2/2]

xmog_exception::xmog_exception ( jobject  inst,
xmog_flags  flags 
)

The constructor for a preexisting exception instance.

Parameters
instthe exception.
flagsthe housekeeping flags.

Member Function Documentation

◆ get_message()

void xmog_exception::get_message ( xmog_base msg,
xmog_localenv env = NULL 
)

Returns the exception instance's message object in the provided proxy instance.

This method is used internally by the .NET bindings.

Parameters
msgthe object into which the message instance is set.
envthe local call environment. May be NULL.

◆ get_message_chars()

virtual char* xmog_exception::get_message_chars ( xmog_localenv env = NULL,
xmog_base enc = NULL 
)
virtual

Returns the error message for this instance.

The caller is responsible for cleaning up the returned string by calling xmog_util::free() or xmog_util::setString().

Parameters
envthe local call environment. May be NULL.
encthe optional encoding to be used. Use one of the encodings in the xmog_java_string class.
Returns
the exception message, owned by the caller.

Reimplemented in xmog_exception_impl.

◆ get_message_u16()

virtual unsigned short* xmog_exception::get_message_u16 ( xmog_localenv env = NULL)
virtual

Returns the error message for this instance.

The caller is responsible for cleaning up the returned string by calling xmog_util::free() or xmog_util::setString().

Parameters
envthe local call environment. May be NULL.
Returns
the exception message, owned by the caller.

Reimplemented in xmog_exception_impl.

◆ throw_java_exception()

static void xmog_exception::throw_java_exception ( xmog_exception pe = NULL,
const char *  msg = NULL,
xmog_localenv env = NULL 
)
static

Throws a Java exception corresponding with the passed exception instance.

If the passed exception instance is NULL or if it is not a proxy instance for a Java exception, a Java RuntimeException will be thrown.

Parameters
pea pointer to an exception instance. May be NULL.
msgan exception message to be used if the passed in exception instance does not represent a Java exception instance. May be NULL.
envthe local call environment. May be NULL.

The documentation for this class was generated from the following file:
xmog_util::setString
static char * setString(char *&strVar, const char *value, size_t len=(size_t) -1)
Sets a string to another string after cleaning up the previous string.
xmog_exception::get_message_chars
virtual char * get_message_chars(xmog_localenv *env=NULL, xmog_base *enc=NULL)
Returns the error message for this instance.
xmog_exception
The wrapper for exceptions that occur on the Java side.
Definition: xmog_exception.h:46

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