Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 165   Methods: 15
NCLOC: 127 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Framework.Xml\XmlHandler.cs 100.0% 91.5% 100.0% 94.3%
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 Seasar.Framework.Xml;
21  
22   namespace Seasar.Framework.Xml
23   {
24   /// <summary>
25   /// XmlHandler の概要の説明です。
26   /// </summary>
27   public sealed class XmlHandler
28   {
29  
30   private TagHandlerRule tagHandlerRule_;
31   private TagHandlerContext context_ = new TagHandlerContext();
32  
33 147 public XmlHandler(TagHandlerRule tagHandlerRule)
34   {
35 147 tagHandlerRule_ = tagHandlerRule;
36   }
37  
38   public TagHandlerContext TagHandlerContext
39   {
40 140 get { return context_; }
41   }
42  
43 1439 public void StartElement(string qName,IAttributes attributes)
44   {
45 1439 this.AppendBody();
46 1439 context_.StartElement(qName);
47 1439 this.Start(attributes);
48   }
49  
50 460 public void Characters(string text)
51   {
52 460 context_.Characters = text;
53 460 this.AppendBody();
54   }
55  
56 1437 public void EndElement(string qName)
57   {
58 1437 this.AppendBody();
59 1437 this.End();
60 1437 context_.EndElement();
61   }
62  
63   public object Result
64   {
65 146 get { return context_.Result; }
66   }
67  
68 3336 private TagHandler GetTagHandlerByPath()
69   {
70 3336 return tagHandlerRule_[context_.Path];
71   }
72  
73 3335 private TagHandler GetTagHandlerByQName()
74   {
75 3335 return tagHandlerRule_[context_.QName];
76   }
77  
78 1439 private void Start(IAttributes attributes)
79   {
80 1439 TagHandler th = this.GetTagHandlerByPath();
81 1439 this.Start(th,attributes);
82 1438 th = this.GetTagHandlerByQName();
83 1438 this.Start(th,attributes);
84   }
85  
86 2877 private void Start(TagHandler handler, IAttributes attributes)
87   {
88 2877 if(handler != null)
89   {
90 1417 try
91   {
92 1417 handler.Start(context_,attributes);
93   }
94   catch(Exception ex)
95   {
96 1 this.ReportDetailPath(ex);
97 1 throw ex;
98   }
99   }
100   }
101  
102 3336 private void AppendBody()
103   {
104 3336 string characters = context_.Characters;
105 3336 if(characters.Length > 0)
106   {
107 460 TagHandler th = this.GetTagHandlerByPath();
108 460 this.AppendBody(th,characters);
109 460 th = this.GetTagHandlerByQName();
110 460 this.AppendBody(th,characters);
111 460 context_.ClearCharacters();
112   }
113   }
114  
115 920 private void AppendBody(TagHandler handler, string characters)
116   {
117 920 if(handler != null)
118   {
119 441 try
120   {
121 441 handler.AppendBody(context_, characters);
122   }
123   catch(Exception ex)
124   {
125 0 this.ReportDetailPath(ex);
126 0 throw ex;
127   }
128   }
129   }
130  
131 1437 private void End()
132   {
133 1437 string body = context_.Body;
134 1437 TagHandler th = this.GetTagHandlerByPath();
135 1437 this.End(th,body);
136 1437 th = this.GetTagHandlerByQName();
137 1437 this.End(th,body);
138   }
139  
140 2874 private void End(TagHandler handler, string body)
141   {
142 2874 if(handler != null)
143   {
144 1416 try
145   {
146 1416 handler.End(context_,body);
147   }
148   catch(Exception ex)
149   {
150 0 this.ReportDetailPath(ex);
151 0 throw ex;
152   }
153   }
154   }
155  
156 1 private void ReportDetailPath(Exception cause)
157   {
158 1 Console.WriteLine("Exception occured at " + context_.DetailPath);
159 1 Console.WriteLine(cause.Message);
160 1 Console.WriteLine(cause.StackTrace);
161   }
162  
163   }
164   }
165