KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > ipanema > accounting > ProductInfoFieldMetaData


1 /*
2  * Created on 17.10.2004
3  */

4 package com.nightlabs.ipanema.accounting;
5
6 import java.io.Serializable JavaDoc;
7
8 import com.nightlabs.inheritance.NotWritableException;
9
10 /**
11  * @author Marco Schulze - marco at nightlabs dot de
12  *
13  * @jdo.persistence-capable
14  * identity-type = "application"
15  * objectid-class = "com.nightlabs.ipanema.accounting.id.ProductInfoFieldMetaDataID"
16  * detachable = "true"
17  *
18  * @jdo.inheritance strategy = "new-table"
19  */

20 public class ProductInfoFieldMetaData
21     implements com.nightlabs.inheritance.FieldMetaData, Serializable JavaDoc
22 {
23     /**
24      * @jdo.field primary-key="true"
25      * @jdo.column length="100"
26      */

27     private String JavaDoc organisationID;
28
29     /**
30      * @jdo.field primary-key="true"
31      * @jdo.column length="100"
32      */

33     private String JavaDoc productID;
34
35     /**
36      * @jdo.field primary-key="true"
37      * @jdo.column length="100"
38      */

39     private String JavaDoc fieldName;
40
41     private ProductInfo productInfo;
42
43     /**
44      * Whether or not the field may be changed by children.
45      */

46     private byte writableByChildren = ProductInfoFieldMetaData.WRITABLEBYCHILDREN_YES;
47
48     /**
49      * writable is set to false if the mother has writableByChildren
50      * set to false.
51      */

52     private boolean writable = true;
53
54     /**
55      * If true, the value of the child is automatically updated if the
56      * mother's field is changed.
57      */

58     private boolean valueInherited = true;
59
60     protected ProductInfoFieldMetaData() { }
61     public ProductInfoFieldMetaData(ProductInfo productInfo, String JavaDoc fieldName)
62     {
63         setProductInfo(productInfo);
64         setFieldName(fieldName);
65     }
66
67     /**
68      * @return Returns the organisationID.
69      */

70     public String JavaDoc getOrganisationID()
71     {
72         return organisationID;
73     }
74
75     /**
76      * @return Returns the productID.
77      */

78     public String JavaDoc getProductID()
79     {
80         return productID;
81     }
82
83     /**
84      * @return Returns the fieldName.
85      */

86     public String JavaDoc getFieldName()
87     {
88         return fieldName;
89     }
90     /**
91      * @param fieldName The fieldName to set.
92      */

93     protected void setFieldName(String JavaDoc fieldName)
94     {
95         this.fieldName = fieldName;
96     }
97
98     /**
99      * @return Returns the productInfo.
100      */

101     public ProductInfo getProductInfo()
102     {
103         return productInfo;
104     }
105     /**
106      * @param product The productInfo to set.
107      */

108     protected void setProductInfo(ProductInfo productInfo)
109     {
110         if (productInfo == null)
111             throw new NullPointerException JavaDoc("productInfo must not be null!");
112         if (productInfo.getOrganisationID() == null)
113             throw new NullPointerException JavaDoc("productInfo.organisationID must not be null!");
114         if (productInfo.getProductID() == null)
115             throw new NullPointerException JavaDoc("productInfo.productID must not be null!");
116         this.organisationID = productInfo.getOrganisationID();
117         this.productID = productInfo.getProductID();
118         this.productInfo = productInfo;
119     }
120
121     /**
122      * @see com.nightlabs.inheritance.ProductInfoFieldMetaData#getWritableByChildren()
123      */

124     public byte getWritableByChildren()
125     {
126         return writableByChildren;
127     }
128     /**
129      * @see com.nightlabs.inheritance.ProductInfoFieldMetaData#setWritableByChildren(byte)
130      */

131     public void setWritableByChildren(byte writableByChildren)
132     {
133         this.writableByChildren = writableByChildren;
134     }
135
136     /**
137      * @return Returns the writable.
138      */

139     public boolean isWritable()
140     {
141         return writable;
142     }
143     /**
144      * @param writable The writable to set.
145      */

146     public void setWritable(boolean writable)
147     {
148         this.writable = writable;
149     }
150     /**
151      * @see com.nightlabs.inheritance.ProductInfoFieldMetaData#assertWritable()
152      */

153     public void assertWritable() throws NotWritableException
154     {
155         if (!isWritable())
156             throw new NotWritableException("Field \""+getFieldName()+"\" is not writeable!");
157     }
158
159     /**
160      * @return Returns the valueInherited.
161      */

162     public boolean isValueInherited()
163     {
164         return valueInherited;
165     }
166     /**
167      * @param valueInherited The valueInherited to set.
168      */

169     public void setValueInherited(boolean valueInherited)
170     {
171         if (!writable && !valueInherited)
172             throw new IllegalStateException JavaDoc("The field is not writable, thus the value must be inherited. Cannot set valueInherited to false!");
173
174         this.valueInherited = valueInherited;
175     }
176
177 }
178
Popular Tags