javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/common_j2me/org/eclipse/swt/internal/ApplicationUidWrapper.java
changeset 78 71ad690e91f5
parent 72 1f0034e370aa
child 80 d6dafc5d983f
equal deleted inserted replaced
72:1f0034e370aa 78:71ad690e91f5
     1 /*******************************************************************************
       
     2  * Copyright (c) 2009,2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved. This program and the accompanying materials
       
     4  * are made available under the terms of the Eclipse Public License v1.0
       
     5  * which accompanies this distribution, and is available at
       
     6  * http://www.eclipse.org/legal/epl-v10.html
       
     7  *
       
     8  * Contributors:
       
     9  *     Nokia Corporation - initial implementation
       
    10  *******************************************************************************/
       
    11 package org.eclipse.swt.internal;
       
    12 
       
    13 import com.nokia.mj.impl.rt.support.ApplicationInfo;
       
    14 
       
    15 
       
    16 public final class ApplicationUidWrapper {
       
    17 
       
    18 	public static int uid() {
       
    19         int midletUid = -1;
       
    20         try{
       
    21             String uidS = ApplicationInfo.getInstance().getUid().getStringValue();
       
    22             // In Symbian the UID is in format '[<uid>]' where <uid> is in hex
       
    23             // format. So wee need to take the brackets away.
       
    24             // Long is needed in conversion because UIDs greater than 0x80000000
       
    25             // would fail if Integer would be used. However typecast from long
       
    26             // to int is safe since UID in Symbian is 32 bit.
       
    27             long uidL = Long.parseLong(uidS.substring(1,uidS.length()-1), 16);
       
    28             return (int)uidL;
       
    29         }
       
    30         catch (Throwable t) {/* Not handled*/ }
       
    31         return midletUid;
       
    32     }
       
    33 }