equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 1999-2000 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 #include "jutils.h" |
|
20 |
|
21 /** |
|
22 * Constuctor taking a Java JNI string and converting it to an EPOC TPtrC. |
|
23 */ |
|
24 EXPORT_C RJString::RJString(JNIEnv& aJni, jstring aString) |
|
25 : iJni(aJni), iString(aString) |
|
26 { |
|
27 // Potential for a string to be NULL, but NULL cannot be passed into |
|
28 // JNI methods, so must check. If string is NULL, will result in empty string |
|
29 if (iString != NULL) |
|
30 { |
|
31 const jchar* ptr = aJni.GetStringChars(iString, NULL); |
|
32 const jint len = aJni.GetStringLength(iString); |
|
33 if (ptr) |
|
34 { |
|
35 Set(ptr, len); |
|
36 } |
|
37 } |
|
38 } |
|
39 |
|
40 |
|
41 |
|
42 /** |
|
43 * Frees up the JNI string resources, if they need to be freed. |
|
44 */ |
|
45 EXPORT_C RJString::~RJString() |
|
46 { |
|
47 if (iString != NULL) |
|
48 { |
|
49 iJni.ReleaseStringChars(iString, this->Ptr()); |
|
50 } |
|
51 } |