EMMA Coverage Report (generated Wed Aug 29 00:03:59 CDT 2007)
[all classes][org.fuwjax.jon]

COVERAGE SUMMARY FOR SOURCE FILE [SerialFormatException.java]

nameclass, %method, %block, %line, %
SerialFormatException.java100% (2/2)45%  (5/11)65%  (70/107)59%  (11.8/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SerialFormatException100% (1/1)50%  (2/4)48%  (14/29)50%  (6/12)
SerialFormatException (String): void 0%   (0/1)0%   (0/7)0%   (0/3)
SerialFormatException (String, Throwable): void 0%   (0/1)0%   (0/8)0%   (0/3)
SerialFormatException (String, int): void 100% (1/1)100% (7/7)100% (3/3)
assertPosition (int): void 100% (1/1)100% (7/7)100% (3/3)
     
class SerialFormatException$Messages100% (1/1)43%  (3/7)72%  (56/78)73%  (5.8/8)
exception (): SerialFormatException 0%   (0/1)0%   (0/6)0%   (0/1)
exception (Throwable): SerialFormatException 0%   (0/1)0%   (0/7)0%   (0/1)
valueOf (String): SerialFormatException$Messages 0%   (0/1)0%   (0/5)0%   (0/1)
values (): SerialFormatException$Messages [] 0%   (0/1)0%   (0/4)0%   (0/1)
<static initializer> 100% (1/1)100% (44/44)100% (5/5)
SerialFormatException$Messages (String, int): void 100% (1/1)100% (5/5)100% (1/1)
exception (int): SerialFormatException 100% (1/1)100% (7/7)100% (1/1)

1/*
2 * This file is part of JON.
3 *
4 * JON is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * JON is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 * 
17 * Copyright 2007 Michael Doberenz
18 */
19package org.fuwjax.jon;
20 
21/**
22 * Thrown when the reader or writer cannot maintain JON format integrity.
23 * @author michaeldoberenz
24 */
25public class SerialFormatException extends Exception{
26        private static final long serialVersionUID = 1L;
27 
28        /**
29         * The set of possible {@link SerialFormatException} subtypes.
30         * @author michaeldoberenz
31         */
32        public enum Messages{
33                /**
34                 * Indicates the formatted output could not physically be written to the
35                 * output medium.
36                 */
37                OutputError,
38                /**
39                 * Indicates that an identifier was expected but not found on the input
40                 * medium.
41                 */
42                UnexpectedIdentifier,
43                /**
44                 * Indicates that a token was expected but not found on the input medium.
45                 */
46                UnexpectedToken,
47                /**
48                 * Indicates that more input is needed, but no more was found.
49                 */
50                UnexpectedEndOfInput;
51                /**
52                 * Returns an exception of this subtype.
53                 * @return an {@link SerialFormatException}
54                 */
55                public SerialFormatException exception(){
56                        return new SerialFormatException(name());
57                }
58 
59                /**
60                 * Returns an exception of this subtype.
61                 * @param cause the cause of this exception
62                 * @return an {@link SerialFormatException}
63                 */
64                public SerialFormatException exception(final Throwable cause){
65                        return new SerialFormatException(name(), cause);
66                }
67 
68                /**
69                 * Returns an exception of this subtype.
70                 * @param pos the current position of the reader
71                 * @return an {@link SerialFormatException}
72                 */
73                public SerialFormatException exception(final int pos){
74                        return new SerialFormatException(name(), pos);
75                }
76        }
77 
78        private final int position;
79 
80        /**
81         * Creates a new instance with a message <code>message</code>.
82         * @param message a description of the cause of this exception
83         * @param cause the cause of this exception
84         */
85        public SerialFormatException(final String message, final Throwable cause){
86                super(message, cause);
87                this.position = -1;
88        }
89 
90        /**
91         * Creates a new instance with a message <code>message</code>.
92         * @param message a description of the cause of this exception
93         * @param pos the current position of the reader
94         */
95        public SerialFormatException(final String message, final int pos){
96                super(message);
97                this.position = pos;
98        }
99 
100        /**
101         * Creates a new instance with a message <code>message</code>.
102         * @param message a description of the cause of this exception
103         */
104        public SerialFormatException(final String message){
105                super(message);
106                this.position = -1;
107        }
108 
109        /**
110         * Asserts that the curernt position of the reader is equal to
111         * <code>pos</code>.
112         * @param pos the expected position of the reader
113         * @throws SerialFormatException if the JON format has not been observed
114         */
115        public void assertPosition(final int pos) throws SerialFormatException{
116                if(pos != position){
117                        throw this;
118                }
119        }
120}

[all classes][org.fuwjax.jon]
EMMA 2.0.5312 (C) Vladimir Roubtsov