tracesrv/tracecompiler/src/com.nokia.tracecompiler/src/com/nokia/tracecompiler/engine/propertyfile/EnumElementParser.java
changeset 56 aa2539c91954
equal deleted inserted replaced
54:a151135b0cf9 56:aa2539c91954
       
     1 /*
       
     2 * Copyright (c) 2007 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 * Parser for enum element
       
    17 *
       
    18 */
       
    19 package com.nokia.tracecompiler.engine.propertyfile;
       
    20 
       
    21 import org.w3c.dom.Element;
       
    22 
       
    23 import com.nokia.tracecompiler.engine.TraceCompilerEngineGlobals;
       
    24 import com.nokia.tracecompiler.model.TraceCompilerException;
       
    25 import com.nokia.tracecompiler.model.TraceConstantTable;
       
    26 import com.nokia.tracecompiler.model.TraceModel;
       
    27 import com.nokia.tracecompiler.model.TraceModelExtension;
       
    28 
       
    29 /**
       
    30  * Parser for enum element
       
    31  * 
       
    32  */
       
    33 final class EnumElementParser implements PropertyFileElementParser {
       
    34 
       
    35 	/**
       
    36 	 * Property file parser
       
    37 	 */
       
    38 	private final PropertyFileParser propertyFileParser;
       
    39 
       
    40 	/**
       
    41 	 * Constructor
       
    42 	 * 
       
    43 	 * @param propertyFileParser
       
    44 	 *            the parser
       
    45 	 */
       
    46 	EnumElementParser(PropertyFileParser propertyFileParser) {
       
    47 		this.propertyFileParser = propertyFileParser;
       
    48 	}
       
    49 
       
    50 	/*
       
    51 	 * (non-Javadoc)
       
    52 	 * 
       
    53 	 * @see com.nokia.tracecompiler.engine.propertyfile.PropertyFileElementParser#
       
    54 	 *      parse(java.lang.Object, org.w3c.dom.Element)
       
    55 	 */
       
    56 	public void parse(Object owner, Element element)
       
    57 			throws TraceCompilerException {
       
    58 		TraceModel model = TraceCompilerEngineGlobals.getTraceModel();
       
    59 		String name = element
       
    60 				.getAttribute(PropertyFileConstants.NAME_ATTRIBUTE);
       
    61 		int id = model.getNextConstantTableID();
       
    62 		model.getVerifier().checkConstantTableProperties(model, null, id, name);
       
    63 		// Document element reference is stored to the model
       
    64 		TraceModelExtension[] exts = new TraceModelExtension[] { new DocumentElementWrapper(
       
    65 				element) };
       
    66 		TraceConstantTable table = model.getFactory().createConstantTable(id,
       
    67 				name, exts);
       
    68 		propertyFileParser.parseChildren(table, element);
       
    69 	}
       
    70 }