sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/CategoryProfile.java
changeset 7 8e12a575a9b5
equal deleted inserted replaced
6:f65f740e69f9 7:8e12a575a9b5
       
     1 /*
       
     2 * Copyright (c) 2009 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 package com.nokia.s60tools.memspy.model;
       
    18 
       
    19 import java.util.Iterator;
       
    20 import java.util.List;
       
    21 
       
    22 import com.nokia.s60tools.memspy.ui.dialogs.SWMTCategoryEntry;
       
    23 
       
    24 /**
       
    25  * Class for one Category Profile
       
    26  */
       
    27 public class CategoryProfile {
       
    28 
       
    29 	private String name;
       
    30 	
       
    31 	private int categories = 0;
       
    32 
       
    33 	/**
       
    34 	 * Create a new Category Profile
       
    35 	 * @param name Profile name
       
    36 	 */
       
    37 	public CategoryProfile(String name) {
       
    38 		this.setName(name);
       
    39 	}
       
    40 	
       
    41 	/**
       
    42 	 * 
       
    43 	 * @param name Profile name
       
    44 	 * @param categories Categories for profile
       
    45 	 */
       
    46 	public CategoryProfile(String name, int categories) {
       
    47 		this.categories = categories;
       
    48 		this.setName(name);
       
    49 	}	
       
    50 
       
    51 	/**
       
    52 	 * Get profile name
       
    53 	 * @return the name
       
    54 	 */
       
    55 	public String getName() {
       
    56 		return name;
       
    57 	}
       
    58 
       
    59 	/**
       
    60 	 * Set profile name
       
    61 	 * @param name the name to set
       
    62 	 */
       
    63 	public void setName(String name) {
       
    64 		this.name = name;
       
    65 	}
       
    66 	
       
    67 	/**
       
    68 	 * Add one or more category to categories
       
    69 	 * @param categories the categories to set
       
    70 	 */
       
    71 	public void addCategory(int category) {
       
    72 		categories = categories & category;
       
    73 	}	
       
    74 
       
    75 	/**
       
    76 	 * Get categories
       
    77 	 * @return the categories
       
    78 	 */
       
    79 	public int getCategories() {
       
    80 		return categories;
       
    81 	}
       
    82 	
       
    83 	/**
       
    84 	 * Get all SWMT categories for this profile
       
    85 	 * @return the categories
       
    86 	 */
       
    87 	public List<SWMTCategoryEntry> getCategoryEntrys() {
       
    88 		
       
    89 		SWMTCategorys cat = SWMTCategorys.getInstance();
       
    90 		List<SWMTCategoryEntry> categoryEntries = cat.getCategoryEntries(getCategories());
       
    91 		
       
    92 		return categoryEntries;
       
    93 	}
       
    94 	
       
    95 	/**
       
    96 	 * Get names of the Categories added to this profile.
       
    97 	 * @return list of Category names
       
    98 	 */
       
    99 	public String [] getCategoryEntryNames(){
       
   100 		List<SWMTCategoryEntry> categoryEntrys = getCategoryEntrys();
       
   101 		if(categoryEntrys.isEmpty()){
       
   102 			return new String[0];
       
   103 		}
       
   104 		String[] names = new String[categoryEntrys.size()];
       
   105 		int i = 0;
       
   106 		for (Iterator<SWMTCategoryEntry> iterator = categoryEntrys.iterator(); iterator.hasNext();) {
       
   107 			SWMTCategoryEntry entry = (SWMTCategoryEntry) iterator
       
   108 					.next();
       
   109 			names[i] = entry.getCategoryName();
       
   110 			i++;
       
   111 		}
       
   112 		return names;
       
   113 	}
       
   114 
       
   115 }