tracesrv/tracecompiler/src/com.nokia.tracecompiler/src/com/nokia/tracecompiler/engine/propertyfile/PropertyFileUtils.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 * Utility functions for property file
       
    17 *
       
    18 */
       
    19 package com.nokia.tracecompiler.engine.propertyfile;
       
    20 
       
    21 import org.w3c.dom.Document;
       
    22 import org.w3c.dom.Element;
       
    23 import org.w3c.dom.Node;
       
    24 import org.w3c.dom.NodeList;
       
    25 
       
    26 /**
       
    27  * Utility functions for property file
       
    28  * 
       
    29  */
       
    30 final class PropertyFileUtils {
       
    31 
       
    32 	/**
       
    33 	 * Finds the root element from property file document
       
    34 	 * 
       
    35 	 * @param document
       
    36 	 *            the document
       
    37 	 * @return the root element
       
    38 	 */
       
    39 	static Element findRoot(Document document) {
       
    40 		NodeList list = document.getChildNodes();
       
    41 		Element rootElement = null;
       
    42 		for (int i = 0; i < list.getLength(); i++) {
       
    43 			Node root = list.item(i);
       
    44 			if (root.getNodeType() == Node.ELEMENT_NODE) {
       
    45 				if (root.getNodeName().equalsIgnoreCase(
       
    46 						PropertyFileConstants.ROOT_ELEMENT)) {
       
    47 					rootElement = (Element) root;
       
    48 				}
       
    49 			}
       
    50 		}
       
    51 		return rootElement;
       
    52 	}
       
    53 
       
    54 }