EMMA Coverage Report (generated Tue Jun 29 17:59:02 CEST 2010)
[all classes][org.jomc.standalone.model.modlet]

COVERAGE SUMMARY FOR SOURCE FILE [StandaloneModelValidator.java]

nameclass, %method, %block, %line, %
StandaloneModelValidator.java100% (1/1)100% (3/3)80%  (188/234)81%  (21/26)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class StandaloneModelValidator100% (1/1)100% (3/3)80%  (188/234)81%  (21/26)
validateModel (ModelContext, Model): ModelValidationReport 100% (1/1)79%  (174/220)78%  (18/23)
StandaloneModelValidator (): void 100% (1/1)100% (3/3)100% (2/2)
getMessage (String, Object []): String 100% (1/1)100% (11/11)100% (1/1)

1// SECTION-START[License Header]
2// <editor-fold defaultstate="collapsed" desc=" Generated License ">
3/*
4 *   Copyright (c) 2010 The JOMC Project
5 *   Copyright (c) 2005 Christian Schulte <schulte2005@users.sourceforge.net>
6 *   All rights reserved.
7 *
8 *   Redistribution and use in source and binary forms, with or without
9 *   modification, are permitted provided that the following conditions
10 *   are met:
11 *
12 *     o Redistributions of source code must retain the above copyright
13 *       notice, this list of conditions and the following disclaimer.
14 *
15 *     o Redistributions in binary form must reproduce the above copyright
16 *       notice, this list of conditions and the following disclaimer in
17 *       the documentation and/or other materials provided with the
18 *       distribution.
19 *
20 *   THIS SOFTWARE IS PROVIDED BY THE JOMC PROJECT AND CONTRIBUTORS "AS IS"
21 *   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 *   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 *   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JOMC PROJECT OR
24 *   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 *   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 *   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 *   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 *   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30 *   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 *   $Id: StandaloneModelValidator.java 2240 2010-06-29 07:53:15Z schulte2005 $
33 *
34 */
35// </editor-fold>
36// SECTION-END
37package org.jomc.standalone.model.modlet;
38 
39import java.text.MessageFormat;
40import java.util.ResourceBundle;
41import java.util.logging.Level;
42import javax.xml.bind.JAXBElement;
43import org.jomc.model.Implementation;
44import org.jomc.model.Module;
45import org.jomc.model.Modules;
46import org.jomc.model.ObjectFactory;
47import org.jomc.model.modlet.ModelHelper;
48import org.jomc.modlet.Model;
49import org.jomc.modlet.ModelContext;
50import org.jomc.modlet.ModelException;
51import org.jomc.modlet.ModelValidationReport;
52import org.jomc.modlet.ModelValidator;
53import org.jomc.standalone.model.MethodType;
54import org.jomc.standalone.model.MethodsType;
55 
56// SECTION-START[Documentation]
57// <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
58/**
59 * Standalone 'ModelValidator' implementation.
60 *
61 * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0
62 * @version $Id: StandaloneModelValidator.java 2240 2010-06-29 07:53:15Z schulte2005 $
63 */
64// </editor-fold>
65// SECTION-END
66// SECTION-START[Annotations]
67// <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
68@javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" )
69// </editor-fold>
70// SECTION-END
71public final class StandaloneModelValidator implements ModelValidator
72{
73    // SECTION-START[StandaloneModelValidator]
74 
75    public ModelValidationReport validateModel( final ModelContext context, final Model model )
76        throws ModelException
77    {
78        if ( context == null )
79        {
80            throw new NullPointerException( "context" );
81        }
82        if ( model == null )
83        {
84            throw new NullPointerException( "model" );
85        }
86 
87        final ModelValidationReport report = new ModelValidationReport();
88        final Modules modules = ModelHelper.getModules( model );
89 
90        if ( modules != null )
91        {
92            if ( context.isLoggable( Level.FINE ) )
93            {
94                context.log( Level.FINE, getMessage(
95                    "validatingModel", this.getClass().getName(), model.getIdentifier() ), null );
96 
97            }
98 
99            for ( Module m : modules.getModule() )
100            {
101                if ( m.getImplementations() != null )
102                {
103                    for ( Implementation i : m.getImplementations().getImplementation() )
104                    {
105                        final JAXBElement<Implementation> detailElement = new ObjectFactory().createImplementation( i );
106 
107                        for ( MethodsType methodsType : i.getAnyObjects( MethodsType.class ) )
108                        {
109                            if ( methodsType.getExceptions() != null
110                                 && methodsType.getExceptions().getDefaultException() != null
111                                 && methodsType.getExceptions().getDefaultException().getTargetClass() != null )
112                            {
113                                report.getDetails().add( new ModelValidationReport.Detail(
114                                    "IMPLEMENTATION_METHODS_DEFAULT_EXCEPTION_TARGET_CLASS_CONSTRAINT", Level.SEVERE,
115                                    getMessage( "implementationMethodsDefaultExceptionTargetClassConstraint",
116                                                i.getIdentifier(),
117                                                methodsType.getExceptions().getDefaultException().getClazz(),
118                                                methodsType.getExceptions().getDefaultException().getTargetClass() ),
119                                    detailElement ) );
120 
121                            }
122 
123                            for ( MethodType methodType : methodsType.getMethod() )
124                            {
125                                if ( methodType.getExceptions() != null
126                                     && methodType.getExceptions().getDefaultException() != null
127                                     && methodType.getExceptions().getDefaultException().getTargetClass() != null )
128                                {
129                                    report.getDetails().add( new ModelValidationReport.Detail(
130                                        "IMPLEMENTATION_METHOD_DEFAULT_EXCEPTION_TARGET_CLASS_CONSTRAINT", Level.SEVERE,
131                                        getMessage( "implementationMethodDefaultExceptionTargetClassConstraint",
132                                                    i.getIdentifier(), methodType.getName(),
133                                                    methodsType.getExceptions().getDefaultException().getClazz(),
134                                                    methodsType.getExceptions().getDefaultException().getTargetClass() ),
135                                        detailElement ) );
136 
137                                }
138                            }
139                        }
140                    }
141                }
142            }
143        }
144        else if ( context.isLoggable( Level.WARNING ) )
145        {
146            context.log( Level.WARNING, getMessage( "modulesNotFound", model.getIdentifier() ), null );
147        }
148 
149        return report;
150    }
151 
152    private static String getMessage( final String key, final Object... arguments )
153    {
154        return MessageFormat.format( ResourceBundle.getBundle(
155            StandaloneModelValidator.class.getName().replace( '.', '/' ) ).getString( key ), arguments );
156 
157    }
158 
159    // SECTION-END
160    // SECTION-START[Constructors]
161    // <editor-fold defaultstate="collapsed" desc=" Generated Constructors ">
162 
163    /** Creates a new {@code StandaloneModelValidator} instance. */
164    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" )
165    public StandaloneModelValidator()
166    {
167        // SECTION-START[Default Constructor]
168        super();
169        // SECTION-END
170    }
171    // </editor-fold>
172    // SECTION-END
173    // SECTION-START[Dependencies]
174    // SECTION-END
175    // SECTION-START[Properties]
176    // SECTION-END
177    // SECTION-START[Messages]
178    // SECTION-END
179}

[all classes][org.jomc.standalone.model.modlet]
EMMA 2.0.5312 (C) Vladimir Roubtsov