Source Code Cross Referenced for XmlAttribute.java in  » Web-Framework » struts-1.3.8 » org » apache » struts » tiles » xmlDefinition » 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 » struts 1.3.8 » org.apache.struts.tiles.xmlDefinition 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: XmlAttribute.java 471754 2006-11-06 14:55:09Z husted $
003:         *
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *  http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:
022:        package org.apache.struts.tiles.xmlDefinition;
023:
024:        import org.apache.struts.tiles.DefinitionNameAttribute;
025:        import org.apache.struts.tiles.DirectStringAttribute;
026:        import org.apache.struts.tiles.PathAttribute;
027:        import org.apache.struts.tiles.UntypedAttribute;
028:
029:        /**
030:         * A property key-value pair.  This class is used to read configuration files.
031:         */
032:        public class XmlAttribute {
033:
034:            /**
035:             * Attribute name or key.
036:             */
037:            private String name = null;
038:
039:            /**
040:             * Attribute value.
041:             * Value read from description file.
042:             */
043:            private Object value = null;
044:
045:            /**
046:             * Attribute value.
047:             */
048:            private String direct = null;
049:
050:            /**
051:             * Attribute value.
052:             */
053:            private String valueType = null;
054:
055:            /**
056:             * Attribute value.
057:             */
058:            private String role = null;
059:
060:            /**
061:             * Real attribute value.
062:             * Real value is the value after processing of valueType.
063:             * I.e. if a type is defined, realValue contains wrapper for this type.
064:             */
065:            private Object realValue = null;
066:
067:            /**
068:             * Constructor.
069:             */
070:            public XmlAttribute() {
071:                super ();
072:            }
073:
074:            /**
075:             * Constructor.
076:             */
077:            public XmlAttribute(String name, Object value) {
078:                this .name = name;
079:                this .value = value;
080:            }
081:
082:            /**
083:             * Access method for the name property.
084:             *
085:             * @return The current value of the name property.
086:             */
087:            public String getName() {
088:                return name;
089:            }
090:
091:            /**
092:             * Sets the value of the name property.
093:             *
094:             * @param role the new value of the name property
095:             */
096:            public void setRole(String role) {
097:                this .role = role;
098:            }
099:
100:            /**
101:             * Access method for the name property.
102:             *
103:             * @return The current value of the name property.
104:             */
105:            public String getRole() {
106:                return role;
107:            }
108:
109:            /**
110:             * Sets the value of the name property.
111:             *
112:             * @param aName the new value of the name property.
113:             */
114:            public void setName(String aName) {
115:                name = aName;
116:            }
117:
118:            /**
119:             * Another access method for the name property.
120:             *
121:             * @return   the current value of the name property
122:             */
123:            public String getAttribute() {
124:                return name;
125:            }
126:
127:            /**
128:             * Sets the value of the name property.
129:             *
130:             * @param aName the new value of the name property
131:             */
132:            public void setAttribute(String aName) {
133:                name = aName;
134:            }
135:
136:            /**
137:             * Access method for the value property. Return the value or a
138:             * QualifiedAttribute containing the value if 'direct' is set.
139:             *
140:             * @return The current value of the value property.
141:             */
142:            public Object getValue() {
143:                // Compatibility with JSP Template
144:                if (this .realValue == null) {
145:                    this .realValue = this .computeRealValue();
146:                }
147:
148:                return this .realValue;
149:            }
150:
151:            /**
152:             * Sets the value of the value property.
153:             *
154:             * @param aValue the new value of the value property
155:             */
156:            public void setValue(Object aValue) {
157:                realValue = null;
158:                value = aValue;
159:            }
160:
161:            /**
162:             * Sets the value of the value property.
163:             *
164:             * @param aValue the new value of the value property
165:             */
166:            public void setContent(Object aValue) {
167:                setValue(aValue);
168:            }
169:
170:            /**
171:             * Sets the value of the value property.
172:             *
173:             * @param body the new value of the value property
174:             */
175:            public void setBody(String body) {
176:                if (body.length() == 0) {
177:                    return;
178:                }
179:
180:                setValue(body);
181:            }
182:
183:            /**
184:             * Sets the value of the value property.
185:             *
186:             * @param value the new value of the value property
187:             */
188:            public void setDirect(String value) {
189:                this .direct = value;
190:            }
191:
192:            /**
193:             * Sets the value of the value property.
194:             *
195:             * @param value the new value of the value property
196:             */
197:            public void setType(String value) {
198:                this .valueType = value;
199:            }
200:
201:            /**
202:             * Compute  real value from attributes setting.
203:             */
204:            protected Object computeRealValue() {
205:                Object realValue = value;
206:                // Is there a type set ?
207:                // First check direct attribute, and translate it to a valueType.
208:                // Then, evaluate valueType, and create requested typed attribute.
209:                if (direct != null) {
210:                    this .valueType = Boolean.valueOf(direct).booleanValue() ? "string"
211:                            : "path";
212:                }
213:
214:                if (value != null && valueType != null) {
215:                    String strValue = value.toString();
216:
217:                    if (valueType.equalsIgnoreCase("string")) {
218:                        realValue = new DirectStringAttribute(strValue);
219:
220:                    } else if (valueType.equalsIgnoreCase("page")) {
221:                        realValue = new PathAttribute(strValue);
222:
223:                    } else if (valueType.equalsIgnoreCase("template")) {
224:                        realValue = new PathAttribute(strValue);
225:
226:                    } else if (valueType.equalsIgnoreCase("instance")) {
227:                        realValue = new DefinitionNameAttribute(strValue);
228:                    }
229:
230:                    // Set realValue's role value if needed
231:                    if (role != null) {
232:                        ((UntypedAttribute) realValue).setRole(role);
233:                    }
234:                }
235:
236:                // Create attribute wrapper to hold role if role is set and no type
237:                // specified
238:                if (role != null && value != null && valueType == null) {
239:                    realValue = new UntypedAttribute(value.toString(), role);
240:                }
241:
242:                return realValue;
243:            }
244:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.