1 package net.sf.mmapps.modules.config.implementation;
2
3 import java.util.Properties;
4
5 import net.sf.mmapps.modules.config.FieldConfiguration;
6 /***
7 *
8 * @author Kees Jongenburger
9 * @version $Id: BasicFieldConfiguration.java,v 1.2 2004/05/18 13:53:51 keesj Exp $
10 */
11 public class BasicFieldConfiguration implements FieldConfiguration{
12 String name;
13 String type;
14 String size;
15 String guitype;
16 boolean isKey= false;
17 boolean isNotNull = false;
18 String state ="persistent";
19 String docType;
20 Properties guiNames = new Properties();
21 Properties descriptions = new Properties();
22
23 String editorPos ="1";
24 String searchPos ="1";
25 String listPos ="1";
26
27 protected BasicFieldConfiguration() {
28 }
29
30 public void setName(String name){
31 this.name = name;
32 }
33 public String getName(){
34 return name;
35 }
36
37 public void setType(String type){
38 this.type = type;
39 }
40
41 public void setSize(String size){
42 this.size = size;
43 }
44
45 public String getType(){
46 return type.toUpperCase();
47 }
48
49 public String getSize(){
50 if (size == null && type.equalsIgnoreCase("string")){
51 return "127";
52 }
53 return size;
54 }
55
56
57 public void setGUIType(String guitype) {
58 this.guitype = guitype;
59 }
60
61 public String getGUIType() {
62 return guitype;
63 }
64
65 public void setDocType(String docType){
66 this.docType = docType;
67 }
68 /*** @return the doctype of the field (only for xml types)
69 *
70 */
71 public String getDocType() {
72 return docType;
73 }
74
75 public void setGUIName(String lang,String value){
76 if (lang != null && value != null) {
77 guiNames.put(lang,value);
78 }
79 }
80
81
82 /*** @return a human readable fieldname
83 *
84 */
85 public String getGUIName(String lang) {
86 if (guiNames.get(lang) == null){
87 return getName();
88 }
89 return (String)guiNames.get(lang);
90 }
91
92 public void setState(String state){
93 this.state = state;
94 }
95 /*** @return the mmbase-state of the field
96 *
97 */
98 public String getState() {
99 return state;
100 }
101
102 public void setIsKey(boolean value){
103 isKey = value;
104 }
105 /*** @return the if the field is a key
106 *
107 */
108 public boolean isKey() {
109 return isKey;
110 }
111
112 public void setIsNotNull(boolean value){
113 isNotNull = value;
114 }
115 /*** @return the if the field may be null
116 *
117 */
118 public boolean isNotNull() {
119 return isNotNull;
120 }
121
122 public void setEditorPosition(String pos){
123 this.editorPos = pos;
124 }
125 public String getEditorPosition() {
126 return editorPos;
127 }
128
129 public void setListPosition(String pos){
130 this.listPos = pos;
131 }
132 public String getListPosition() {
133 return listPos;
134 }
135
136 public void setSearchPosition(String pos){
137 this.searchPos = pos;
138 }
139 public String getSearchPosition() {
140 return searchPos;
141 }
142
143 public Properties getGUINames() {
144 return guiNames;
145 }
146 public Properties getDescriptions(){
147 return descriptions;
148 }
149 public void setDescription(String lang,String description){
150 if (lang != null && description != null) {
151 descriptions.put(lang, description);
152 }
153 }
154
155 public String getDescription(String lang) {
156 if (descriptions.get(lang) == null){
157 return getName();
158 }
159 return (String)descriptions.get(lang);
160 }
161
162 }