1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.job.internal.xstream

File SafeWriter.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

2
9
5
1
76
35
6
0.67
1.8
5
1.2

Classes

Class Line # Actions
SafeWriter 31 9 0% 6 0
1.0100%
 

Contributing tests

This file is covered by 30 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.job.internal.xstream;
21   
22    import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
23    import com.thoughtworks.xstream.io.WriterWrapper;
24   
25    /**
26    * Help tracking and closing forgotten ending tags.
27    *
28    * @version $Id: 0c73be107373cf337d8866ebc6326c36c6c13258 $
29    * @since 7.2RC1
30    */
 
31    public class SafeWriter extends WriterWrapper
32    {
33    private int depth;
34   
35    /**
36    * @param writer the actual writer
37    */
 
38  36249 toggle public SafeWriter(HierarchicalStreamWriter writer)
39    {
40  36250 super(writer);
41    }
42   
 
43  41214 toggle @Override
44    public void startNode(String name)
45    {
46  41214 super.startNode(name);
47   
48  41214 ++this.depth;
49    }
50   
 
51  342222 toggle @Override
52    public void startNode(String name, Class clazz)
53    {
54  342229 super.startNode(name, clazz);
55   
56  342281 ++this.depth;
57    }
58   
 
59  383453 toggle @Override
60    public void endNode()
61    {
62  383458 super.endNode();
63   
64  383486 --this.depth;
65    }
66   
67    /**
68    * Close any open tag in case of error in the middle of the serialization.
69    */
 
70  1 toggle public void fix()
71    {
72  2 while (this.depth > 0) {
73  1 endNode();
74    }
75    }
76    }