equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2003 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 void AddToJavaStringArrayL(JNIEnv& aJni, jobjectArray& aContainer, TInt aPosition, const TDesC& aString) |
|
23 { |
|
24 jstring javaString = CreateJavaString(aJni, aString); |
|
25 User::LeaveIfNull(javaString); |
|
26 // |
|
27 aJni.SetObjectArrayElement(aContainer, aPosition, javaString); |
|
28 aJni.DeleteLocalRef(javaString); |
|
29 } |
|
30 |
|
31 |
|
32 EXPORT_C jobjectArray CopyToNewJavaStringArrayL(JNIEnv& aJni, const CDesCArray& aNativeArray) |
|
33 { |
|
34 jclass stringClass = aJni.FindClass("java/lang/String"); |
|
35 User::LeaveIfNull(stringClass); |
|
36 // |
|
37 jobjectArray result = aJni.NewObjectArray(aNativeArray.Count(), stringClass, NULL); |
|
38 if (result != NULL) |
|
39 { |
|
40 TPtrC item; |
|
41 for (int i=0; i<aNativeArray.Count(); ++i) |
|
42 { |
|
43 item.Set(aNativeArray[i]); |
|
44 AddToJavaStringArrayL(aJni, result, i, item); |
|
45 } |
|
46 } |
|
47 return result; |
|
48 } |