crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianXmlInputLib/Parser/Nodes/SXILParserNodeCommand.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     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 using System;
       
    18 using System.IO;
       
    19 using System.Xml;
       
    20 using System.Text;
       
    21 using System.Collections.Generic;
       
    22 using SymbianTree;
       
    23 using SymbianUtils;
       
    24 using SymbianXmlInputLib.Elements;
       
    25 using SymbianXmlInputLib.Elements.Types.Command;
       
    26 
       
    27 namespace SymbianXmlInputLib.Parser.Nodes
       
    28 {
       
    29     public class SXILParserNodeCommand : SXILParserNode
       
    30     {
       
    31         #region Constructors
       
    32         public SXILParserNodeCommand()
       
    33         {
       
    34         }
       
    35 
       
    36         public SXILParserNodeCommand( string aDescription )
       
    37             : base( aDescription )
       
    38         {
       
    39         }
       
    40         #endregion
       
    41 
       
    42         #region From SXILParserNode
       
    43         public override bool IsMulti
       
    44         {
       
    45             get
       
    46             {
       
    47                 return true;
       
    48             }
       
    49         }
       
    50 
       
    51         public override void XmlParse( XmlNode aNode )
       
    52         {
       
    53             XmlAttributeCollection attribs = aNode.Attributes;
       
    54             if ( attribs.Count < 1 || attribs[ "name" ] == null )
       
    55             {
       
    56                 throw new ArgumentException( "Mandatory name node missing" );
       
    57             }
       
    58 
       
    59             XmlAttribute nameAttribute = attribs[ "name" ];
       
    60             string name = nameAttribute.Value.Trim();
       
    61 
       
    62             // Get details if present
       
    63             string details = aNode.InnerText.Trim();
       
    64 
       
    65             SXILElementCommand command = new SXILElementCommand( name, details );
       
    66             base.Document.CurrentNode.Add( command );
       
    67 
       
    68             iHandled = true;
       
    69         }
       
    70 
       
    71         public override bool CanHandle( XmlNode aNode )
       
    72         {
       
    73             bool ret = false;
       
    74             
       
    75             // We must support categories that contain multiple commands
       
    76             // therefore we must provide a means of preventing an already-populated command from
       
    77             // processing multiple xml tags.
       
    78             if ( !iHandled )
       
    79             {
       
    80                 // This command instance has not yet successfully processed a command, so
       
    81                 // it's okay to at least attempt to handle it - providing the xml tag is
       
    82                 // our expected "command" name.
       
    83                 ret = ( aNode.Name.ToUpper() == KXmlTagName );
       
    84             }
       
    85             //
       
    86             return ret;
       
    87         }
       
    88         #endregion
       
    89 
       
    90         #region Internal constants
       
    91         private const string KXmlTagName = "COMMAND";
       
    92         #endregion
       
    93 
       
    94         #region Data members
       
    95         private bool iHandled = false;
       
    96         #endregion
       
    97     }
       
    98 }