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


001:        package uk.org.ponder.saxalizer;
002:
003:        /**
004:         * A SAXAccessMethodSpec identifies a mapping from an XML tag name to a Java
005:         * method name that is capable of either setting or getting an XML-serialised
006:         * subobject (the <it>target object </it). If it is a get method, the signature
007:         * of the method must be <code>
008:         * &lt;clazz&gt; &lt;methodname&gt;() </code>. If
009:         * it is a set method, the signature of the method must be <code>void
010:         * &lt;methodname&gt;(&lt;clazz&gt;)</code>.
011:         * <p>
012:         * Thus we must be clear that <code>clazz</code> is the type returned or taken
013:         * from the access method, i.e. the type of the subobject and NOT the type of
014:         * the object that the method is a member of.
015:         * <p>
016:         * The value "*" is allowed for the parameter <code>clazz</code>, which
017:         * indicates that the XML tagname will be interpreted as a fully-qualified Java
018:         * classname. This class must exist and be a subclass of the actual argument
019:         * type of the method identified.
020:         */
021:
022:        public class SAXAccessMethodSpec implements  SAXalizable,
023:                SAXalizableAttrs {
024:            public static final int GET_METHOD = 0;
025:            public static final int SET_METHOD = 1;
026:            public static final int FIELD_METHOD = 2;
027:            public static final String ACCESS_METHOD = "method";
028:            public static final String ACCESS_FIELD = "field";
029:            public static final String ACCESS_IGNORE = "ignore";
030:            public static final String XML_TAG = "tag";
031:            public static final String XML_ATTRIBUTE = "attribute";
032:            public static final String XML_BODY = "body";
033:
034:            public static final String DEFAULT_ACCESS = ACCESS_METHOD;
035:            public static final String DEFAULT_XML_FORM = XML_TAG;
036:            // either the tag or attribute name, depending on the value of xmlform.
037:            public String xmlname;
038:            // if either getmethodname or setmethodname is set, fieldname will not be
039:            // set. At least one out of the following three will be.
040:            public String getmethodname;
041:            public String setmethodname;
042:            public String fieldname;
043:            // QQQQQ this field need not exist, although the ACCESS strings do.
044:            public String accesstype = DEFAULT_ACCESS;
045:            public String xmlform = DEFAULT_XML_FORM;
046:            public Class clazz;
047:
048:            /**
049:             * @param tag The tagname that will be used when the target object is
050:             *          serialised, or "*" if the tag is not known.
051:             * @param methodname The method to be called in order to deliver or retrieve
052:             *          the target object.
053:             * @param clazz The class (or a superclass) of the target object
054:             */
055:            public SAXAccessMethodSpec(String tag, String methodname,
056:                    Class clazz) {
057:                this .xmlname = tag;
058:                this .getmethodname = methodname;
059:                this .clazz = clazz;
060:            }
061:
062:            public SAXAccessMethodSpec(String tag, String methodorfieldname,
063:                    Class clazz, String accesstype) {
064:                this .xmlname = tag;
065:                this .accesstype = accesstype;
066:                if (accesstype.equals(ACCESS_METHOD)) {
067:                    this .getmethodname = methodorfieldname;
068:                } else if (accesstype.equals(ACCESS_FIELD)) {
069:                    this .fieldname = methodorfieldname;
070:                }
071:                this .clazz = clazz;
072:            }
073:
074:            public SAXAccessMethodSpec() {
075:
076:            }
077:
078:            public boolean isDuplicate(SAXAccessMethodSpec newentry) {
079:                if (newentry.setmethodname != null
080:                        && newentry.setmethodname.equals(setmethodname))
081:                    return true;
082:                if (newentry.getmethodname != null
083:                        && newentry.getmethodname.equals(getmethodname))
084:                    return true;
085:                if (newentry.fieldname != null
086:                        && newentry.fieldname.equals(fieldname))
087:                    return true;
088:                return false;
089:            }
090:
091:            /**
092:             * This is a utility method, currently called by MethodAnalyser, for SAMS
093:             * returned from getSAXQqqMethod() in order to swap the name supplied for
094:             * "methodname" which defaults to referring to a get method into a set method.
095:             * 
096:             * @param toconvert
097:             */
098:            public static void convertToSetSpec(SAXAccessMethodSpec[] toconvert) {
099:                for (int i = 0; i < toconvert.length; ++i) {
100:                    // Bail out if the swapping has already been performed!!
101:                    if (toconvert[i].getmethodname != null) {
102:                        toconvert[i].setmethodname = toconvert[i].getmethodname;
103:                        toconvert[i].getmethodname = null;
104:                    }
105:                }
106:            }
107:
108:            /**
109:             * This is a utility method, currently called by MethodAnalyser, for SAMS
110:             * returned from getSAXQqqAttrMethod() in order to convert swap the name
111:             * supplied for "tagname" which defaults to referring to a tag method into an
112:             * attribute.
113:             * 
114:             * @param toconvert
115:             */
116:            public static void convertToAttrSpec(SAXAccessMethodSpec[] toconvert) {
117:                for (int i = 0; i < toconvert.length; ++i) {
118:                    toconvert[i].xmlform = XML_ATTRIBUTE;
119:                }
120:            }
121:
122:            // Yes, SAXAccessMethodSpecs are themselves SAXalizable.
123:            public SAXAccessMethodSpec[] getSAXSetMethods() {
124:                return new SAXAccessMethodSpec[] {
125:                        new SAXAccessMethodSpec("getmethod", "getmethodname",
126:                                String.class, ACCESS_FIELD),
127:                        new SAXAccessMethodSpec("setmethod", "setmethodname",
128:                                String.class, ACCESS_FIELD),
129:                        new SAXAccessMethodSpec("fieldname", "fieldname",
130:                                String.class, ACCESS_FIELD),
131:                        new SAXAccessMethodSpec("javaclass", "clazz",
132:                                Class.class, ACCESS_FIELD) };
133:            }
134:
135:            public SAXAccessMethodSpec[] getSAXSetAttrMethods() {
136:                return new SAXAccessMethodSpec[] {
137:                        new SAXAccessMethodSpec("xmlname", "xmlname",
138:                                String.class, ACCESS_FIELD),
139:                        new SAXAccessMethodSpec("access-type", "accesstype",
140:                                String.class, ACCESS_FIELD),
141:                        new SAXAccessMethodSpec("xml-form", "xmlform",
142:                                String.class, ACCESS_FIELD) };
143:            }
144:
145:            public String toString() {
146:                return "SAXAccessMethodSpec for " + xmlform + " " + xmlname
147:                        + ", getmethod: " + getmethodname + " setmethod: "
148:                        + setmethodname + " fieldname: " + fieldname;
149:            }
150:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.