Source Code Cross Referenced for BaseConverter.java in  » Web-Framework » aranea-mvc-1.1.1 » org » araneaframework » uilib » form » converter » 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 » Web Framework » aranea mvc 1.1.1 » org.araneaframework.uilib.form.converter 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright 2006 Webmedia Group Ltd.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *  http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         **/package org.araneaframework.uilib.form.converter;
016:
017:        import java.util.Set;
018:        import org.araneaframework.Environment;
019:        import org.araneaframework.core.Assert;
020:        import org.araneaframework.uilib.form.Converter;
021:        import org.araneaframework.uilib.form.FormElementContext;
022:
023:        /**
024:         * This class is the base class for form converters. The converters' task is to convert the value
025:         * of form {@link org.araneaframework.uilib.form.Control} to the value of {@link org.araneaframework.uilib.form.FormElement} 
026:         * {@link org.araneaframework.uilib.form.Data} and back.
027:         * 
028:         * @author Jevgeni Kabanov (ekabanov <i>at</i> araneaframework <i>dot</i> org)
029:         */
030:        public abstract class BaseConverter implements  java.io.Serializable,
031:                Converter {
032:
033:            private FormElementContext feCtx;
034:
035:            //*********************************************************************
036:            //* PUBLIC METHODS
037:            //*********************************************************************
038:
039:            /**
040:             * This method converts the data from one type to another. If the data is <code>null</code>
041:             * then <code>null</code> is returned. Otherwise {@link #convertNotNull(Object)}method is used
042:             * for actual conversion.
043:             * 
044:             * @param data Data to convert.
045:             * @return Converted data.
046:             */
047:            public Object convert(Object data) {
048:                Assert
049:                        .notNull(
050:                                this ,
051:                                getFormElementCtx(),
052:                                "Form element context must be assigned to the converter before it can function! "
053:                                        + "Make sure that the converter is associated with a form element!");
054:
055:                if (data == null)
056:                    return null;
057:
058:                return convertNotNull(data);
059:            }
060:
061:            /**
062:             * This method converts the data from one type to another (though the types are exchanged in
063:             * comparison with {@link #convert(Object)}). If the data is <code>null</code> then <code>null</code>
064:             * is returned. Otherwise {@link #reverseConvertNotNull(Object)}method is used for actual
065:             * conversion.
066:             * 
067:             * @param data Data to convert.
068:             * @return Converted data.
069:             */
070:            public Object reverseConvert(Object data) {
071:                Assert
072:                        .notNull(
073:                                this ,
074:                                getFormElementCtx(),
075:                                "Form element context must be assigned to the converter before it can function! "
076:                                        + "Make sure that the converter is associated with a form element!");
077:
078:                if (data == null)
079:                    return null;
080:
081:                return reverseConvertNotNull(data);
082:            }
083:
084:            public void setFormElementCtx(FormElementContext feCtx) {
085:                this .feCtx = feCtx;
086:            }
087:
088:            public FormElementContext getFormElementCtx() {
089:                return this .feCtx;
090:            }
091:
092:            //*********************************************************************
093:            //* PROTECTED METHODS
094:            //*********************************************************************
095:
096:            protected void addError(String error) {
097:                feCtx.addError(error);
098:            }
099:
100:            protected void addErrors(Set errors) {
101:                feCtx.addErrors(errors);
102:            }
103:
104:            protected Environment getEnvironment() {
105:                return feCtx.getEnvironment();
106:            }
107:
108:            protected String getLabel() {
109:                return feCtx.getLabel();
110:            }
111:
112:            //*********************************************************************
113:            //* ABSTRACT INTERFACE METHODS
114:            //*********************************************************************
115:
116:            /**
117:             * This method should return a new converter, of the same type that the class that overrides it,
118:             * however freshly initialized.
119:             * 
120:             * @return a new converter, of the same type that the class that overrides it, however freshly
121:             * initialized.
122:             */
123:            public abstract Converter newConverter();
124:
125:            //*********************************************************************
126:            //* ABSTRACT IMPLEMENTATION METHODS
127:            //*********************************************************************
128:
129:            /**
130:             * This method should convert the data from one type to another. It may assume that the <code>data</code>
131:             * is never <code>null</code>.
132:             * 
133:             * @param data Data to convert.
134:             * @return Converted data.
135:             */
136:            protected abstract Object convertNotNull(Object data);
137:
138:            /**
139:             * This method should convert the data from one type to another. It may assume that the <code>data</code>
140:             * is never <code>null</code>. The types of data are reversed in comparison to
141:             * {@link #convertNotNull(Object)}.
142:             * 
143:             * @param data Data to convert.
144:             * @return Converted data.
145:             */
146:            protected abstract Object reverseConvertNotNull(Object data);
147:
148:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.