Clover.NET coverage report - Coverage for s2container.net

Coverage timestamp: 2006年5月30日 11:21:29

File Stats: LOC: 191   Methods: 21
NCLOC: 146 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Framework.Xml\TagHandlerContext.cs 78.6% 93.1% 95.2% 91.4%
coverage coverage
1   #region Copyright
2   /*
3   * Copyright 2005 the Seasar Foundation and the Others.
4   *
5   * Licensed under the Apache License, Version 2.0 (the "License");
6   * you may not use this file except in compliance with the License.
7   * You may obtain a copy of the License at
8   *
9   * http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14   * either express or implied. See the License for the specific language
15   * governing permissions and limitations under the License.
16   */
17   #endregion
18  
19   using System;
20   using System.Text;
21   using System.Collections;
22  
23   namespace Seasar.Framework.Xml
24   {
25   /// <summary>
26   /// TagHandlerContext の概要の説明です。
27   /// </summary>
28   public sealed class TagHandlerContext
29   {
30   private StringBuilder body_ = null;
31   private StringBuilder characters_ = new StringBuilder();
32   private Stack bodyStack_ = new Stack();
33   private StringBuilder path_ = new StringBuilder();
34   private StringBuilder detailPath_ = new StringBuilder();
35   private string qName_ = "";
36   private Stack qNameStack_ = new Stack();
37   private object result_;
38   private Stack stack_ = new Stack();
39   private Hashtable pathCounts_ = new Hashtable();
40   private Hashtable parameters_ = new Hashtable();
41  
42 149 public TagHandlerContext()
43   {
44   }
45  
46 1383 public void Push(object obj)
47   {
48 1383 if(stack_.Count == 0) result_ = obj;
49 1383 stack_.Push(obj);
50   }
51  
52   public object Result
53   {
54 146 get { return result_; }
55   }
56  
57 1238 public object Pop()
58   {
59 1238 return stack_.Pop();
60   }
61  
62 1921 public object Peek()
63   {
64 1921 return stack_.Peek();
65   }
66  
67 655 public object Peek(int n)
68   {
69 655 IEnumerator enu = stack_.GetEnumerator();
70 655 int index = stack_.Count - n - 1;
71 655 int i = 0;
72 1059 while(enu.MoveNext())
73   {
74 1059 if(index == i++) return enu.Current;
75   }
76 0 return null;
77   }
78  
79 3 public object Peek(Type type)
80   {
81 3 IEnumerator enu = stack_.GetEnumerator();
82 7 while(enu.MoveNext())
83   {
84 6 object o = enu.Current;
85 6 if(type.IsInstanceOfType(o)) return o;
86   }
87 1 return null;
88   }
89  
90 280 public object GetParameter(string name)
91   {
92 280 return parameters_[name];
93   }
94  
95 280 public void AddParameter(string name,object parameter)
96   {
97 280 parameters_[name] = parameter;
98   }
99  
100 1442 public void StartElement(string qName)
101   {
102 1442 bodyStack_.Push(body_);
103 1442 body_ = new StringBuilder();
104 1442 characters_ = new StringBuilder();
105 1442 qNameStack_.Push(qName_);
106 1442 qName_ = qName;
107 1442 path_.Append("/");
108 1442 path_.Append(qName);
109 1442 int pathCount = this.IncrementPathCount();
110 1442 detailPath_.Append("/");
111 1442 detailPath_.Append(qName);
112 1442 detailPath_.Append("[");
113 1442 detailPath_.Append(pathCount);
114 1442 detailPath_.Append("]");
115   }
116  
117   public string Characters
118   {
119 3336 get { return characters_.ToString().Trim(); }
120 460 set
121   {
122 460 body_.Append(value);
123 460 characters_.Append(value);
124   }
125   }
126  
127   public string Body
128   {
129 1437 get { return body_.ToString().Trim(); }
130   }
131  
132 0 public bool IsCharactersEol
133   {
134   get
135   {
136   if(characters_.Length == 0) return false;
137   return characters_[characters_.Length - 1] == '\n';
138   }
139   }
140  
141 460 public void ClearCharacters()
142   {
143 460 characters_ = new StringBuilder();
144   }
145  
146 1438 public void EndElement()
147   {
148 1438 body_ = (StringBuilder) bodyStack_.Pop();
149 1438 RemoveLastPath(path_);
150 1438 RemoveLastPath(detailPath_);
151 1438 qName_ = (string) qNameStack_.Pop();
152   }
153  
154 2876 private static void RemoveLastPath(StringBuilder path)
155   {
156 2876 int last = path.ToString().LastIndexOf("/");
157 2876 path.Remove(last,path.Length - last);
158   }
159  
160   public string Path
161   {
162 4782 get { return path_.ToString(); }
163   }
164  
165   public string DetailPath
166   {
167 10 get { return detailPath_.ToString(); }
168   }
169  
170   public string QName
171   {
172 3339 get { return qName_; }
173   }
174  
175 1442 private int IncrementPathCount()
176   {
177 1442 string path = this.Path;
178 1442 int pathCount = 0;
179  
180 1442 if(pathCounts_[path] != null)
181   {
182 914 pathCount = (int) pathCounts_[path];
183   }
184  
185 1442 pathCount++;
186 1442 pathCounts_[path] = pathCount;
187 1442 return pathCount;
188   }
189   }
190   }
191