Logo
Distributed Genetic Programming Framework
print print

File org.sfc.events.DefaultEventListener.java

Here you can find all the information about the file org.sfc.events.DefaultEventListener.java. You may explore it here or download it onto your local disk.
/*
 * Copyright (c) 2006 Thomas Weise
 *
 * E-Mail           : tweise@gmx.de
 * Creation Date    : 2006-02-28 06:04:51
 * Original Filename: org.sfc.events.DefaultEventListener.java
 * Version          : 3.0.0
 * Last modification: 2006-04-10
 *                by: Thomas Weise
 *
 * License          : GNU LESSER GENERAL PUBLIC LICENSE
 *                    Version 2.1, February 1999
 *                    You should have received a copy of this license along
 *                    with this library; if not, write to the Free Software
 *                    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *                    MA 02111-1307, USA or download the license under
 *                    http://www.gnu.org/copyleft/lesser.html.
 *
 * Warranty         : This software is provided "as is" without any
 *                    warranty; without even the implied warranty of
 *                    merchantability or fitness for a particular purpose.
 *                    See the Gnu Lesser General Public License for more
 *                    details.
 */


package org.sfc.events;

import org.sfc.text.Text;


/**
 * A basic event listener without no specialization.
 *
 * @author Thomas Weise
 */

public class DefaultEventListener extends EventOutput
  {

/**
 * The default sfc event handler.
 */

  public  static  final EventHandler<SfcEvent>  SFC_EVENT_HANDLER =
        new EventHandler<SfcEvent>()
    {
    @Override
    protected final void handle_event(final SfcEvent    p_event,
                                      final EventOutput p_output)
      {
      p_output.write("Something undefined: ");
      p_output.write_object(p_event);
      }
    };

/**
 * The default timed event handler.
 */

  public  static  final EventHandler<TimedEvent>  TIMED_EVENT_HANDLER =
        new EventHandler<TimedEvent>()
    {
    @Override
    protected final void handle_event(final TimedEvent  p_event,
                                      final EventOutput p_output)
      {
      p_output.write("Something happened at ");
      p_output.write_time(p_event.get_time(), false);
      p_output.write(": ");
      p_output.write_object(p_event);
      }
    };

/**
 * The error event handler.
 */

  public  static  final EventHandler<ErrorEvent>  ERROR_EVENT_HANDLER =
        new EventHandler<ErrorEvent>()
    {
    @Override
    protected final void handle_event(final ErrorEvent  p_event,
                                      final EventOutput p_output)
      {
      Object l_o;

      p_output.write("Error ");
      p_output.write_time(p_event.get_time(), false);
      p_output.write(": ");

      l_o = p_event.getSource();
      if(l_o != null)
        {
        p_output.write(l_o.toString());
        }
      p_output.write_linebreak();

      p_output.write(Text.error_to_string(p_event.get_error()));
      }
    };


/**
 * Create a new event output listener.
 * @param p_out             The output stream to write to.
 * @param p_default_indent  The default indentation step width.
 */

  public  DefaultEventListener(final Object p_out,
                               final int    p_default_indent)
    {
    super(p_out, p_default_indent);
    this.add_handler(SfcEvent.class,   SFC_EVENT_HANDLER);
    this.add_handler(TimedEvent.class, TIMED_EVENT_HANDLER);
    this.add_handler(ErrorEvent.class, ERROR_EVENT_HANDLER);
    }
  }

File Information:

file name:DefaultEventListener.java
package:org.sfc.events
qualified name:org.sfc.events.DefaultEventListener.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/sfc/events/DefaultEventListener.java
size:3.395 KB (3477 B)
uploaded: 2015-07-22 04:11:11 GMT+0000
last update: 2006-05-05 14:20:36 GMT+0000
last access: 2018-01-23 15:32:20 GMT+0000

statistics online since 2006-01-02.   RSS Feed
Contact us by sending an email to tweise@gmx.de to receive further information, to report errors, or to join our project.
All content on this site (http://dgpf.sourceforge.net/) is LGPL-licensed.
http://dgpf.sourceforge.net/scripts/source/source.php last modified at 2015-07-22 04:10:53 GMT+0000 served at 2018-01-23 15:32:20 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo