Source Code Cross Referenced for TransformerOptions.java in  » XML » zeus » org » enhydra » zeus » transform » 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 » zeus » org.enhydra.zeus.transform 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Enhydra Java Application Server Project
003:         * 
004:         * The contents of this file are subject to the Enhydra Public License
005:         * Version 1.1 (the "License"); you may not use this file except in
006:         * compliance with the License. You may obtain a copy of the License on
007:         * the Enhydra web site ( http://www.enhydra.org/ ).
008:         * 
009:         * Software distributed under the License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 
011:         * the License for the specific terms governing rights and limitations
012:         * under the License.
013:         * 
014:         * The Initial Developer of the Enhydra Application Server is Lutris
015:         * Technologies, Inc. The Enhydra Application Server and portions created
016:         * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017:         * All Rights Reserved.
018:         */
019:        package org.enhydra.zeus.transform;
020:
021:        import org.enhydra.zeus.InvalidCollectionTypeException;
022:        import org.enhydra.zeus.util.ClassUtils;
023:
024:        /**
025:         * <p>
026:         *  <code>TransformerOptions</code> is used to specify options used in
027:         *    <code>{@link org.enhydra.zeus.Transformer}</code> and related classes
028:         *    and processes. It specifies global options for transformation such
029:         *    as packages, collection types, and more.
030:         * </p>
031:         *
032:         * @author Brett McLaughlin
033:         */
034:        public class TransformerOptions {
035:
036:            /** The default package for all classes, unless overridden */
037:            protected String defaultPackage;
038:
039:            /** The default interface package for this transformation */
040:            protected String interfacePackage;
041:
042:            /** The default implementation package for this transformation */
043:            protected String implementationPackage;
044:
045:            /** The default collection class type */
046:            protected int defaultCollectionType;
047:
048:            /**
049:             * <p>
050:             *  This default constructor sets up default variable values.
051:             * </p>
052:             */
053:            public TransformerOptions() {
054:                this ("", ClassUtils.COLLECTION_TYPE_LIST);
055:            }
056:
057:            /**
058:             * <p>
059:             *  This convenience constructor allows options to be set on
060:             *    construction.
061:             * </p>
062:             *
063:             * @param defaultPackage the package for all generated classes.
064:             * @param defaultCollectionType constant for the collection type to use.
065:             */
066:            public TransformerOptions(String defaultPackage,
067:                    int defaultCollectionType) {
068:                this .defaultPackage = defaultPackage;
069:                interfacePackage = null;
070:                implementationPackage = null;
071:                try {
072:                    setDefaultCollectionType(defaultCollectionType);
073:                } catch (InvalidCollectionTypeException e) {
074:                    try {
075:                        setDefaultCollectionType(ClassUtils.COLLECTION_TYPE_LIST);
076:                    } catch (InvalidCollectionTypeException neverHappens) {
077:                    }
078:                }
079:            }
080:
081:            /**
082:             * <p>
083:             *  This convenience constructor allows options to be set on
084:             *    construction.
085:             * </p>
086:             *
087:             * @param interfacePackage the package for all generated interfaces.
088:             * @param implementationPackage the package for all generated implementation
089:             *        packages.
090:             * @param defaultCollectionType constant for the collection type to use.
091:             */
092:            public TransformerOptions(String interfacePackage,
093:                    String implementationPackage, int defaultCollectionType) {
094:                defaultPackage = "";
095:                interfacePackage = interfacePackage;
096:                implementationPackage = implementationPackage;
097:                try {
098:                    setDefaultCollectionType(defaultCollectionType);
099:                } catch (InvalidCollectionTypeException e) {
100:                    try {
101:                        setDefaultCollectionType(ClassUtils.COLLECTION_TYPE_LIST);
102:                    } catch (InvalidCollectionTypeException neverHappens) {
103:                    }
104:                }
105:            }
106:
107:            /**
108:             * <p>
109:             *  This sets the default and global package for all generated
110:             *    classes, unless a specific package for interfaces and/or
111:             *    implementations is supplied, which then overrides this
112:             *    setting. Those packages can be set using the
113:             *    <code>{@link #setInterfacePackage}</code> and
114:             *    <code>{@link #setImplementationPackage}</code> methods.
115:             * </p><p>
116:             *  There is intentionally not a <code>getDefaultPackage()</code> method.
117:             *    Instead, <code>{@link #getInterfacePackage}</code> and
118:             *    <code>{@link #getImplementationPackage}</code> should be used,
119:             *    which return correct values based on the default and specific
120:             *    packages set for both options.
121:             *
122:             * @param interfacePackage the package for generated interfaces.
123:             */
124:            public void setDefaultPackage(String defaultPackage) {
125:                if (defaultPackage == null) {
126:                    throw new IllegalArgumentException(
127:                            "A TransformerOptions cannot "
128:                                    + "have a null value for the default package. To use the "
129:                                    + "default package, specify an empty String (\"\").");
130:                }
131:
132:                this .defaultPackage = defaultPackage;
133:            }
134:
135:            /**
136:             * <p>
137:             *  This sets the default and global interface package for generated
138:             *    classes.
139:             * </p>
140:             *
141:             * @param interfacePackage the package for generated interfaces.
142:             */
143:            public void setInterfacePackage(String interfacePackage) {
144:                if (interfacePackage == null) {
145:                    throw new IllegalArgumentException(
146:                            "A TransformerOptions cannot "
147:                                    + "have a null value for the interface package. To use the "
148:                                    + "default package, specify an empty String (\"\").");
149:                }
150:                this .interfacePackage = interfacePackage;
151:            }
152:
153:            /**
154:             * <p>
155:             *  This returns the default package in which generated interfaces are
156:             *    placed.
157:             * </p>
158:             *
159:             * @return <code>String</code> - the default interface package.
160:             */
161:            public String getInterfacePackage() {
162:                if (interfacePackage != null) {
163:                    return interfacePackage;
164:                } else {
165:                    return defaultPackage;
166:                }
167:            }
168:
169:            /**
170:             * <p>
171:             *  This sets the default and global interface package for generated
172:             *    classes.
173:             * </p>
174:             *
175:             * @param interfacePackage the package for generated interfaces.
176:             */
177:            public void setImplementationPackage(String implementationPackage) {
178:                if (implementationPackage == null) {
179:                    throw new IllegalArgumentException(
180:                            "A TransformerOptions cannot "
181:                                    + "have a null value for the implementation package. To use "
182:                                    + "the default package, specify an empty String (\"\").");
183:                }
184:                this .implementationPackage = implementationPackage;
185:            }
186:
187:            /**
188:             * <p>
189:             *  This returns the default package in which generated implementations are
190:             *    placed.
191:             * </p>
192:             *
193:             * @return <code>String</code> - the default implementation package.
194:             */
195:            public String getImplementationPackage() {
196:                if (implementationPackage != null) {
197:                    return implementationPackage;
198:                } else {
199:                    return defaultPackage;
200:                }
201:            }
202:
203:            /**
204:             * <p>
205:             *  This allows setting of the default collection type for transformations,
206:             *    through constants defined in this class. If the supplied constant is 
207:             *    an illegal type, an 
208:             *    <code>{@link InvalidCollectionTypeException}</code> is thrown.
209:             * </p>
210:             *
211:             * @param defaultCollectionType the collection type to use in
212:             *        transformations, as an <code>int</code> constant.
213:             * @throws <code>InvalidCollectionTypeException</code> - when an illegal
214:             *         collection type is supplied.
215:             * @see <code>{@link #COLLECTION_TYPE_LIST}</code>
216:             * @see <code>{@link #COLLECTION_TYPE_ARRAY}</code>
217:             */
218:            public void setDefaultCollectionType(int defaultCollectionType)
219:                    throws InvalidCollectionTypeException {
220:
221:                // Ensure a legal value
222:                if (!ClassUtils.isCollectionConstant(defaultCollectionType)) {
223:                    throw new InvalidCollectionTypeException();
224:                }
225:
226:                // If legal, set as default collection type
227:                this .defaultCollectionType = defaultCollectionType;
228:            }
229:
230:            /**
231:             * <p>
232:             *  This allows setting of the default collection type for transformations,
233:             *    through supplying a <code>String</code> class name, such as
234:             *    <code>java.util.List</code>. If the supplied type is an illegal type,
235:             *    an <code>{@link InvalidCollectionTypeException}</code> is thrown.
236:             * </p>
237:             *
238:             * @param defaultCollectionTypeString the String representation of the
239:             *        collection type to use.
240:             * @throws <code>InvalidCollectionTypeException</code> - when an illegal
241:             *         collection type is supplied.
242:             */
243:            public void setDefaultCollectionType(
244:                    String defaultCollectionTypeString)
245:                    throws InvalidCollectionTypeException {
246:
247:                // If legal, set as default collection type
248:                this .defaultCollectionType = ClassUtils
249:                        .getCollectionTypeAsInt(defaultCollectionTypeString);
250:            }
251:
252:            /**
253:             * <p>
254:             *  This will return the default collection class name for this set
255:             *    of transformation options. This will return a fully-qualified class
256:             *    name, such as <code>java.util.List</code>.
257:             * </p>
258:             *
259:             * @return <code>String</code> - the class name for the collection type.
260:             */
261:            public String getDefaultCollectionType() {
262:                return ClassUtils
263:                        .getCollectionTypeAsString(defaultCollectionType);
264:            }
265:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.