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

COVERAGE SUMMARY FOR SOURCE FILE [EnumType.java]

nameclass, %method, %block, %line, %
EnumType.java100% (1/1)100% (8/8)88%  (29/33)91%  (10/11)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class EnumType100% (1/1)100% (8/8)88%  (29/33)91%  (10/11)
getActualType (Object): IndirectType 100% (1/1)64%  (7/11)67%  (2/3)
EnumType (Class): void 100% (1/1)100% (4/4)100% (2/2)
createInstance (CharSequence, Object): Object 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)
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% (4/4)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.type;
20 
21import org.fuwjax.jon.ClassCastStrategy;
22import org.fuwjax.jon.IndirectType;
23import org.fuwjax.jon.ObjectAccessException;
24import org.fuwjax.jon.ReferenceStrategy;
25import org.fuwjax.jon.accessor.Literal;
26import org.fuwjax.jon.accessor.LiteralAccessor;
27import org.fuwjax.jon.accessor.Symbol;
28 
29/**
30 * An abstract layer over the enum classes.
31 * @author michaeldoberenz
32 */
33public class EnumType extends AbstractIndirectType implements LiteralAccessor{
34        /**
35         * Wraps <code>cls</code> with an indirect type.
36         * @param cls the class instance backing this type
37         */
38        public EnumType(final Class<?> cls){
39                super(cls);
40        }
41 
42        public ClassCastStrategy getClassCastStrategy(){
43                return ClassCastStrategy.AlwaysCast;
44        }
45 
46        public ReferenceStrategy getReferenceStrategy(){
47                return ReferenceStrategy.NeverReference;
48        }
49 
50        public Symbol getSymbolSpec(){
51                return Symbol.Literal;
52        }
53 
54        public Literal getLiteral(){
55                return Literal.Identifier;
56        }
57 
58        public CharSequence toString(final Object object) throws ObjectAccessException{
59                return ((Enum<?>)object).name();
60        }
61 
62        /* SW unchecked for Enum.valueOf */
63        @SuppressWarnings("unchecked")
64        public Object createInstance(final CharSequence parse, final Object source) throws ObjectAccessException{
65                return Enum.valueOf((Class<? extends Enum>)getType(), parse.toString());
66        }
67 
68        @Override
69        public IndirectType getActualType(final Object object) throws ClassCastException{
70                if(getType().isInstance(object)){
71                        return this;
72                }
73                return super.getActualType(object);
74        }
75}

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