javacommons/utils/inc/javajniutils.h
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef JAVAJNIUTILS_H
       
    20 #define JAVAJNIUTILS_H
       
    21 
       
    22 #include <string>
       
    23 #include <jni.h>
       
    24 #include "javaosheaders.h"
       
    25 
       
    26 namespace java
       
    27 {
       
    28 namespace util
       
    29 {
       
    30 
       
    31 /**
       
    32  * This class contains jni utility operations.
       
    33  */
       
    34 class JniUtils
       
    35 {
       
    36 public:
       
    37     OS_IMPORT static std::wstring jstringToWstring(JNIEnv* env, const jstring& str);
       
    38     OS_IMPORT static jstring wstringToJstring(JNIEnv* env, const std::wstring& str);
       
    39 
       
    40     /**
       
    41      * Throws exception from native side to java side.
       
    42      * @param aEnv JNIEnv object.
       
    43      * @param aClassNameOfException class name and name of the exception.
       
    44      * @param aExceptionText exception text added to java exception.
       
    45      * Example:
       
    46      * throwNewException(aEnv,"java/lang/NullPointerException","Creation of native handler failed");
       
    47      */
       
    48     OS_IMPORT static void throwNewException(JNIEnv* aEnv,const std::string& aClassNameOfException,
       
    49                                             const std::string& aExceptionText);
       
    50 };
       
    51 
       
    52 } //end namespace util
       
    53 } //end namespace java
       
    54 
       
    55 #endif // JAVAJNIUTILS_H
       
    56