trace/traceviewer/com.nokia.trace.dictionary/src/com/nokia/trace/dictionary/model/handlers/TraceHandler.java
changeset 11 5b9d4d8641ce
equal deleted inserted replaced
10:ed1c9f64298a 11:5b9d4d8641ce
       
     1 /*
       
     2  * Copyright (c) 2007-2010 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  * Trace handler
       
    17  *
       
    18  */
       
    19 package com.nokia.trace.dictionary.model.handlers;
       
    20 
       
    21 import org.xml.sax.Attributes;
       
    22 
       
    23 import com.nokia.trace.dictionary.model.DecodeObject;
       
    24 import com.nokia.trace.dictionary.model.DictionaryContentHandler;
       
    25 import com.nokia.trace.dictionary.model.DictionaryContentVariables;
       
    26 import com.nokia.trace.dictionary.model.DictionaryDecodeModel;
       
    27 import com.nokia.trace.dictionary.model.TraceInstanceList;
       
    28 import com.nokia.trace.dictionary.model.DictionaryContentVariables.ParentDecodeObject;
       
    29 
       
    30 /**
       
    31  * Trace handler
       
    32  * 
       
    33  */
       
    34 final class TraceHandler extends BaseHandler {
       
    35 
       
    36 	/**
       
    37 	 * Tag name this handler handles
       
    38 	 */
       
    39 	private static final String TRACE_TAG = "trace"; //$NON-NLS-1$
       
    40 
       
    41 	/**
       
    42 	 * Constructor
       
    43 	 * 
       
    44 	 * @param model
       
    45 	 *            the model
       
    46 	 */
       
    47 	TraceHandler(DictionaryDecodeModel model) {
       
    48 		super(model, TRACE_TAG);
       
    49 	}
       
    50 
       
    51 	/*
       
    52 	 * (non-Javadoc)
       
    53 	 * 
       
    54 	 * @see com.nokia.trace.dictionary.model.handlers.DictionaryHandler#
       
    55 	 * processElement(org.xml.sax.Attributes)
       
    56 	 */
       
    57 	@Override
       
    58 	public void processStartElement(Attributes atts,
       
    59 			DictionaryContentHandler handler) {
       
    60 
       
    61 		DictionaryContentVariables variables = handler.getVariables();
       
    62 
       
    63 		// Save the data-ref value to variables
       
    64 		variables.setPreviousTraceDataRef(Integer.parseInt(atts
       
    65 				.getValue(DATAREF)));
       
    66 		variables.setTraceInstanceList(new TraceInstanceList(0, "allthesame")); //$NON-NLS-1$
       
    67 		variables.setParentDecodeObject(ParentDecodeObject.TRACE);
       
    68 
       
    69 		// Save trace name to variables
       
    70 		variables.setPreviousTraceName(atts.getValue(NAME));
       
    71 	}
       
    72 
       
    73 	/*
       
    74 	 * (non-Javadoc)
       
    75 	 * 
       
    76 	 * @see
       
    77 	 * com.nokia.trace.dictionary.model.handlers.BaseHandler#processEndElement
       
    78 	 * (java.lang.StringBuffer, java.lang.Object,
       
    79 	 * com.nokia.trace.dictionary.model.DictionaryContentHandler,
       
    80 	 * com.nokia.trace.dictionary.model.DecodeObject)
       
    81 	 */
       
    82 	@Override
       
    83 	public void processEndElement(StringBuffer elementContent,
       
    84 			Object unFinishedObject, DictionaryContentHandler handler,
       
    85 			DecodeObject parentObject) {
       
    86 		DictionaryContentVariables variables = handler.getVariables();
       
    87 
       
    88 		// Set metadata to traces and remove the list afterwards
       
    89 		variables.getTraceInstanceList().setMetadataToTraces();
       
    90 		variables.setTraceInstanceList(null);
       
    91 		variables.setParentDecodeObject(ParentDecodeObject.GROUP);
       
    92 	}
       
    93 }