Source Code Cross Referenced for AbstractDomainProvider.java in  » Workflow-Engines » osbl-1_0 » org » conform » 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 » Workflow Engines » osbl 1_0 » org.conform 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.conform;
002:
003:        import org.conform.format.AbstractFormat;
004:        import org.conform.format.FormatComparator;
005:        import org.apache.commons.logging.LogFactory;
006:
007:        import java.util.*;
008:
009:        /**
010:         * derived classed need to implement:
011:         * 
012:         * 1) createValues() -> return the list of values for the combo box,
013:         *      the values must be of the same type as the property
014:         *      
015:         * 2) formatValue() -> convert a value to a text string which is diplayed
016:         *      in the combo box
017:         *      or:
018:         *    setValue2String -> set all format strings for all values during initialization  
019:         *      
020:         * wilken.openshop.core.util.AbstractDomainProvider
021:         */
022:        public abstract class AbstractDomainProvider<T> extends AbstractFormat
023:                implements  DomainProvider, Modifier {
024:            private static org.apache.commons.logging.Log LOG = LogFactory
025:                    .getLog(DomainProvider.class);
026:
027:            protected String propertyName;
028:
029:            protected List<T> values;
030:
031:            private Map<T, String> value2String;
032:
033:            protected AbstractDomainProvider() {
034:            }
035:
036:            protected AbstractDomainProvider(String propertyName) {
037:                this .propertyName = propertyName;
038:            }
039:
040:            /**
041:             * @param value2String The value2String to set.
042:             */
043:            public void setValue2String(Map<T, String> value2String) {
044:                this .value2String = value2String;
045:            }
046:
047:            /**
048:             * @inheritDoc
049:             */
050:            public final void modify(BeanMeta beanMeta)
051:                    throws ModifierException {
052:                if (propertyName == null)
053:                    throw new IllegalStateException(
054:                            "Provide the propertyName, if you use it as a modifier");
055:
056:                PropertyMeta property = beanMeta.getProperty(propertyName);
057:                property.setDomainProvider(this );
058:                property.setFormat(this );
059:            }
060:
061:            protected abstract List<T> createValues();
062:
063:            /**
064:             * @inheritDoc
065:             */
066:            public final String format(Object value) {
067:                return formatValue((T) value);
068:            }
069:
070:            /**
071:             * this method can be overriden, or the format mapping must be initialized
072:             * 
073:             * @param value
074:             * @return
075:             */
076:            protected String formatValue(T value) {
077:                if (this .value2String == null) {
078:                    LOG.warn("No string for value " + value);
079:                    return String.valueOf(value);
080:                }
081:                String text = this .value2String.get(value);
082:                if (text == null) {
083:                    LOG.warn("No string for value " + value);
084:                    return String.valueOf(value);
085:                }
086:                return text;
087:            }
088:
089:            /**
090:             * @inheritDoc
091:             */
092:            public final List<T> getDomain() {
093:                if (values == null) {
094:                    values = createValues();
095:                    if (values == null)
096:                        values = new ArrayList<T>(0);
097:
098:                    if (isSorted())
099:                        Collections.sort(values, createComparator());
100:                }
101:                return values;
102:            }
103:
104:            /**
105:             * create the comparator for sorting
106:             * 
107:             * @return
108:             */
109:            protected Comparator<T> createComparator() {
110:                return new FormatComparator<T>(this );
111:            }
112:
113:            /**
114:             * override this method to have an unsorted list
115:             * 
116:             * @return
117:             */
118:            protected boolean isSorted() {
119:                return true;
120:            }
121:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.