Java tutorial
//package com.java2s; /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import android.text.TextUtils; import java.util.ArrayList; import java.util.HashMap; import java.util.List; public class Main { private static HashMap<Integer, String> descPermissions = new HashMap(); public static String getDescPermission(int property) { return getHashMapValue(descPermissions, property); } private static String getHashMapValue(HashMap<Integer, String> hashMap, int number) { String result = hashMap.get(number); if (TextUtils.isEmpty(result)) { List<Integer> numbers = getElement(number); result = ""; for (int i = 0; i < numbers.size(); i++) { result += hashMap.get(numbers.get(i)) + "|"; } } return result; } static private List<Integer> getElement(int number) { List<Integer> result = new ArrayList<Integer>(); for (int i = 0; i < 32; i++) { int b = 1 << i; if ((number & b) > 0) result.add(b); } return result; } }