001 /*
002 Copyright (C) 2008 Richard Gomes
003
004 This source code is release under the BSD License.
005
006 This file is part of JQuantLib, a free-software/open-source library
007 for financial quantitative analysts and developers - http://jquantlib.org/
008
009 JQuantLib is free software: you can redistribute it and/or modify it
010 under the terms of the JQuantLib license. You should have received a
011 copy of the license along with this program; if not, please email
012 <jquant-devel@lists.sourceforge.net>. The license is also available online at
013 <http://www.jquantlib.org/index.php/LICENSE.TXT>.
014
015 This program is distributed in the hope that it will be useful, but WITHOUT
016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
017 FOR A PARTICULAR PURPOSE. See the license for more details.
018
019 JQuantLib is based on QuantLib. http://quantlib.org/
020 When applicable, the original copyright notice follows this notice.
021 */
022
023 /*
024 Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
025
026 This file is part of QuantLib, a free-software/open-source library
027 for financial quantitative analysts and developers - http://quantlib.org/
028
029 QuantLib is free software: you can redistribute it and/or modify it
030 under the terms of the QuantLib license. You should have received a
031 copy of the license along with this program; if not, please email
032 <quantlib-dev@lists.sf.net>. The license is also available online at
033 <http://quantlib.org/license.shtml>.
034
035 This program is distributed in the hope that it will be useful, but WITHOUT
036 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
037 FOR A PARTICULAR PURPOSE. See the license for more details.
038 */
039
040 package org.jquantlib.quotes;
041
042 import java.util.List; // FIXME :: performance
043
044 import org.jquantlib.math.FunctionDouble;
045 import org.jquantlib.util.DefaultObservable;
046 import org.jquantlib.util.Observable;
047 import org.jquantlib.util.Observer;
048
049 /**
050 * Purely virtual base class for market observables
051 *
052 * @author Richard Gomes
053 */
054 // FIXME: understand how this class is used
055 public abstract class Quote implements FunctionDouble, Observable {
056
057 //
058 // implements Observable interface
059 //
060
061 /**
062 * Implements multiple inheritance via delegate pattern to an inner class
063 *
064 * @see Observable
065 * @see DefaultObservable
066 */
067 private Observable delegatedObservable = new DefaultObservable(this);
068
069 public void addObserver(Observer observer) {
070 delegatedObservable.addObserver(observer);
071 }
072
073 public int countObservers() {
074 return delegatedObservable.countObservers();
075 }
076
077 public void deleteObserver(Observer observer) {
078 delegatedObservable.deleteObserver(observer);
079 }
080
081 public void notifyObservers() {
082 delegatedObservable.notifyObservers();
083 }
084
085 public void notifyObservers(Object arg) {
086 delegatedObservable.notifyObservers(arg);
087 }
088
089 public void deleteObservers() {
090 delegatedObservable.deleteObservers();
091 }
092
093 public List<Observer> getObservers() {
094 return delegatedObservable.getObservers();
095 }
096
097 }