EMMA Coverage Report (generated Wed Oct 03 05:00:03 CEST 2012)
[all classes][org.jdtaus.core.text.util]

COVERAGE SUMMARY FOR SOURCE FILE [MessageLogger.java]

nameclass, %method, %block, %line, %
MessageLogger.java0%   (0/1)0%   (0/5)0%   (0/87)0%   (0/15)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MessageLogger0%   (0/1)0%   (0/5)0%   (0/87)0%   (0/15)
MessageLogger (): void 0%   (0/1)0%   (0/3)0%   (0/1)
getLocale (): Locale 0%   (0/1)0%   (0/6)0%   (0/1)
getLogger (): Logger 0%   (0/1)0%   (0/6)0%   (0/1)
getUnknownMessageEventTypeMessage (Locale, Number): String 0%   (0/1)0%   (0/12)0%   (0/1)
onMessage (MessageEvent): void 0%   (0/1)0%   (0/60)0%   (0/11)

1/*
2 *  jDTAUS Core Utilities
3 *  Copyright (C) 2005 Christian Schulte
4 *  <cs@schulte.it>
5 *
6 *  This library is free software; you can redistribute it and/or
7 *  modify it under the terms of the GNU Lesser General Public
8 *  License as published by the Free Software Foundation; either
9 *  version 2.1 of the License, or any later version.
10 *
11 *  This library is distributed in the hope that it will be useful,
12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 *  Lesser General Public License for more details.
15 *
16 *  You should have received a copy of the GNU Lesser General Public
17 *  License along with this library; if not, write to the Free Software
18 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19 *
20 */
21package org.jdtaus.core.text.util;
22 
23import java.util.Locale;
24import org.jdtaus.core.container.ContainerFactory;
25import org.jdtaus.core.logging.spi.Logger;
26import org.jdtaus.core.text.MessageEvent;
27import org.jdtaus.core.text.MessageListener;
28 
29/**
30 * {@code MessageListener} logging messages to a system logger.
31 *
32 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
33 * @version $JDTAUS: MessageLogger.java 8641 2012-09-27 06:45:17Z schulte $
34 *
35 * @see #onMessage(MessageEvent)
36 */
37public final class MessageLogger implements MessageListener
38{
39    //--MessageListener---------------------------------------------------------
40 
41    /**
42     * {@inheritDoc}
43     * <p>This method logs all messages given by the event using the
44     * corresponding log level.</p>
45     *
46     * @param event the event holding messages.
47     */
48    public void onMessage( final MessageEvent event )
49    {
50        if ( event != null )
51        {
52            for ( int i = 0; i < event.getMessages().length; i++ )
53            {
54                switch ( event.getType() )
55                {
56                    case MessageEvent.ERROR:
57                        this.getLogger().error( event.getMessages()[i].getText(
58                            this.getLocale() ) );
59 
60                        break;
61 
62                    case MessageEvent.INFORMATION:
63                    case MessageEvent.NOTIFICATION:
64                        this.getLogger().info( event.getMessages()[i].getText(
65                            this.getLocale() ) );
66 
67                        break;
68 
69                    case MessageEvent.WARNING:
70                        this.getLogger().warn( event.getMessages()[i].getText(
71                            this.getLocale() ) );
72 
73                        break;
74 
75                    default:
76                        this.getLogger().warn(
77                            this.getUnknownMessageEventTypeMessage(
78                            this.getLocale(),
79                            new Integer( event.getType() ) ) );
80 
81                }
82            }
83        }
84    }
85 
86    //---------------------------------------------------------MessageListener--
87    //--Dependencies------------------------------------------------------------
88 
89// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausDependencies
90    // This section is managed by jdtaus-container-mojo.
91 
92    /**
93     * Gets the configured <code>Logger</code> implementation.
94     *
95     * @return The configured <code>Logger</code> implementation.
96     */
97    private Logger getLogger()
98    {
99        return (Logger) ContainerFactory.getContainer().
100            getDependency( this, "Logger" );
101 
102    }
103 
104    /**
105     * Gets the configured <code>Locale</code> implementation.
106     *
107     * @return The configured <code>Locale</code> implementation.
108     */
109    private Locale getLocale()
110    {
111        return (Locale) ContainerFactory.getContainer().
112            getDependency( this, "Locale" );
113 
114    }
115 
116// </editor-fold>//GEN-END:jdtausDependencies
117 
118    //------------------------------------------------------------Dependencies--
119    //--Messages----------------------------------------------------------------
120 
121// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausMessages
122    // This section is managed by jdtaus-container-mojo.
123 
124    /**
125     * Gets the text of message <code>unknownMessageEventType</code>.
126     * <blockquote><pre>Meldung unbekannten Typs {0,number} ignoriert.</pre></blockquote>
127     * <blockquote><pre>Ignored message event of unknown type {0,number}.</pre></blockquote>
128     *
129     * @param locale The locale of the message instance to return.
130     * @param unknownEventType The unknown event type.
131     *
132     * @return Message stating that an unknown message event got ignored.
133     */
134    private String getUnknownMessageEventTypeMessage( final Locale locale,
135            final java.lang.Number unknownEventType )
136    {
137        return ContainerFactory.getContainer().
138            getMessage( this, "unknownMessageEventType", locale,
139                new Object[]
140                {
141                    unknownEventType
142                });
143 
144    }
145 
146// </editor-fold>//GEN-END:jdtausMessages
147 
148    //----------------------------------------------------------------Messages--
149}

[all classes][org.jdtaus.core.text.util]
EMMA 2.1.5320 (stable) (C) Vladimir Roubtsov