Source Code Cross Referenced for XPojoMethodArg.java in  » XML-UI » xui32 » com » xoetrope » data » pojo » 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 » XML UI » xui32 » com.xoetrope.data.pojo 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.xoetrope.data.pojo;
002:
003:        import java.util.List;
004:        import java.util.ArrayList;
005:        import java.util.Vector;
006:        import net.xoetrope.optional.data.pojo.XPojoDataSource;
007:        import net.xoetrope.optional.data.pojo.XPojoHelper;
008:
009:        import net.xoetrope.optional.data.pojo.XPojoModel;
010:        import net.xoetrope.xui.data.XBaseModel;
011:
012:        /**
013:         * Model of the arguments of the pojos methods. Works only for primitives.
014:         * <p> Copyright (c) Xoetrope Ltd., 2001-2007, This software is licensed under
015:         * the GNU Public License (GPL), please see license.txt for more details. If
016:         * you make commercial use of this software you must purchase a commercial
017:         * license from Xoetrope.</p>
018:         */
019:        public class XPojoMethodArg extends XPojoModelVis {
020:            public static final int ARG_VALUE = 0;
021:            public static final int ARG_NAME = 1;
022:            public static final int ARG_TYPE = 2;
023:            public static final int ARG_TYPEG = 3;
024:
025:            protected Class argumentType;
026:            protected String genericName;
027:            protected XPojoModelEx pojoFinder;
028:            protected XPropertiesRetriever propertiesRetriever;
029:            protected int argIdx;
030:
031:            /**
032:             * Full constructor, Creates the new instance of XPojoArg class.
033:             * @param idx argument's position in the list of finder's arguments.
034:             * @param at the type of the argument wrapped by this model node.
035:             * @param gat the type of the generic type of the argument
036:             * @param pc XPojoFinderEx object the argument of which is wrapped
037:             * @param ac object being used to obtain value of the argument wrapped
038:             * by this <code>XPojoFinderArg</code> object   
039:             */
040:            public XPojoMethodArg(XPojoMethodArgs pc, int i, Class at,
041:                    String gn, XPropertiesRetriever ar) {
042:                super (pc, null);
043:                propertiesRetriever = ar;
044:                argIdx = i;
045:                // Set the argument type
046:                if (XPojoHelper.isPrimitiveType(at))
047:                    setArgumentType(at);
048:                else
049:                    setArgumentType(String.class);
050:                genericName = gn;
051:                pojoFinder = (XPojoModelEx) pc.getParent();
052:                getCaption();
053:                restoreArgument();
054:            }
055:
056:            /**
057:             * Sets the new type of the underlying argument.
058:             * @param newType the new type to be set
059:             */
060:            public void setArgumentType(Class newType) {
061:                argumentType = newType;
062:                XPojoMethodArgs parent = (XPojoMethodArgs) getParent();
063:                parent.getParameterTypes()[argIdx] = newType;
064:            }
065:
066:            /**
067:             * Restores the value of this argument
068:             */
069:            public void restoreArgument() {
070:                if (hasValue()) {
071:                    setPojo(propertiesRetriever.getPropertyValue(this , "arg"));
072:                    if (pojo != null)
073:                        setArgumentType(pojo.getClass());
074:                } else {
075:                    setPojo(null);
076:                }
077:            }
078:
079:            /**
080:             * Determines wheter the value of this argument has been set.
081:             * @return true if this argument has a value, false otherwise
082:             */
083:            public boolean hasValue() {
084:                return propertiesRetriever.containsProperty(this , "arg");
085:            }
086:
087:            /**
088:             * Removes the value of this argument.
089:             */
090:            public void removeValue() {
091:                propertiesRetriever.removeProperty(this , "arg");
092:            }
093:
094:            /**
095:             * Gets the current type of the argument
096:             * wrapped by this node
097:             * @return argument type
098:             */
099:            public Class getArgumentType() {
100:                return argumentType;
101:            }
102:
103:            /**
104:             * Gets the name of this argument's type, as it
105:             * occurs in the source code.
106:             * @return the name of this argument's type
107:             */
108:            public String getGenericName() {
109:                return genericName;
110:            }
111:
112:            /**
113:             * Gets the name of this attribute
114:             * @return the name of this attribute
115:             */
116:            public String getName() {
117:                return "arg" + argIdx;
118:            }
119:
120:            /**
121:             * Indicates whether argument wrapped by this model node
122:             * was declared in the source code as generic.
123:             * @return true if the argument is generic, false
124:             * otherwise
125:             */
126:            public boolean isGeneric() {
127:                return (genericName != null);
128:            }
129:
130:            /**
131:             * Sets the value of the argument
132:             * @param val new value of the wrapped argument
133:             */
134:            public void setValue(Object val) {
135:                pojo = val;
136:                pojoClass = (pojo != null ? pojo.getClass() : null);
137:                propertiesRetriever.setPropertyValue(this , "arg", pojo);
138:                pojoFinder.setDirty(true);
139:            }
140:
141:            public Class getPojoClass() {
142:                return null;
143:            }
144:
145:            /**
146:             * Gets the value of the argument
147:             * @return value
148:             */
149:            public Object getValue() {
150:                boolean cp = propertiesRetriever.containsProperty(this , "arg");
151:                return (cp ? propertiesRetriever.getPropertyValue(this , "arg")
152:                        : null);
153:            }
154:
155:            /*
156:            public Object getValue()
157:            {
158:              return pojo;
159:            }
160:             */
161:
162:            /**
163:             * Gets the number of children of this model node,
164:             * @return 0, since it wrapps only the primitives
165:             */
166:            public int getNumChildren() {
167:                return 0;
168:            }
169:
170:            /**
171:             * Gets the position of this argument in the list of arguments.
172:             * @return position of this argument
173:             */
174:            public int getArgIdx() {
175:                return argIdx;
176:            }
177:
178:            /**
179:             * Sets the value of the attribute. This method is being called
180:             * from the visualiser's in order to set the new value of the
181:             * wrapped attribute.
182:             * @param idx index of the model's attribute
183:             * @param value the new values of the underlaying attribute
184:             */
185:            public void setAttribValue(int idx, Object value) {
186:                if (idx == ARG_VALUE)
187:                    setValue(value);
188:            }
189:
190:            /**
191:             * Returns the index of the attribiteNames array whose value is the same
192:             * as the attribName
193:             * @param attribName The name of the attribute we are trying to locate
194:             * @return The index of the attributeNames array containg the name
195:             */
196:            public int getAttribute(String attribName) {
197:                int attrIdx = -1;
198:                if ("type".equals(attribName))
199:                    attrIdx = ARG_TYPE;
200:                else if ("name".equals(attribName))
201:                    attrIdx = ARG_NAME;
202:                else if ("value".equals(attribName))
203:                    attrIdx = ARG_VALUE;
204:                else if ("generic type".equals(attribName))
205:                    attrIdx = ARG_TYPEG;
206:                return attrIdx;
207:            }
208:
209:            /**
210:             * Gets the caption of this object which will appear in
211:             * the visualiser tree.
212:             * @return the caption
213:             */
214:            public String getCaption() {
215:                String caption = (pojo != null ? pojo.toString() : "<not set>");
216:                caption = "arg" + argIdx + ": " + caption;
217:                setCaption(caption);
218:                return caption;
219:            }
220:
221:            /**
222:             * Returns the number of attributes of this model node
223:             * @return 3 (type, name, value)
224:             */
225:            public int getNumAttributes() {
226:                return (isGeneric() ? 4 : 3);
227:            }
228:
229:            /**
230:             * Gets the name of the finder argument's attribute
231:             * @param idx the index of the attribute
232:             * @return the name of the attribute
233:             */
234:            public String getAttribName(int idx) {
235:                String attribName = null;
236:                switch (idx) {
237:                case ARG_TYPE:
238:                    attribName = "type";
239:                    break;
240:                case ARG_TYPEG:
241:                    attribName = "generic type";
242:                    break;
243:                case ARG_NAME:
244:                    attribName = "name";
245:                    break;
246:                case ARG_VALUE:
247:                    attribName = "value";
248:                }
249:                return attribName;
250:            }
251:
252:            /**
253:             * Gets the value of the finder argument's attribute
254:             * @param idx the index of the attribute
255:             * @return the value of the attribute
256:             */
257:            public String getAttribValue(int idx) {
258:                String attribValue = null;
259:                switch (idx) {
260:                case ARG_VALUE:
261:                    if (hasValue())
262:                        attribValue = String.valueOf(pojo);
263:                    else
264:                        attribValue = "<not set>";
265:                    break;
266:                case ARG_NAME:
267:                    attribValue = "arg" + argIdx;
268:                    break;
269:                case ARG_TYPE:
270:                    attribValue = argumentType.getSimpleName();
271:                    break;
272:                case ARG_TYPEG:
273:                    if (isGeneric())
274:                        attribValue = genericName;
275:                    break;
276:                }
277:                return attribValue;
278:            }
279:
280:            /**
281:             * Gets the attributes
282:             */
283:            public Vector getBindingAttributes() {
284:                return null;
285:            }
286:
287:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.