Here you can find the source of toPercent(Vector members, HashMap mapMemberToValue)
static void toPercent(Vector members, HashMap mapMemberToValue)
//package com.java2s; /*// w w w .j a va 2 s . c om // $Id: //open/mondrian/src/main/mondrian/olap/fun/FunUtil.java#18 $ // (C) Copyright 2002 Kana Software, Inc. // This software is subject to the terms of the Common Public License // Agreement, available at the following URL: // http://www.opensource.org/licenses/cpl.html. // (C) Copyright 2002 Kana Software, Inc. and others. // All Rights Reserved. // You must accept the terms of that agreement to use this software. // // jhyde, 3 March, 2002 */ import java.util.*; public class Main { /** * Turns the mapped values into relative values (percentages) for easy * use by the general topOrBottom function. This might also be a useful * function in itself. */ static void toPercent(Vector members, HashMap mapMemberToValue) { double total = 0; int numMembers = members.size(); for (int i = 0; i < numMembers; i++) { Object o = mapMemberToValue.get(members.elementAt(i)); if (o instanceof Number) { total += ((Number) o).doubleValue(); } } for (int i = 0; i < numMembers; i++) { Object member = members.elementAt(i); Object o = mapMemberToValue.get(member); if (o instanceof Number) { double d = ((Number) o).doubleValue(); mapMemberToValue.put(member, new Double(d / total * 100)); } } } }