Source Code Cross Referenced for SchemaColNode.java in  » Portal » Open-Portal » soif » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » soif 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *	CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
003:         *	NETSCAPE COMMUNICATIONS CORPORATION
004:         *
005:         *	Copyright (c) 1996 Netscape Communications Corporation.
006:         *	All Rights Reserved.
007:         *	Use of this Source Code is subject to the terms of the applicable
008:         *	license agreement from Netscape Communications Corporation.
009:         */
010:
011:        package soif;
012:
013:        // SGP: changes to SOIF-Attribute ought to (for now) be applied to
014:        // Column-Name and System-Column-Name.
015:        // SGP: consider disallowing removal of some key attributes (e.g.,
016:        // SOIF-Attribute).
017:
018:        import util.ReportError;
019:
020:        /**
021:         Encapsulates data for a schema column.
022:         *
023:         */
024:        public class SchemaColNode {
025:            /**
026:             * Indicates that the data has been picked for display.
027:             */
028:            protected int display;
029:            /**
030:             * Indicates that the data has been picked as sort criteria.
031:             */
032:            protected int sort;
033:            /**
034:             * Indicates that the data has been picked as editable.
035:             */
036:            protected int editable;
037:            /**
038:             * Indicates that the data has been picked as indexable.
039:             */
040:            protected int indexable;
041:            /**
042:             * SOIF attribute name.
043:             */
044:            protected String soifAttribute;
045:            /**
046:             * System table name.
047:             */
048:            protected String sysTblName;
049:
050:            private String label;
051:            private AVPairs list;
052:
053:            /**
054:             * Default non-value for display, sort and editable.
055:             */
056:            protected static final int ZIPPO = -1;
057:
058:            /*--------------*/
059:            /* constructors */
060:            /*--------------*/
061:
062:            /**
063:             * Constructor.
064:             * @param list list of attribute value pairs describing this column
065:             */
066:            public SchemaColNode(AVPairs list) {
067:                this .list = list;
068:
069:                String stmp;
070:
071:                stmp = list.getValue("Edit-Attribute");
072:                editable = (stmp == null) ? ZIPPO : Integer.parseInt(stmp);
073:                stmp = list.getValue("Index-Attribute");
074:                indexable = (stmp == null) ? ZIPPO : Integer.parseInt(stmp);
075:
076:                label = list.getValue("soif-attribute");
077:                soifAttribute = list.getValue("soif-attribute");
078:                sysTblName = list.getValue("system-table-name");
079:
080:                setDefaultDisplay();
081:                setDefaultSort();
082:
083:                if (soifAttribute == null) {
084:                    ReportError.reportError(ReportError.ADMIN, "SchemaColNode",
085:                            "SchemaColNode", Messages.MISSINGSOIFATTRIBUTE);
086:                    System.out.println(toString());
087:                }
088:            }
089:
090:            /**
091:             * Get the label.
092:             */
093:            public String getLabel() {
094:                return label;
095:            }
096:
097:            /**
098:             * Get value by attribute.
099:             * Ignores case of attribute name.
100:             * @param s the attribute
101:             */
102:            public String getValue(String s) {
103:                return list.getValue(s);
104:            }
105:
106:            /**
107:             * Set value by attribute.
108:             * Ignores case of attribute name.
109:             * @param s the attribute
110:             * @param v the value
111:             */
112:            public boolean setValue(String s, String v) {
113:                if ("Default-View-Attribute".equalsIgnoreCase(s) == true) {
114:                    setDefaultDisplay();
115:                }
116:                if ("Default-View-Order".equalsIgnoreCase(s) == true) {
117:                    setDefaultSort();
118:                }
119:                if ("SOIF-Attribute".equalsIgnoreCase(s) == true) {
120:                    label = v;
121:                }
122:
123:                return list.setValue(s, v);
124:            }
125:
126:            /**
127:             * Inserts a new AVPairs instance.
128:             * The inserter of duplicates (particular of
129:             * key attributes) is assumed to know what they're doing.
130:             * @param att the attribute
131:             * @param val the value
132:             */
133:            public void insert(String att, String val) {
134:                if (list == null) {
135:                    list = new AVPairs(att, val);
136:                } else {
137:                    list.insertAfter(new AVPairs(att, val));
138:                }
139:
140:                if ("Default-View-Attribute".equalsIgnoreCase(att) == true) {
141:                    setDefaultDisplay();
142:                }
143:                if ("Default-View-Order".equalsIgnoreCase(att) == true) {
144:                    setDefaultSort();
145:                }
146:                if ("SOIF-Attribute".equalsIgnoreCase(att) == true) {
147:                    label = val;
148:                }
149:            }
150:
151:            /**
152:             * Remove AVPair by attribute.
153:             * Ignores case of attribute name.
154:             * @param s the attribute
155:             */
156:            public void remove(String s) {
157:                list = list.remove(list.getAVPair(s));
158:                if ("Default-View-Attribute".equalsIgnoreCase(s) == true) {
159:                    setDefaultDisplay();
160:                }
161:                if ("Default-View-Order".equalsIgnoreCase(s) == true) {
162:                    setDefaultSort();
163:                }
164:                if ("SOIF-Attribute".equalsIgnoreCase(s) == true) {
165:                    label = null;
166:                }
167:            }
168:
169:            /**
170:             * A convenience method which bundles insert(),
171:             * setValue() and remove().
172:             * If the proposed value is length 0, remove() is called.
173:             * Otherwise, setValue() is called.
174:             * If setValue() fails, insertAfter() is called.
175:             * @param att attribute
176:             * @param val value
177:             */
178:            public void update(String att, String val) {
179:                list.update(att, val);
180:
181:                if ("Default-View-Attribute".equalsIgnoreCase(att) == true) {
182:                    setDefaultDisplay();
183:                }
184:                if ("Default-View-Order".equalsIgnoreCase(att) == true) {
185:                    setDefaultSort();
186:                }
187:                if ("SOIF-Attribute".equalsIgnoreCase(att) == true) {
188:                    label = val;
189:                }
190:            }
191:
192:            /**
193:             * Convenience method for handling Enforce-Uniqueness.
194:             * @param s enforce-uniqueness value
195:             */
196:            public void setEnforceUniqueness(boolean b) {
197:                if (!b) {
198:                    remove("Enforce-Uniqueness");
199:                } else {
200:                    if (getValue("Enforce-Uniqueness") == null) {
201:                        insert("Enforce-Uniqueness", "1");
202:                    }
203:                }
204:            }
205:
206:            // SGP: more like enforce-uniqueness now, consider cloning that
207:            /**
208:             * Convenience method for handling Edit-Attribute.
209:             * If the value is null a removal is performed.
210:             * @param s edit-attribute value
211:             */
212:            public void setEditAttribute(String s) {
213:                if (s == null) {
214:                    remove("Edit-Attribute");
215:                } else {
216:                    try {
217:                        editable = Integer.parseInt(s);
218:                    } catch (NumberFormatException e) {
219:                        remove("Edit-Attribute");
220:                        indexable = ZIPPO;
221:                        return;
222:                    }
223:                    if (!(setValue("Edit-Attribute", s))) {
224:                        insert("Edit-Attribute", s);
225:                    }
226:                }
227:            }
228:
229:            // SGP: more like enforce-uniqueness now, consider cloning that
230:            /**
231:             * Convenience method for handling Index-Attribute.
232:             * If the value is null a removal is performed.
233:             * @param s index-attribute value
234:             */
235:            public void setIndexAttribute(String s) {
236:                if (s == null) {
237:                    remove("Index-Attribute");
238:                } else {
239:                    int i = 0;
240:                    try {
241:                        indexable = Integer.parseInt(s);
242:                    } catch (NumberFormatException e) {
243:                        remove("Index-Attribute");
244:                        indexable = ZIPPO;
245:                        return;
246:                    }
247:                    if (!(setValue("Index-Attribute", s))) {
248:                        insert("Index-Attribute", s);
249:                    }
250:                }
251:            }
252:
253:            /**
254:             * Set the default display value.
255:             */
256:            public void setDefaultDisplay() {
257:                String s = list.getValue("Default-View-Attribute");
258:
259:                if (s == null) {
260:                    display = ZIPPO;
261:                } else {
262:                    try {
263:                        display = Integer.parseInt(s);
264:                    } catch (NumberFormatException e) {
265:                        display = ZIPPO;
266:                    }
267:                }
268:            }
269:
270:            /**
271:             * Set the default display value.
272:             */
273:            public void setDefaultSort() {
274:                String s = list.getValue("Default-View-Order");
275:
276:                if (s == null) {
277:                    sort = ZIPPO;
278:                } else {
279:                    try {
280:                        sort = Integer.parseInt(s);
281:                    } catch (NumberFormatException e) {
282:                        sort = ZIPPO;
283:                    }
284:                }
285:            }
286:
287:            /**
288:             * Return SOIF.
289:             */
290:            public String toSOIF() {
291:                return list.toSOIFList();
292:            }
293:
294:            /**
295:             * Return SOIF w/ proposed multi-value.
296:             * @param mv multi-value
297:             */
298:            public String toSOIF(int mv) {
299:                return list.toSOIFList(mv);
300:            }
301:
302:            public String toString() {
303:                return "SchemaColNode instance: (" + Header.VERSION + ")\n"
304:                        + "\tsoifAttribute	= [" + soifAttribute + "]\n"
305:                        + "\tdisplay	= [" + display + "]\n" + "\tsort	= ["
306:                        + sort + "]\n" + "\teditable	= [" + editable + "]\n"
307:                        + "\tindexable	= [" + indexable + "]\n" + "\tlabel	= ["
308:                        + label + "]\n" + "\tlist		= ["
309:                        + ((list == null) ? "null" : "not null") + "]\n"
310:                        + list.toStringList();
311:            }
312:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.