sysperfana/analyzetoolext/com.nokia.s60tools.analyzetool/src/com/nokia/s60tools/analyzetool/engine/AnalysisItem.java
changeset 1 1050670c6980
child 6 f65f740e69f9
equal deleted inserted replaced
0:5ad7ad99af01 1:1050670c6980
       
     1 /*
       
     2  * Copyright (c) 2008-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:  Definitions for the class AnalysisItem
       
    15  *
       
    16  */
       
    17 
       
    18 package com.nokia.s60tools.analyzetool.engine;
       
    19 
       
    20 import java.util.AbstractList;
       
    21 import java.util.ArrayList;
       
    22 
       
    23 /**
       
    24  * Contains information of one memory leak item Information is parsed from
       
    25  * atool.exe generated XML file so we can assume that all the information is
       
    26  * valid and no other checking is needed.
       
    27  *
       
    28  * @author kihe
       
    29  *
       
    30  */
       
    31 public class AnalysisItem extends BaseItem {
       
    32 
       
    33 	/** Size of leak. */
       
    34 	private int leakSize = 0;
       
    35 
       
    36 	/** Call stack addresses. */
       
    37 	private final AbstractList<CallstackItem> callstackItems;
       
    38 
       
    39 	/**
       
    40 	 * Constructor.
       
    41 	 */
       
    42 	public AnalysisItem() {
       
    43 		super();
       
    44 		callstackItems = new ArrayList<CallstackItem>();
       
    45 	}
       
    46 
       
    47 	/**
       
    48 	 * Adds new Callstack item.
       
    49 	 *
       
    50 	 * @param item
       
    51 	 *            Callstack item
       
    52 	 */
       
    53 	public final void addCallstackItem(final CallstackItem item) {
       
    54 		this.callstackItems.add(item);
       
    55 	}
       
    56 
       
    57 	/**
       
    58 	 * Check contains current item valid callstack item.
       
    59 	 *
       
    60 	 * @return True one callstack info contains Function name and leak line
       
    61 	 *         number, otherwise False
       
    62 	 */
       
    63 	public final boolean containValidCallstack() {
       
    64 		// thru stored callstack items
       
    65 		final java.util.Iterator<CallstackItem> iterCallstack = callstackItems
       
    66 				.iterator();
       
    67 		while (iterCallstack.hasNext()) {
       
    68 			// if one item contains valid filename and line number
       
    69 			// this means that current callstack items can be pinpointed
       
    70 			final CallstackItem oneItem = iterCallstack.next();
       
    71 			if (!("").equals(oneItem.getFileName())
       
    72 					&& oneItem.getLeakLineNumber() != 0) {
       
    73 				return true;
       
    74 			}
       
    75 		}
       
    76 		return false;
       
    77 	}
       
    78 
       
    79 	/**
       
    80 	 * Gets stored callstack items.
       
    81 	 *
       
    82 	 * @return Callstack items
       
    83 	 */
       
    84 	public final AbstractList<CallstackItem> getCallstackItems() {
       
    85 		return this.callstackItems;
       
    86 	}
       
    87 
       
    88 	/**
       
    89 	 * Gets size of memory leak.
       
    90 	 *
       
    91 	 * @return Memory leak size
       
    92 	 */
       
    93 	public final int getLeakSize() {
       
    94 		return this.leakSize;
       
    95 	}
       
    96 
       
    97 
       
    98 	/**
       
    99 	 * Sets size for the memory leak.
       
   100 	 *
       
   101 	 * @param newSize
       
   102 	 *            Memory leak size
       
   103 	 */
       
   104 	public final void setLeakSize(final int newSize) {
       
   105 		this.leakSize = newSize;
       
   106 	}
       
   107 }