|
1 /* |
|
2 * Copyright (c) 2004-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 */ |
|
17 |
|
18 using System; |
|
19 using System.Collections; |
|
20 using System.Xml; |
|
21 using SymBuildParsingLib.Token; |
|
22 using SymbianTree; |
|
23 |
|
24 namespace SymBuildParsingLib.Tree |
|
25 { |
|
26 public class SymNodeToken : SymNodeAddAsChild |
|
27 { |
|
28 #region Constructors & destructor |
|
29 public SymNodeToken( SymToken aToken ) |
|
30 { |
|
31 Data = aToken; |
|
32 } |
|
33 #endregion |
|
34 |
|
35 #region API |
|
36 public virtual int CountTokenByType( SymToken.TClass aClass ) |
|
37 { |
|
38 int count = 0; |
|
39 // |
|
40 foreach( SymNode n in this ) |
|
41 { |
|
42 if ( n is SymNodeToken ) |
|
43 { |
|
44 SymToken t = ((SymNodeToken) n).Token; |
|
45 // |
|
46 if ( t.Class == aClass ) |
|
47 { |
|
48 ++count; |
|
49 } |
|
50 } |
|
51 } |
|
52 // |
|
53 return count; |
|
54 } |
|
55 #endregion |
|
56 |
|
57 #region Properties - data |
|
58 public SymToken Token |
|
59 { |
|
60 get { return (SymToken) Data; } |
|
61 set { Data = value; } |
|
62 } |
|
63 #endregion |
|
64 |
|
65 #region From System.Object |
|
66 public override string ToString() |
|
67 { |
|
68 return Token.ToString(); |
|
69 } |
|
70 |
|
71 public override bool Equals( object aObject ) |
|
72 { |
|
73 bool same = false; |
|
74 // |
|
75 if ( aObject is SymNodeToken ) |
|
76 { |
|
77 SymNodeToken otherToken = (SymNodeToken) aObject; |
|
78 // |
|
79 same = otherToken.Token.Equals( Token ); |
|
80 } |
|
81 // |
|
82 return same; |
|
83 } |
|
84 #endregion |
|
85 |
|
86 #region XML |
|
87 public override void ExternaliseAsXML( XmlWriter aSink ) |
|
88 { |
|
89 if ( Token != null ) |
|
90 { |
|
91 aSink.WriteAttributeString( "value", Token.Value ); |
|
92 } |
|
93 else |
|
94 { |
|
95 aSink.WriteAttributeString( "value", "" ); |
|
96 } |
|
97 } |
|
98 #endregion |
|
99 } |
|
100 } |