001: /*--
002:
003: Copyright (C) 2002-2005 Adrian Price.
004: All rights reserved.
005:
006: Redistribution and use in source and binary forms, with or without
007: modification, are permitted provided that the following conditions
008: are met:
009:
010: 1. Redistributions of source code must retain the above copyright
011: notice, this list of conditions, and the following disclaimer.
012:
013: 2. Redistributions in binary form must reproduce the above copyright
014: notice, this list of conditions, and the disclaimer that follows
015: these conditions in the documentation and/or other materials
016: provided with the distribution.
017:
018: 3. The names "OBE" and "Open Business Engine" must not be used to
019: endorse or promote products derived from this software without prior
020: written permission. For written permission, please contact
021: adrianprice@sourceforge.net.
022:
023: 4. Products derived from this software may not be called "OBE" or
024: "Open Business Engine", nor may "OBE" or "Open Business Engine"
025: appear in their name, without prior written permission from
026: Adrian Price (adrianprice@users.sourceforge.net).
027:
028: THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
029: WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
030: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
031: DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
032: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
033: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
034: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
035: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
036: STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
037: IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
038: POSSIBILITY OF SUCH DAMAGE.
039:
040: For more information on OBE, please see
041: <http://obe.sourceforge.net/>.
042:
043: */
044:
045: package org.obe.xpdl.model.data;
046:
047: import org.obe.xpdl.PackageVisitor;
048: import org.obe.xpdl.model.misc.AbstractWFElement;
049:
050: /**
051: * The DataField class represents a data field which is placed in the workflow
052: * relevant data when a workflow process executes.
053: *
054: * @author Adrian Price
055: */
056: public final class DataField extends AbstractWFElement {
057: private static final long serialVersionUID = 8312139864854170366L;
058:
059: private DataType _dataType;
060: private String _initialValue;
061: private int _length;
062: private boolean _array;
063:
064: public DataField() {
065: }
066:
067: public DataField(String id, String name) {
068: super (id, name);
069: }
070:
071: /**
072: * Construct a new DataField.
073: *
074: * @param id The data field id
075: * @param name The data field name
076: * @param dataType The data type
077: */
078: public DataField(String id, String name, DataType dataType) {
079: super (id, name);
080: setDataType(dataType);
081: }
082:
083: public void accept(PackageVisitor visitor) {
084: visitor.visit(this );
085: }
086:
087: /**
088: * Get the field's data type.
089: *
090: * @return The DataType
091: */
092:
093: public DataType getDataType() {
094: return _dataType;
095: }
096:
097: /**
098: * Set the field's data type. The data type must not be null.
099: *
100: * @param dataType The data type
101: */
102:
103: public void setDataType(DataType dataType) {
104: if (dataType == null)
105: throw new IllegalArgumentException(
106: "Data type cannot be null");
107: _dataType = dataType;
108: }
109:
110: /**
111: * Get the field's initial value.
112: *
113: * @return The initial value
114: */
115:
116: public String getInitialValue() {
117: return _initialValue;
118: }
119:
120: /**
121: * Set the field's initial value.
122: *
123: * @param initialValue The new initial value
124: */
125: public void setInitialValue(String initialValue) {
126: _initialValue = initialValue;
127: }
128:
129: /**
130: * Get the length of the data field if the field represents an array or
131: * list. If the field is a single value then this method should return 0.
132: *
133: * @return The field's length for arrays or 0
134: */
135: public int getLength() {
136: return _length;
137: }
138:
139: /**
140: * Set the length of the data field.
141: *
142: * @param length The length
143: */
144: public void setLength(int length) {
145: _length = length;
146: }
147:
148: /**
149: * Return true if the data field is an array.
150: *
151: * @return True if the data field is an array
152: */
153: public boolean isArray() {
154: return _array;
155: }
156:
157: /**
158: * Set the flag indicating that the field is an array.
159: *
160: * @param array True to indicate that the field is an array
161: */
162: public void setArray(boolean array) {
163: _array = array;
164: }
165:
166: public String toString() {
167: return "DataField[id=" + getId() + ", name=" + getName()
168: + ", isArray=" + _array + ", dataType=" + _dataType
169: + ", initialValue=" + _initialValue + ", length="
170: + _length + ", description=" + getDescription()
171: + ", extendedAttributes=" + getExtendedAttributes()
172: + ']';
173: }
174: }
|