tracesrv/tracecompiler/src/com.nokia.tracecompiler/src/com/nokia/tracecompiler/engine/propertyfile/FileElementParser.java
changeset 56 aa2539c91954
equal deleted inserted replaced
54:a151135b0cf9 56:aa2539c91954
       
     1 /*
       
     2 * Copyright (c) 2008 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 * FIle element parser
       
    17 *
       
    18 */
       
    19 package com.nokia.tracecompiler.engine.propertyfile;
       
    20 
       
    21 import java.io.File;
       
    22 import java.io.IOException;
       
    23 import java.util.ArrayList;
       
    24 
       
    25 import org.w3c.dom.Element;
       
    26 
       
    27 import com.nokia.tracecompiler.engine.TraceCompilerEngineGlobals;
       
    28 import com.nokia.tracecompiler.engine.project.ProjectEngine;
       
    29 import com.nokia.tracecompiler.engine.source.SourceEngine;
       
    30 import com.nokia.tracecompiler.model.TraceCompilerException;
       
    31 
       
    32 /**
       
    33  * File element parser
       
    34  * 
       
    35  */
       
    36 final class FileElementParser implements PropertyFileElementParser {
       
    37 
       
    38 	/*
       
    39 	 * (non-Javadoc)
       
    40 	 * 
       
    41 	 * @see com.nokia.tracecompiler.engine.propertyfile.PropertyFileElementParser#
       
    42 	 *      parse(java.lang.Object, org.w3c.dom.Element)
       
    43 	 */
       
    44 	public void parse(Object owner, Element element)
       
    45 			throws TraceCompilerException {
       
    46 		String filePath = element.getTextContent();
       
    47 		SourceEngine sourceEngine = TraceCompilerEngineGlobals.getSourceEngine();
       
    48 		ArrayList<String> list = sourceEngine.getNonSourceFiles();
       
    49 
       
    50 		String projectPath = TraceCompilerEngineGlobals.getProjectPath();
       
    51 
       
    52 		File file = new File(projectPath + File.separatorChar
       
    53 				+ ProjectEngine.traceFolderName + File.separatorChar + filePath);
       
    54 
       
    55 		try {
       
    56 			filePath = file.getCanonicalPath();
       
    57 		} catch (IOException e) {
       
    58 			e.printStackTrace();
       
    59 		}
       
    60 
       
    61 		if (!list.contains(filePath)) {
       
    62 			sourceEngine.addNonSourceFile(filePath);
       
    63 		}
       
    64 	}
       
    65 }