001package jmri.implementation;
002
003import jmri.Reporter;
004
005/**
006 * Abstract base for the Reporter interface.
007 * <p>
008 * Implements the parameter binding support.
009 * <p>
010 * Note that we consider it an error for there to be more than one object that
011 * corresponds to a particular physical Reporter on the layout.
012 *
013 * Abstract class providing the basic logic of the Reporter
014 * interface
015 *
016 * @author Bob Jacobsen Copyright (C) 2001
017 * @author Matthew Harris Copyright (C) 2011
018 */
019public abstract class AbstractReporter extends AbstractNamedBean implements Reporter {
020
021    public AbstractReporter(String systemName) {
022        super(systemName);
023    }
024
025    public AbstractReporter(String systemName, String userName) {
026        super(systemName, userName);
027    }
028
029    @Override
030    public String getBeanType() {
031        return Bundle.getMessage("BeanNameReporter");
032    }
033    
034    @Override
035    public Object getCurrentReport() {
036        return _currentReport;
037    }
038
039    @Override
040    public Object getLastReport() {
041        return _lastReport;
042    }
043
044    /**
045     * Provide a general method for updating the report.
046     */
047    @Override
048    public void setReport(Object r) {
049        if (r == _currentReport) {
050            return;
051        }
052        Object old = _currentReport;
053        Object oldLast = _lastReport;
054        _currentReport = r;
055        if (r != null) {
056            _lastReport = r;
057            // notify
058            firePropertyChange("lastReport", oldLast, _lastReport);
059        }
060        // notify
061        firePropertyChange("currentReport", old, _currentReport);
062    }
063
064    // internal data members
065    protected Object _lastReport = null;
066    protected Object _currentReport = null;
067
068}