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

COVERAGE SUMMARY FOR SOURCE FILE [NullType.java]

nameclass, %method, %block, %line, %
NullType.java100% (3/3)89%  (16/18)79%  (86/109)79%  (22/28)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class NullType$2100% (1/1)67%  (2/3)68%  (17/25)67%  (2/3)
read (Object): Object 0%   (0/1)0%   (0/8)0%   (0/1)
NullType$2 (NullType, CachedLexable): void 100% (1/1)100% (9/9)100% (1/1)
read (): Object 100% (1/1)100% (8/8)100% (1/1)
     
class NullType100% (1/1)92%  (12/13)78%  (52/67)77%  (17/22)
getIndirectType (Class): IndirectType 0%   (0/1)0%   (0/8)0%   (0/3)
getActualType (Object): IndirectType 100% (1/1)50%  (4/8)67%  (2/3)
createInstance (CharSequence, Object): Object 100% (1/1)70%  (7/10)67%  (2/3)
<static initializer> 100% (1/1)100% (5/5)100% (1/1)
NullType (): void 100% (1/1)100% (3/3)100% (2/2)
createReader (CachedLexable): Reader 100% (1/1)100% (6/6)100% (1/1)
createWriter (CachedAppendable): Writer 100% (1/1)100% (6/6)100% (1/1)
getClassCastStrategy (): ClassCastStrategy 100% (1/1)100% (2/2)100% (1/1)
getLiteral (): Literal 100% (1/1)100% (2/2)100% (1/1)
getName (): String 100% (1/1)100% (4/4)100% (1/1)
getReferenceStrategy (): ReferenceStrategy 100% (1/1)100% (2/2)100% (1/1)
getSymbolSpec (): Symbol 100% (1/1)100% (2/2)100% (1/1)
toString (Object): CharSequence 100% (1/1)100% (9/9)100% (3/3)
     
class NullType$1100% (1/1)100% (2/2)100% (17/17)100% (3/3)
NullType$1 (NullType, CachedAppendable): void 100% (1/1)100% (9/9)100% (1/1)
write (Object): void 100% (1/1)100% (8/8)100% (2/2)

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.type;
20 
21import org.fuwjax.jon.CachedAppendable;
22import org.fuwjax.jon.CachedLexable;
23import org.fuwjax.jon.ClassCastStrategy;
24import org.fuwjax.jon.IndirectType;
25import org.fuwjax.jon.ObjectAccessException;
26import org.fuwjax.jon.Reader;
27import org.fuwjax.jon.ReferenceStrategy;
28import org.fuwjax.jon.SerialFormatException;
29import org.fuwjax.jon.Writer;
30import org.fuwjax.jon.accessor.Literal;
31import org.fuwjax.jon.accessor.LiteralAccessor;
32import org.fuwjax.jon.accessor.Symbol;
33 
34/**
35 * An abstract type to be used only for as long as we don't know the type of the
36 * object being serialized.
37 * @author michaeldoberenz
38 */
39public final class NullType implements IndirectType, LiteralAccessor{
40        /**
41         * The singleton instance.
42         */
43        public static final NullType DEFAULT = new NullType();
44        private static final String NULL = "null"; //$NON-NLS-1$
45 
46        private NullType(){
47                // for singleton
48        }
49 
50        public IndirectType getActualType(final Object object){
51                if(object == null){
52                        return this;
53                }
54                throw new ClassCastException();
55        }
56 
57        public IndirectType getIndirectType(final Class<?> cls){
58                if(cls == null){
59                        return this;
60                }
61                throw new ClassCastException();
62        }
63 
64        public ClassCastStrategy getClassCastStrategy(){
65                return ClassCastStrategy.NeverCast;
66        }
67 
68        public String getName(){
69                throw new UnsupportedOperationException();
70        }
71 
72        public ReferenceStrategy getReferenceStrategy(){
73                return ReferenceStrategy.NeverReference;
74        }
75 
76        public Symbol getSymbolSpec(){
77                return Symbol.Literal;
78        }
79 
80        public Literal getLiteral(){
81                return Literal.Identifier;
82        }
83 
84        public CharSequence toString(final Object object) throws ObjectAccessException{
85                if(object == null){
86                        return String.valueOf((Object)null);
87                }
88                throw ObjectAccessException.Message.NonNullNotInstanceOfNullType.exception();
89        }
90 
91        public Object createInstance(final CharSequence parse, final Object source) throws ObjectAccessException{
92                if(NULL.equals(parse.toString())){
93                        return null;
94                }
95                throw ObjectAccessException.Message.NonNullNotInstanceOfNullType.exception();
96        }
97 
98        public Writer createWriter(final CachedAppendable appender){
99                return new Writer(){
100                        public void write(final Object object) throws ObjectAccessException, SerialFormatException{
101                                Symbol.Element.write(appender, object, NullType.this);
102                        }
103                };
104        }
105 
106        public Reader createReader(final CachedLexable lexer){
107                return new Reader(){
108                        public Object read() throws ObjectAccessException, SerialFormatException{
109                                return Symbol.Element.read(lexer, null, NullType.this);
110                        }
111 
112                        public Object read(final Object object) throws ObjectAccessException, SerialFormatException{
113                                return Symbol.Element.read(lexer, object, NullType.this);
114                        }
115                };
116        }
117}

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