sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/analysers/ResultElements.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.swmtanalyser.analysers;
       
    18 
       
    19 import org.eclipse.swt.graphics.Color;
       
    20 /**
       
    21  * Input object for tree viewer in analysis tab.
       
    22  *
       
    23  */
       
    24 public class ResultElements implements Comparable<ResultElements>{
       
    25 	
       
    26 	/**
       
    27 	 * Item name
       
    28 	 */
       
    29 	public static final String ITEM_NAME_COLUMN = "Item name";
       
    30 	/**
       
    31 	 * Event
       
    32 	 */
       
    33 	public static final String EVENT_COLUMN = "Event";
       
    34 	/**
       
    35 	 * Delta
       
    36 	 */
       
    37 	public static final String DELTA_COLUMN = "Delta";
       
    38 	/**
       
    39 	 * Severity
       
    40 	 */
       
    41 	public static final String SEVERITY_COLUMN = "Severity";
       
    42 	
       
    43 	private static final String TAB = "\t";
       
    44 
       
    45 	private String itemName;
       
    46 	private String event;
       
    47 	private String delta;
       
    48 	private long delta_value;
       
    49 	private double growing_factor;
       
    50 	private Color color;
       
    51 	private long [] event_values;
       
    52 	
       
    53 	private AnalyserConstants.Priority priority = AnalyserConstants.Priority.NEGLIGIBLE;
       
    54 	private AnalyserConstants.DeltaType deltaType = AnalyserConstants.DeltaType.COUNT; 
       
    55 	
       
    56 	/**
       
    57 	 * Construction
       
    58 	 * @param itemName
       
    59 	 * @param event
       
    60 	 * @param delta
       
    61 	 * @param deltaValue
       
    62 	 * @param type
       
    63 	 */
       
    64 	ResultElements(String itemName, String event, String delta, long deltaValue, AnalyserConstants.DeltaType type)
       
    65 	{
       
    66 		this.itemName = itemName;
       
    67 		this.event = event;
       
    68 		this.delta = delta;
       
    69 		this.delta_value = deltaValue;
       
    70 		this.deltaType = type;
       
    71 	}
       
    72 	
       
    73 	/**
       
    74 	 * @return item name
       
    75 	 */
       
    76 	public String toString()
       
    77 	{
       
    78 		return this.itemName;
       
    79 	}
       
    80 		
       
    81 
       
    82 	/**
       
    83 	 * Get tab separated headers for this result.
       
    84 	 * @return headers with tab as separator
       
    85 	 */
       
    86 	public String getTabSeparatedHeaders()
       
    87 	{
       
    88 		//NOTE: If reorganized, also #getTabSeparatedValues() must reorganize
       
    89 		StringBuffer b = new StringBuffer();
       
    90 		b.append(ITEM_NAME_COLUMN);
       
    91 		b.append(TAB);
       
    92 		b.append(EVENT_COLUMN);
       
    93 		b.append(TAB);
       
    94 		b.append(DELTA_COLUMN);
       
    95 		b.append(TAB);
       
    96 		b.append(SEVERITY_COLUMN);
       
    97 		
       
    98 		return b.toString();
       
    99 	
       
   100 	}			
       
   101 	
       
   102 	/**
       
   103 	 * Get tab separated values for this result.
       
   104 	 * @return values
       
   105 	 */
       
   106 	public String getTabSeparatedValues()
       
   107 	{
       
   108 		//NOTE: If reorganized, also #getTabSeparatedHeaders() must reorganize
       
   109 		StringBuffer b = new StringBuffer();
       
   110 		b.append(itemName);
       
   111 		b.append(TAB);
       
   112 		b.append(event);
       
   113 		b.append(TAB);
       
   114 		b.append(delta);
       
   115 		b.append(TAB);
       
   116 		b.append(getPriority());
       
   117 		
       
   118 		return b.toString();
       
   119 	
       
   120 	}		
       
   121 	
       
   122 
       
   123 
       
   124 	/**
       
   125 	 * Get delta
       
   126 	 * @return delta
       
   127 	 */
       
   128 	public String getDelta() {
       
   129 		return delta;
       
   130 	}
       
   131 
       
   132 	/**
       
   133 	 * Set delta
       
   134 	 * @param delta
       
   135 	 */
       
   136 	public void setDelta(String delta) {
       
   137 		this.delta = delta;
       
   138 	}
       
   139 
       
   140 	/**
       
   141 	 * Get item name
       
   142 	 * @return item name
       
   143 	 */
       
   144 	public String getItemName() {
       
   145 		return itemName;
       
   146 	}
       
   147 
       
   148 	/**
       
   149 	 * Get event
       
   150 	 * @return event
       
   151 	 */
       
   152 	public String getEvent() {
       
   153 		return event;
       
   154 	}
       
   155 
       
   156 	/**
       
   157 	 * Set event
       
   158 	 * @param event
       
   159 	 */
       
   160 	public void setEvent(String event) {
       
   161 		this.event = event;
       
   162 	}
       
   163 
       
   164 	/**
       
   165 	 * Get growing factor
       
   166 	 * @return growing factor
       
   167 	 */
       
   168 	public double getGrowingFactor() {
       
   169 		return growing_factor;
       
   170 	}
       
   171 
       
   172 	/**
       
   173 	 * Set growing factor
       
   174 	 * @param growing_factor
       
   175 	 */
       
   176 	public void setGrowingFactor(double growing_factor) {
       
   177 		this.growing_factor = growing_factor;
       
   178 	}
       
   179 
       
   180 	/* (non-Javadoc)
       
   181 	 * @see java.lang.Comparable#compareTo(java.lang.Object)
       
   182 	 */
       
   183 	public int compareTo(ResultElements input) {
       
   184 		
       
   185 		int priority_comparision = this.getPriority().compareTo(input.getPriority());
       
   186 		
       
   187 		if(priority_comparision == 0)
       
   188 		{
       
   189 			if(this.growing_factor > input.growing_factor)
       
   190 				return 1;
       
   191 			else if(this.growing_factor < input.growing_factor)
       
   192 				return -1;
       
   193 			else
       
   194 				return 0;
       
   195 		}
       
   196 		else
       
   197 			return priority_comparision;
       
   198 	}
       
   199 
       
   200 	/**
       
   201 	 * Compare this objects {@link #getDelta()} to given object {@link #getDelta()}
       
   202 	 * Returns a negative integer, zero, or a positive integer 
       
   203 	 * as this object is less than, equal to, or greater than the specified object.
       
   204 	 * @param input
       
   205 	 * @return 0 if this object is equal to given object, 
       
   206 	 * 1 if this object is greater to given object,
       
   207 	 * -1 if this object is less to given object
       
   208 	 */
       
   209 	public int compareByDelta(ResultElements input)
       
   210 	{
       
   211 		long input_delta = input.getDeltaValue();
       
   212 		
       
   213 		if(delta_value > input_delta)
       
   214 			return 1;
       
   215 		else if(delta_value < input_delta)
       
   216 			return -1;
       
   217 		else
       
   218 			return 0;
       
   219 
       
   220 	}
       
   221 	/**
       
   222 	 * Get priority
       
   223 	 * @return priority
       
   224 	 */
       
   225 	public AnalyserConstants.Priority getPriority() {
       
   226 		return priority;
       
   227 	}
       
   228 
       
   229 	/**
       
   230 	 * Set priority
       
   231 	 * @param priority
       
   232 	 */
       
   233 	public void setPriority(AnalyserConstants.Priority priority) {
       
   234 		this.priority = priority;
       
   235 	}
       
   236 		
       
   237 	/**
       
   238 	 * Get delta
       
   239 	 * @return delta
       
   240 	 */
       
   241 	public long getDeltaValue() {
       
   242 		return delta_value;
       
   243 	}
       
   244 
       
   245 	/**
       
   246 	 * Set delta
       
   247 	 * @param delta_value
       
   248 	 */
       
   249 	public void setDeltaValue(long delta_value) {
       
   250 		this.delta_value = delta_value;
       
   251 	}
       
   252 
       
   253 	/**
       
   254 	 * Get Delta type
       
   255 	 * @return delta type
       
   256 	 */
       
   257 	public AnalyserConstants.DeltaType getType() {
       
   258 		return deltaType;
       
   259 	}
       
   260 
       
   261 	/**
       
   262 	 * Set delta type
       
   263 	 * @param type
       
   264 	 */
       
   265 	public void setType(AnalyserConstants.DeltaType type) {
       
   266 		this.deltaType = type;
       
   267 	}
       
   268 
       
   269 	/**
       
   270 	 * Get color
       
   271 	 * @return color
       
   272 	 */
       
   273 	public Color getColor() {
       
   274 		return color;
       
   275 	}
       
   276 
       
   277 	/**
       
   278 	 * Set Color
       
   279 	 * @param color
       
   280 	 */
       
   281 	public void setColor(Color color) {
       
   282 		this.color = color;
       
   283 	}
       
   284 
       
   285 	/**
       
   286 	 * Get event values
       
   287 	 * @return values
       
   288 	 */
       
   289 	public long[] getEventValues() {
       
   290 		return event_values;
       
   291 	}
       
   292 
       
   293 	/**
       
   294 	 * Set event values
       
   295 	 * @param event_values
       
   296 	 */
       
   297 	public void setEventValues(long[] event_values) {
       
   298 		this.event_values = event_values;
       
   299 	}
       
   300 }
       
   301