Clover coverage report - XJavaDoc - 1.1 Coverage timestamp: Sun Oct 3 2004 19:56:54 BST FRAMES NO FRAMES |
file stats: | LOC: | 148 |  | Methods: | 4
| NCLOC: | 78 |  | Classes: | 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
Source file | Conditionals | Statements | Methods | TOTAL
NodePrinter.java | 72.2% | 75% | 75% | 74.1% |

1 |  |
     /*
2 |  |
      * Copyright (c) 2001-2003 The XDoclet team
3 |  |
      * All rights reserved.
4 |  |
      */
5 |  |
     package xjavadoc;
6 |  |
7 |  |
     import java.io.PrintWriter;
8 |  |
     import java.io.Writer;
9 |  |
10 |  |
     /**
11 |  |
      * This visitor prints a node and all its children to a PrintWriter. The
12 |  |
      * PrintWriter must be passed to the data variable in the jjtAccept method of
13 |  |
      * the node from which printing should start. T print a whole class, call
14 |  |
      * compilationUnit.jjtAccept( new PrintVisitor(), System.out );
15 |  |
      *
16 |  |
      * @author    Aslak Hellesøy
17 |  |
      * @created   8. januar 2002
18 |  |
      * @todo      replace PrintWriter with PrintWriter and remove the
19 |  |
      *      addUnicodeEscapes()
20 |  |
      */
21 |  |
     public final class NodePrinter
22 |  |
     {
23 |  |
24 |  |
         /**
25 |  |
          * Describe what the method does
26 |  |
          *
27 |  |
          * @param node     Describe what the parameter does
28 |  |
          * @param o
29 |  |
          * @todo-javadoc   Write javadocs for method parameter
30 |  |
          * @todo-javadoc   Write javadocs for method
31 |  |
          * @todo-javadoc   Write javadocs for method parameter
32 |  |
          * @todo-javadoc   Write javadocs for method parameter
33 |  |
          * @todo-javadoc   Write javadocs for return value
34 |  |
          */
35 | 4896 |
         public static void print( SimpleNode node, Writer o )
36 |  |
         {
37 | 4896 |
             PrintWriter out = new PrintWriter( o );
38 | 4896 |
             Token t1 = node.getFirstToken();
39 | 4896 |
             Token t = new Token();
40 |  |
41 | 4896 |
             t.next = t1;
42 |  |
43 | 4896 |
             SimpleNode n;
44 |  |
45 | 4896 |
             for( int ord = 0; ord < node.jjtGetNumChildren(); ord++ )
46 |  |
             {
47 | 4884 |
                 n = ( SimpleNode ) node.jjtGetChild( ord );
48 | 4884 |
                 while( true )
49 |  |
                 {
50 | 5678 |
                     t = t.next;
51 | 5678 |
                     if( t == n.getFirstToken() )
52 |  |
                     {
53 | 4884 |
                         break;
54 |  |
                     }
55 | 794 |
                     print( t, out );
56 |  |
                 }
57 | 4884 |
                 print( n, out );
58 | 4884 |
                 t = n.getLastToken();
59 |  |
             }
60 |  |
61 | 4896 |
             while( t != node.getLastToken() && t != null )
62 |  |
             {
63 | 1604 |
                 t = t.next;
64 | 1604 |
                 if( t != null )
65 |  |
                 {
66 | 1604 |
                     print( t, out );
67 |  |
                 }
68 |  |
             }
69 |  |
         }
70 |  |
71 |  |
         /**
72 |  |
          * Describe what the method does
73 |  |
          *
74 |  |
          * @param t        Describe what the parameter does
75 |  |
          * @param out      Describe what the parameter does
76 |  |
          * @todo-javadoc   Write javadocs for method
77 |  |
          * @todo-javadoc   Write javadocs for method parameter
78 |  |
          * @todo-javadoc   Write javadocs for method parameter
79 |  |
          */
80 | 2398 |
         private final static void print( Token t, PrintWriter out )
81 |  |
         {
82 | 2398 |
             Token tt = t.specialToken;
83 |  |
84 | 2398 |
             if( tt != null )
85 |  |
             {
86 | 1412 |
                 while( tt.specialToken != null )
87 |  |
                 {
88 | 2436 |
                     tt = tt.specialToken;
89 |  |
                 }
90 | 1412 |
                 while( tt != null )
91 |  |
                 {
92 | 3852 |
                     out.print( addUnicodeEscapes( tt.image ) );
93 |  |
     //                out.print(tt.image);
94 | 3852 |
                     tt = tt.next;
95 |  |
                 }
96 |  |
             }
97 | 2398 |
             out.print( addUnicodeEscapes( t.image ) );
98 |  |
     //        out.print(t.image);
99 |  |
         }
100 |  |
101 |  |
         /**
102 |  |
          * Describe the method
103 |  |
          *
104 |  |
          * @param str      Describe the method parameter
105 |  |
          * @return         Describe the return value
106 |  |
          * @todo-javadoc   Describe the method
107 |  |
          * @todo-javadoc   Describe the method parameter
108 |  |
          * @todo-javadoc   Write javadocs for return value
109 |  |
          */
110 | 6250 |
         private final static String addUnicodeEscapes( final String str )
111 |  |
         {
112 | 6250 |
             return str;
113 |  |
         }
114 |  |
115 |  |
         /**
116 |  |
          * Describe the method
117 |  |
          *
118 |  |
          * @param str      Describe the method parameter
119 |  |
          * @return         Describe the return value
120 |  |
          * @todo-javadoc   Describe the method
121 |  |
          * @todo-javadoc   Describe the method parameter
122 |  |
          * @todo-javadoc   Write javadocs for return value
123 |  |
          */
124 | 0 |
         protected String addUnicodeEscapesOld( String str )
125 |  |
         {
126 | 0 |
             String retval = "";
127 | 0 |
             char ch;
128 |  |
129 | 0 |
             for( int i = 0; i < str.length(); i++ )
130 |  |
             {
131 | 0 |
                 ch = str.charAt( i );
132 | 0 |
                 if( ( ch < 0x20 || ch > 0x7e ) &&
133 |  |
                     ch != '\t' && ch != '\n' && ch != '\r' && ch != '\f' )
134 |  |
                 {
135 | 0 |
                     String s = "0000" + Integer.toString( ch, 16 );
136 |  |
137 | 0 |
                     retval += "\\u" + s.substring( s.length() - 4, s.length() );
138 |  |
                 }
139 |  |
                 else
140 |  |
                 {
141 | 0 |
                     retval += ch;
142 |  |
                 }
143 |  |
             }
144 | 0 |
             return retval;
145 |  |
         }
146 |  |
147 |  |
     }
148 |  |