Source Code Cross Referenced for XmlGroup.java in  » Web-Framework » TURBINE » org » apache » turbine » services » intake » xmlmodel » 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 » TURBINE » org.apache.turbine.services.intake.xmlmodel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.turbine.services.intake.xmlmodel;
002:
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:        import java.io.Serializable;
023:
024:        import java.util.ArrayList;
025:        import java.util.Iterator;
026:        import java.util.List;
027:
028:        import org.apache.commons.lang.StringUtils;
029:
030:        import org.xml.sax.Attributes;
031:
032:        /**
033:         * A Class for holding data about a grouping of inputs used in an Application.
034:         *
035:         * @author <a href="mailto:jmcnally@collab.net>John McNally</a>
036:         * @version $Id: XmlGroup.java 534527 2007-05-02 16:10:59Z tv $
037:         */
038:        public class XmlGroup implements  Serializable {
039:            /** Serial Version UID */
040:            private static final long serialVersionUID = -2529039710689787681L;
041:
042:            private List fields;
043:            private List mapToObjects;
044:            private String defaultMapToObject;
045:            private AppData parent;
046:            private String groupName;
047:            private String key;
048:            private String poolCapacity;
049:
050:            /**
051:             * Constructs a input group object
052:             */
053:            public XmlGroup() {
054:                fields = new ArrayList();
055:                mapToObjects = new ArrayList(2);
056:            }
057:
058:            /**
059:             * Load the input group object from an xml tag.
060:             */
061:            public void loadFromXML(Attributes attrib) {
062:                groupName = attrib.getValue("name");
063:                key = attrib.getValue("key");
064:                poolCapacity = attrib.getValue("pool-capacity");
065:
066:                String objName = attrib.getValue("mapToObject");
067:                if (StringUtils.isNotEmpty(objName)) {
068:                    defaultMapToObject = objName;
069:                }
070:            }
071:
072:            /**
073:             * Get the name that handles this group
074:             */
075:            public String getName() {
076:                return groupName;
077:            }
078:
079:            /**
080:             * Set the name that handles this group
081:             */
082:            public void setName(String newGroupName) {
083:                groupName = newGroupName;
084:            }
085:
086:            /**
087:             * Get the key used to reference this group in input (form)
088:             */
089:            public String getKey() {
090:                return key;
091:            }
092:
093:            /**
094:             * Set the key used to reference this group in input (form)
095:             */
096:            public void setKey(String newKey) {
097:                key = newKey;
098:            }
099:
100:            /**
101:             * The maximum number of classes specific to this group
102:             * allowed at one time.
103:             *
104:             * @return an <code>String</code> value
105:             */
106:            public String getPoolCapacity() {
107:                if (poolCapacity == null) {
108:                    return "128";
109:                }
110:
111:                return poolCapacity;
112:            }
113:
114:            /**
115:             * A utility function to create a new field
116:             * from attrib and add it to this input group.
117:             */
118:            public XmlField addField(Attributes attrib) {
119:                XmlField field = new XmlField();
120:                field.loadFromXML(attrib);
121:                addField(field);
122:
123:                return field;
124:            }
125:
126:            /**
127:             * Adds a new field to the fields list and set the
128:             * parent group of the field to the current group
129:             */
130:            public void addField(XmlField field) {
131:                field.setGroup(this );
132:
133:                // if this field has an object defined for mapping,
134:                // add it to the list
135:                if (field.getMapToObject() != null) {
136:                    boolean isNewObject = true;
137:                    for (int i = 0; i < mapToObjects.size(); i++) {
138:                        if (mapToObjects.get(i).equals(field.getMapToObject())) {
139:                            isNewObject = false;
140:                            break;
141:                        }
142:                    }
143:                    if (isNewObject) {
144:                        mapToObjects.add(field.getMapToObject());
145:                    }
146:                }
147:                // if a mapToProperty exists, set the object to this group's default
148:                else if (field.getMapToProperty() != null
149:                        && !"".equals(field.getMapToProperty())
150:                        && defaultMapToObject != null) {
151:                    field.setMapToObject(defaultMapToObject);
152:                }
153:
154:                fields.add(field);
155:            }
156:
157:            /**
158:             * Returns a collection of fields in this input group
159:             */
160:            public List getFields() {
161:                return fields;
162:            }
163:
164:            /**
165:             * Utility method to get the number of fields in this input group
166:             */
167:            public int getNumFields() {
168:                return fields.size();
169:            }
170:
171:            /**
172:             * Returns a Specified field.
173:             * @return Return a XmlField object or null if it does not exist.
174:             */
175:            public XmlField getField(String name) {
176:                String curName;
177:
178:                for (Iterator iter = fields.iterator(); iter.hasNext();) {
179:                    XmlField field = (XmlField) iter.next();
180:                    curName = field.getRawName();
181:                    if (curName.equals(name)) {
182:                        return field;
183:                    }
184:                }
185:                return null;
186:            }
187:
188:            /**
189:             * Returns true if the input group contains a spesified field
190:             */
191:            public boolean containsField(XmlField field) {
192:                return fields.contains(field);
193:            }
194:
195:            /**
196:             * Returns true if the input group contains a specified field
197:             */
198:            public boolean containsField(String name) {
199:                return (getField(name) != null);
200:            }
201:
202:            public List getMapToObjects() {
203:                return mapToObjects;
204:            }
205:
206:            /**
207:             * Set the parent of the group
208:             */
209:            public void setAppData(AppData parent) {
210:                this .parent = parent;
211:                if (defaultMapToObject != null) {
212:                    defaultMapToObject = parent.getBasePackage()
213:                            + defaultMapToObject;
214:                    mapToObjects.add(defaultMapToObject);
215:                }
216:            }
217:
218:            /**
219:             * Get the parent of the input group
220:             */
221:            public AppData getAppData() {
222:                return parent;
223:            }
224:
225:            /**
226:             * A String which might be used as a variable of this class
227:             */
228:            public String getVariable() {
229:                String firstChar = getName().substring(0, 1).toLowerCase();
230:                return firstChar + getName().substring(1);
231:            }
232:
233:            /**
234:             * Creates a string representation of this input group. This
235:             * is an xml representation.
236:             */
237:            public String toString() {
238:                StringBuffer result = new StringBuffer();
239:
240:                result.append("<group name=\"").append(getName());
241:                result.append(" key=\"" + key + "\"");
242:                result.append(">\n");
243:
244:                if (fields != null) {
245:                    for (Iterator iter = fields.iterator(); iter.hasNext();) {
246:                        result.append(iter.next());
247:                    }
248:                }
249:
250:                result.append("</group>\n");
251:
252:                return result.toString();
253:            }
254:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.