Source Code Cross Referenced for VectorCapableParser.java in  » Web-Framework » RSF » uk » org » ponder » conversion » 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 » RSF » uk.org.ponder.conversion 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Nov 11, 2005
003:         */
004:        package uk.org.ponder.conversion;
005:
006:        import java.util.Enumeration;
007:
008:        import uk.org.ponder.arrayutil.ArrayUtil;
009:        import uk.org.ponder.beanutil.BeanResolver;
010:        import uk.org.ponder.reflect.ReflectiveCache;
011:        import uk.org.ponder.saxalizer.mapping.ContainerTypeRegistry;
012:        import uk.org.ponder.stringutil.StringList;
013:        import uk.org.ponder.util.Denumeration;
014:        import uk.org.ponder.util.EnumerationConverter;
015:        import uk.org.ponder.util.Logger;
016:
017:        /**
018:         * An "aggregating" object parser/renderer that is capable of dealing with
019:         * vector (array, list) values by repeated invokation of a LeafObjectParser for
020:         * each parse/render.
021:         * 
022:         * @author Antranig Basman (antranig@caret.cam.ac.uk)
023:         */
024:        // Should convert this into an interface, but there is not really any kind of
025:        // alternative implementation - all customizability is at the scalarparser
026:        // level.
027:        public class VectorCapableParser {
028:            private StaticLeafParser scalarparser;
029:            private ContainerTypeRegistry ctr;
030:
031:            public void setScalarParser(StaticLeafParser scalarparser) {
032:                this .scalarparser = scalarparser;
033:            }
034:
035:            /**
036:             * Determines whether the supplied object is some kind of "List of Strings"
037:             * type, either String[] or StringList.
038:             */
039:            public static boolean isLOSType(Object o) {
040:                Logger.log.info("SAC: " + ArrayUtil.stringArrayClass);
041:                return ArrayUtil.stringArrayClass
042:                        .isAssignableFrom(o.getClass())
043:                        || o instanceof  StringList;
044:            }
045:
046:            public void setContainerTypeRegistry(ContainerTypeRegistry ctr) {
047:                this .ctr = ctr;
048:            }
049:
050:            /**
051:             * Converts some form of multiple Strings into some form of multiple Objects.
052:             * 
053:             * @param stringlist Some form of String collection - either a String[] array,
054:             *          or any kind of Collection with String elements. {@link isLOSType}
055:             *          will return true for this argument.
056:             * @param target Some kind of collection or array
057:             *          {@link EnumerationConverter.isDenumerable} will return true for
058:             *          this argument. The elements of this "collection" will be filled
059:             *          with parsed values.
060:             * @return Either a List or Array of Object according to whether the second
061:             *         parameter  represents a Class or is null. 
062:             */
063:            public Object parse(Object stringlist, Object target,
064:                    Class elemtype, ReflectiveCache reflectivecache) {
065:                // int size = EnumerationConverter.getEnumerableSize(stringlist);
066:                // Object togo = arraytype == null? new ArrayList(size) :
067:                // Array.newInstance(arraytype, size);
068:                Denumeration denum = EnumerationConverter.getDenumeration(
069:                        target, reflectivecache);
070:                Class containeetype = ctr.getContaineeType(target);
071:                if (containeetype != null) {
072:                    elemtype = containeetype;
073:                }
074:                for (Enumeration elemenum = EnumerationConverter
075:                        .getEnumeration(stringlist); elemenum.hasMoreElements();) {
076:                    String elem = (String) elemenum.nextElement();
077:                    Object converted = scalarparser.parse(elemtype, elem);
078:                    denum.add(converted);
079:                }
080:                return target;
081:            }
082:
083:            /**
084:             * Converts some form of multiple objects into some form of multiple Strings.
085:             * 
086:             * @param torenders Either some form of Object array or a Collection.
087:             * @param The object into which the rendered objects are to be placed as
088:             *          Strings - either a String[] array (of the correct size!) or a
089:             *          Collection.
090:             */
091:            // This code will go into ValueFixer.
092:            public void render(Object torenders, Object toreceive,
093:                    BeanResolver resolver, ReflectiveCache reflectivecache) {
094:                Denumeration denum = EnumerationConverter.getDenumeration(
095:                        toreceive, reflectivecache);
096:                for (Enumeration rendenum = EnumerationConverter
097:                        .getEnumeration(torenders); rendenum.hasMoreElements();) {
098:                    Object torender = rendenum.nextElement();
099:                    String rendered = resolver == null ? scalarparser
100:                            .render(torender) : resolver.resolveBean(torender);
101:                    denum.add(rendered);
102:                }
103:            }
104:
105:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.