001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.stocks.model;
022:
023: import java.io.Serializable;
024:
025: /**
026: * <a href="Stocks.java.html"><b><i>View Source</i></b></a>
027: *
028: * @author Brian Wing Shun Chan
029: *
030: */
031: public class Stocks implements Serializable {
032:
033: public Stocks(String symbol, double lastTrade, double change,
034: double open, double dayHigh, double dayLow, long volume) {
035: _symbol = symbol;
036: _lastTrade = lastTrade;
037: _change = change;
038: _open = open;
039: _dayHigh = dayHigh;
040: _dayLow = dayLow;
041: _volume = volume;
042: }
043:
044: public String getSymbol() {
045: return _symbol;
046: }
047:
048: public double getLastTrade() {
049: return _lastTrade;
050: }
051:
052: public void setLastTrade(double lastTrade) {
053: _lastTrade = lastTrade;
054: }
055:
056: public boolean isLastTradeAvailable() {
057: return _lastTradeAvailable;
058: }
059:
060: public void setLastTradeAvailable(boolean lastTradeAvailable) {
061: _lastTradeAvailable = lastTradeAvailable;
062: }
063:
064: public double getChange() {
065: return _change;
066: }
067:
068: public void setChange(double change) {
069: _change = change;
070: }
071:
072: public boolean isChangeAvailable() {
073: return _changeAvailable;
074: }
075:
076: public void setChangeAvailable(boolean changeAvailable) {
077: _changeAvailable = changeAvailable;
078: }
079:
080: public double getPreviousClose() {
081: return _lastTrade - _change;
082: }
083:
084: public boolean isPreviousCloseAvailable() {
085: if (isLastTradeAvailable() && isChangeAvailable()) {
086: return true;
087: } else {
088: return false;
089: }
090: }
091:
092: public double getOpen() {
093: return _open;
094: }
095:
096: public void setOpen(double open) {
097: _open = open;
098: }
099:
100: public boolean isOpenAvailable() {
101: return _openAvailable;
102: }
103:
104: public void setOpenAvailable(boolean openAvailable) {
105: _openAvailable = openAvailable;
106: }
107:
108: public double getDayHigh() {
109: return _dayHigh;
110: }
111:
112: public void setDayHigh(double dayHigh) {
113: _dayHigh = dayHigh;
114: }
115:
116: public boolean isDayHighAvailable() {
117: return _dayHighAvailable;
118: }
119:
120: public void setDayHighAvailable(boolean dayHighAvailable) {
121: _dayHighAvailable = dayHighAvailable;
122: }
123:
124: public double getDayLow() {
125: return _dayLow;
126: }
127:
128: public void setDayLow(double dayLow) {
129: _dayLow = dayLow;
130: }
131:
132: public boolean isDayLowAvailable() {
133: return _dayLowAvailable;
134: }
135:
136: public void setDayLowAvailable(boolean dayLowAvailable) {
137: _dayLowAvailable = dayLowAvailable;
138: }
139:
140: public long getVolume() {
141: return _volume;
142: }
143:
144: public void setVolume(long volume) {
145: _volume = volume;
146: }
147:
148: public boolean isVolumeAvailable() {
149: return _volumeAvailable;
150: }
151:
152: public void setVolumeAvailable(boolean volumeAvailable) {
153: _volumeAvailable = volumeAvailable;
154: }
155:
156: public boolean isValid() {
157: if (!_changeAvailable && !_openAvailable && !_dayHighAvailable
158: && !_dayLowAvailable && !_volumeAvailable) {
159:
160: return false;
161: } else {
162: return true;
163: }
164: }
165:
166: private String _symbol;
167: private double _lastTrade;
168: private boolean _lastTradeAvailable = true;
169: private double _change;
170: private boolean _changeAvailable = true;
171: private double _open;
172: private boolean _openAvailable = true;
173: private double _dayHigh;
174: private boolean _dayHighAvailable = true;
175: private double _dayLow;
176: private boolean _dayLowAvailable = true;
177: private long _volume;
178: private boolean _volumeAvailable = true;
179:
180: }
|