001: /*
002: The contents of this file are subject to the Common Public Attribution License
003: Version 1.0 (the "License"); you may not use this file except in compliance with
004: the License. You may obtain a copy of the License at
005: http://www.projity.com/license . The License is based on the Mozilla Public
006: License Version 1.1 but Sections 14 and 15 have been added to cover use of
007: software over a computer network and provide for limited attribution for the
008: Original Developer. In addition, Exhibit A has been modified to be consistent
009: with Exhibit B.
010:
011: Software distributed under the License is distributed on an "AS IS" basis,
012: WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the
013: specific language governing rights and limitations under the License. The
014: Original Code is OpenProj. The Original Developer is the Initial Developer and
015: is Projity, Inc. All portions of the code written by Projity are Copyright (c)
016: 2006, 2007. All Rights Reserved. Contributors Projity, Inc.
017:
018: Alternatively, the contents of this file may be used under the terms of the
019: Projity End-User License Agreeement (the Projity License), in which case the
020: provisions of the Projity License are applicable instead of those above. If you
021: wish to allow use of your version of this file only under the terms of the
022: Projity License and not to allow others to use your version of this file under
023: the CPAL, indicate your decision by deleting the provisions above and replace
024: them with the notice and other provisions required by the Projity License. If
025: you do not delete the provisions above, a recipient may use your version of this
026: file under either the CPAL or the Projity License.
027:
028: [NOTE: The text of this license may differ slightly from the text of the notices
029: in Exhibits A and B of the license at http://www.projity.com/license. You should
030: use the latest text at http://www.projity.com/license for your modifications.
031: You may not remove this license text from the source files.]
032:
033: Attribution Information: Attribution Copyright Notice: Copyright � 2006, 2007
034: Projity, Inc. Attribution Phrase (not exceeding 10 words): Powered by OpenProj,
035: an open source solution from Projity. Attribution URL: http://www.projity.com
036: Graphic Image as provided in the Covered Code as file: openproj_logo.png with
037: alternatives listed on http://www.projity.com/logo
038:
039: Display of Attribution Information is required in Larger Works which are defined
040: in the CPAL as a work which combines Covered Code or portions thereof with code
041: not governed by the terms of the CPAL. However, in addition to the other notice
042: obligations, all copies of the Covered Code in Executable and Source Code form
043: distributed must, as a form of attribution of the original author, include on
044: each user interface screen the "OpenProj" logo visible to all users. The
045: OpenProj logo should be located horizontally aligned with the menu bar and left
046: justified on the top left of the screen adjacent to the File menu. The logo
047: must be at least 100 x 25 pixels. When users click on the "OpenProj" logo it
048: must direct them back to http://www.projity.com.
049: */
050: package com.projity.field;
051:
052: import java.io.IOException;
053: import java.io.ObjectInputStream;
054: import java.io.ObjectOutputStream;
055: import java.io.Serializable;
056:
057: /**
058: * Custom fields and their bounds. The bounds are set from config file by corresponding fields
059: */
060: public class CustomFieldsImpl implements CustomFields, Serializable,
061: Cloneable {
062: public static int NUM_COST = 0;
063: public static int NUM_DATE = 0;
064: public static int NUM_DURATION = 0;
065: public static int NUM_FINISH = 0;
066: public static int NUM_FLAG = 0;
067: public static int NUM_NUMBER = 0;
068: public static int NUM_START = 0;
069: public static int NUM_TEXT = 0;
070:
071: protected double cost[];
072: protected long date[];
073: protected long duration[];
074: protected long finish[];
075: protected boolean flag[];
076: protected double number[];
077: protected long start[];
078: protected String text[];
079:
080: public void serialize(ObjectOutputStream s) throws IOException {
081: s.writeObject(cost);
082: s.writeObject(date);
083: s.writeObject(duration);
084: s.writeObject(finish);
085: s.writeObject(flag);
086: s.writeObject(number);
087: s.writeObject(start);
088: s.writeObject(text);
089: }
090:
091: //call init to complete initialization
092: public static CustomFieldsImpl deserialize(ObjectInputStream s)
093: throws IOException, ClassNotFoundException {
094: CustomFieldsImpl c = new CustomFieldsImpl();
095: c.cost = (double[]) s.readObject();
096: c.date = (long[]) s.readObject();
097: c.duration = (long[]) s.readObject();
098: c.finish = (long[]) s.readObject();
099: c.flag = (boolean[]) s.readObject();
100: c.number = (double[]) s.readObject();
101: c.start = (long[]) s.readObject();
102: c.text = (String[]) s.readObject();
103: return c;
104: }
105:
106: public Object clone() {
107: CustomFieldsImpl cf = new CustomFieldsImpl();
108:
109: if (cost == null)
110: cf.cost = null;
111: else {
112: cf.cost = new double[cost.length];
113: System.arraycopy(cost, 0, cf.cost, 0, cost.length);
114: }
115: if (date == null)
116: cf.date = null;
117: else {
118: cf.date = new long[date.length];
119: System.arraycopy(date, 0, cf.date, 0, date.length);
120: }
121: if (duration == null)
122: cf.duration = null;
123: else {
124: cf.duration = new long[duration.length];
125: System.arraycopy(duration, 0, cf.duration, 0,
126: duration.length);
127: }
128: if (finish == null)
129: cf.finish = null;
130: else {
131: cf.finish = new long[finish.length];
132: System.arraycopy(finish, 0, cf.finish, 0, finish.length);
133: }
134: if (flag == null)
135: cf.flag = null;
136: else {
137: cf.flag = new boolean[flag.length];
138: System.arraycopy(flag, 0, cf.flag, 0, flag.length);
139: }
140: if (number == null)
141: cf.number = null;
142: else {
143: cf.number = new double[number.length];
144: System.arraycopy(number, 0, cf.number, 0, number.length);
145: }
146: if (start == null)
147: cf.start = null;
148: else {
149: cf.start = new long[start.length];
150: System.arraycopy(start, 0, cf.start, 0, start.length);
151: }
152: if (text == null)
153: cf.text = null;
154: else {
155: cf.text = new String[text.length];
156: for (int i = 0; i < text.length; i++)
157: cf.text[i] = text[i] == null ? null : new String(
158: text[i]);
159: }
160: return cf;
161: }
162:
163: public CustomFieldsImpl() {
164: }
165:
166: public double getCustomCost(int i) {
167: if (cost == null)
168: return 0.0;
169: return cost[i];
170: }
171:
172: public void setCustomCost(int i, double cost) {
173: if (this .cost == null)
174: this .cost = new double[NUM_COST];
175: this .cost[i] = cost;
176: }
177:
178: public long getCustomDate(int i) {
179: if (date == null)
180: return 0;
181: return date[i];
182: }
183:
184: public void setCustomDate(int i, long date) {
185: if (this .date == null)
186: this .date = new long[NUM_DATE];
187: this .date[i] = date;
188: }
189:
190: public long getCustomDuration(int i) {
191: if (duration == null)
192: return 0;
193: return duration[i];
194: }
195:
196: public void setCustomDuration(int i, long duration) {
197: if (this .duration == null)
198: this .duration = new long[NUM_DATE];
199: this .duration[i] = duration;
200: }
201:
202: public long getCustomFinish(int i) {
203: if (finish == null)
204: return 0;
205: return finish[i];
206: }
207:
208: public void setCustomFinish(int i, long finish) {
209: if (this .finish == null)
210: this .finish = new long[NUM_FINISH];
211: this .finish[i] = finish;
212: }
213:
214: public boolean getCustomFlag(int i) {
215: if (flag == null)
216: return false;
217: return flag[i];
218: }
219:
220: public void setCustomFlag(int i, boolean flag) {
221: if (this .flag == null)
222: this .flag = new boolean[NUM_FLAG];
223: this .flag[i] = flag;
224: }
225:
226: public double getCustomNumber(int i) {
227: if (number == null)
228: return 0.0D;
229: return number[i];
230: }
231:
232: public void setCustomNumber(int i, double number) {
233: if (this .number == null)
234: this .number = new double[NUM_NUMBER];
235: this .number[i] = number;
236: }
237:
238: public long getCustomStart(int i) {
239: if (start == null)
240: return 0;
241: return start[i];
242: }
243:
244: public void setCustomStart(int i, long start) {
245: if (this .start == null)
246: this .start = new long[NUM_START];
247: this .start[i] = start;
248: }
249:
250: public String getCustomText(int i) {
251: if (text == null)
252: return null;
253: return text[i];
254: }
255:
256: public void setCustomText(int i, String text) {
257: if (this .text == null)
258: this .text = new String[NUM_TEXT];
259: this.text[i] = text;
260: }
261:
262: }
|