Clover coverage report - ATP library for Java - 3.6.4-stable-060214
Coverage timestamp: Вт фев 14 2006 13:45:22 MSK
file stats: LOC: 140   Methods: 6
NCLOC: 92   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
JavaUnicodeEscapeFilterReader.java 0% 0% 0% 0%
coverage
 1    /*
 2    * Copyright (c) 2001-2004,
 3    * RedVerst Group, ISP RAS http://www.ispras.ru
 4    * All rights reserved.
 5    *
 6    * Redistribution and use in source and binary forms, with or without
 7    * modification, are permitted provided that the following conditions are met:
 8    *
 9    * 1. Redistributions of source code must retain the above copyright notice, this
 10    * list of conditions and the following disclaimer.
 11    *
 12    * 2. Redistributions in binary form must reproduce the above copyright notice,
 13    * this list of conditions and the following disclaimer in the documentation
 14    * and/or other materials provided with the distribution.
 15    *
 16    * 3. The names "ATP", "TreeDL", "RedVerst", "ISP RAS"
 17    * may not be used to endorse or promote products derived from this software
 18    * without specific prior written permission.
 19    *
 20    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 21    * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 22    * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 23    * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 24    * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 25    * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 26    * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 27    * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28    * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 29    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30    */
 31   
 32    package com.unitesk.atp.tree.tool.antlr;
 33   
 34    import java.io.FilterReader;
 35    import java.io.IOException;
 36    import java.io.Reader;
 37   
 38    /**
 39    * This reader converts Java Unicode Escapes (\\u+XXXX)
 40    * to unicode characters as described in JLS 3.2 step 1
 41    *
 42    * @author <A href="mailto:demakov@ispras.ru">Alexey Demakov</A>
 43    * @version $Id: JavaUnicodeEscapeFilterReader.java,v 1.1 2005/06/23 13:28:43 all-x Exp $
 44    * @since 3.3
 45    */
 46    public class JavaUnicodeEscapeFilterReader extends FilterReader
 47    {
 48  0 public JavaUnicodeEscapeFilterReader(Reader in)
 49    {
 50  0 super( in );
 51    }
 52   
 53  0 private static int hex2int( int d ) throws IOException
 54    {
 55  0 switch( d )
 56    {
 57  0 case '0': return 0;
 58  0 case '1': return 1;
 59  0 case '2': return 2;
 60  0 case '3': return 3;
 61  0 case '4': return 4;
 62  0 case '5': return 5;
 63  0 case '6': return 6;
 64  0 case '7': return 7;
 65  0 case '8': return 8;
 66  0 case '9': return 9;
 67  0 case 'a':
 68  0 case 'A': return 10;
 69  0 case 'b':
 70  0 case 'B': return 11;
 71  0 case 'c':
 72  0 case 'C': return 12;
 73  0 case 'd':
 74  0 case 'D': return 13;
 75  0 case 'e':
 76  0 case 'E': return 14;
 77  0 case 'f':
 78  0 case 'F': return 15;
 79  0 default:
 80  0 throw new IOException( "illegal hex: " + d );
 81    }
 82    }
 83   
 84    private int count;
 85    private int buf;
 86   
 87    private static final boolean debug = false;
 88   
 89  0 public int read() throws IOException
 90    {
 91  0 if( count > 0 )
 92    {
 93  0 count--;
 94  0 if( debug ) System.out.print( (char)buf );
 95  0 return buf;
 96    }
 97  0 int d = super.read();
 98  0 if( d != '\\' )
 99    {
 100  0 if( debug ) System.out.print( (char)d );
 101  0 return d;
 102    }
 103  0 int value = 0;
 104  0 if( (d = super.read()) != 'u' )
 105    {
 106  0 count++;
 107  0 buf = d;
 108  0 if( debug ) System.out.print( '\\' );
 109  0 return '\\';
 110    }
 111  0 while( (d = super.read()) == 'u' ) {} // skip
 112  0 value = hex2int( d );
 113  0 value = value * 16 + hex2int( super.read() );
 114  0 value = value * 16 + hex2int( super.read() );
 115  0 value = value * 16 + hex2int( super.read() );
 116  0 if( debug ) System.out.print( "\\u" + Integer.toHexString( value ) );
 117  0 return value;
 118    }
 119   
 120  0 public int read( char[] cbuf, int off, int len ) throws IOException
 121    {
 122  0 for( int i = off; i < off + len; i++ )
 123    {
 124  0 cbuf[i] = (char)read();
 125    }
 126  0 return len;
 127    }
 128   
 129  0 public long skip( long n ) throws IOException
 130    {
 131  0 long res = n;
 132  0 while( n-- > 0 ) read();
 133  0 return res;
 134    }
 135   
 136  0 public int read( char[] cbuf ) throws IOException
 137    {
 138  0 return read( cbuf, 0, cbuf.length );
 139    }
 140    }