package fauxExchange; import java.util.*; // A segment represents a particular market segment for an exchange //Note to Self: JDK's observer/observable classes leave much to be //desired....(at least JDK 1.1 API style) class Segment extends Observable { //--[ MemberData ]---------------------- private Exchange exch; //To what exchange do I belong? private State state; //What is my CurrentState? private int segmentID; //UIN for a segment //*************************************************************// //--[ Constructors ]-------------------- //the segment always gets created with a "null" state... //explicit calls to gotoBreak() or gotoTrading() will change that public Segment(Exchange e, int id){ this.exch = e; this.segmentID = id; //Add the OSC to the list of observers for myself // this.addObserver(this.osc); } //*************************************************************// //--[ MemberMethods ]------------------- //public void registerMarketTimes(int startHour, int startMinute, int closeHour, int closeMinute){ //Calendar c1 = new java.util.Calendar.getInstance(); //Calendar c2 = new java.util.Calendar.getInstance(); //c1.set(c1.YEAR, c1.MONTH, c1.DATE, startHour, startMinute); //c2.set(c2.YEAR, c2.MONTH, c2.DATE, startHour, startMinute); //MarketTime mt = new MarketTime(c1, c2); //this.getExchange(). // //} public void setExchange(Exchange e){ this.exch = e; } public void setState(State s){ this.state = s; this.notifyObservers(this.state); } public Exchange getExchange(){ return this.exch; } //Do I really need this...maybe?!? public State getState() { return this.state; } //We need to notify the orderBook if our state changes //goto continouusTrading state public void gotoTrading(){ this.state = new TradingState(); this.notifyObservers(this.state); } //goto BreakState public void gotoBreak(){ this.state = new BreakState(); this.notifyObservers(this.state); } public void setSegmentId(int id){ this.segmentID = id; } //*************************************************************// } //end class