KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > ipanema > person > SelectionPersonDataField


1 /*
2  * Created on Nov 24, 2004
3  * by alex
4  *
5  */

6 package com.nightlabs.ipanema.person;
7
8 /**
9  * Holds one member of type {@link com.nightlabs.ipanema.person.PersonStructFieldValue}
10  * defining the users choice from the list within {@link com.nightlabs.ipanema.person.SelectionPersonStructField}.
11  *
12  * @author Alexander Bieber <alex[AT]nightlabs[DOT]de>
13  */

14 /**
15  * @jdo.persistence-capable
16  * identity-type = "application"
17  * persistence-capable-superclass="com.nightlabs.ipanema.person.AbstractPersonDataField"
18  * detachable = "true"
19  *
20  * @jdo.inheritance strategy = "new-table"
21  */

22 public class SelectionPersonDataField extends AbstractPersonDataField {
23     
24     
25     /**
26      *
27      */

28     public SelectionPersonDataField() {
29         super();
30     }
31     /**
32      * @param _personDataBlock
33      * @param _personStructField
34      */

35     public SelectionPersonDataField(PersonDataBlock _personDataBlock,
36             AbstractPersonStructField _personStructField) {
37         super(_personDataBlock, _personStructField);
38     }
39     /**
40      * @jdo.field persistence-modifier="persistent"
41      */

42     protected PersonStructFieldValue selection = null;
43     
44     public void setSelection(PersonStructFieldValue value) {
45         selection = value;
46     }
47     
48     public PersonStructFieldValue getSelection() {
49         return selection;
50     }
51     
52     /**
53      * Casts {@link AbstractPersonDataField#getPersonStructField()} as
54      * {@link SelectionPersonStructField}
55      * @throws ClassCastException If class cast fails
56      * @return Associated struct field as {@link SelectionPersonStructField}
57      */

58     public SelectionPersonStructField getSelectionStructField(PersonStruct structure)
59     throws ClassCastException JavaDoc
60     {
61         IllegalStateException JavaDoc ill = null;
62         AbstractPersonStructField field = null;
63         try {
64             field = structure.getPersonStructField(
65                 getPersonStructBlockOrganisationID(),
66                 getPersonStructBlockID(),
67                 getPersonStructFieldOrganisationID(),
68                 getPersonStructFieldID()
69             );
70         } catch (Exception JavaDoc e) {
71             ill = new IllegalStateException JavaDoc("Caught exception while accessing PersonStructFactory");
72             ill.initCause(e);
73         }
74         if (ill != null)
75             throw ill;
76         return (SelectionPersonStructField)field;
77     }
78     /**
79      * @see com.nightlabs.ipanema.person.AbstractPersonDataField#isEmpty()
80      */

81     public boolean isEmpty() {
82         return getSelection() == null;
83     }
84     /**
85      * @see com.nightlabs.ipanema.person.AbstractPersonDataField#localizedToString(java.lang.String)
86      */

87     public String JavaDoc localizedToString(String JavaDoc languageID) {
88         return getSelection().getValueName().getText(languageID);
89     }
90
91 }
92
Popular Tags