Source Code Cross Referenced for Resource.java in  » UML » AndroMDA-3.2 » org » andromda » core » cartridge » 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 » UML » AndroMDA 3.2 » org.andromda.core.cartridge 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.andromda.core.cartridge;
002:
003:        import java.io.File;
004:
005:        import java.text.MessageFormat;
006:
007:        import org.andromda.core.configuration.NamespaceProperties;
008:        import org.andromda.core.configuration.Namespaces;
009:        import org.andromda.core.configuration.Property;
010:        import org.apache.commons.lang.StringUtils;
011:
012:        /**
013:         * <p/>
014:         * This class implements the <code>&lt;resource&gt;</code> tag in a cartridge descriptor file and represents the base
015:         * cartridge resource element. </p>
016:         *
017:         * @author Chad Brandon
018:         */
019:        public class Resource {
020:            /**
021:             * Stores the output location logical name.
022:             */
023:            private String outlet;
024:
025:            /**
026:             * Gets the logical location to which output from this resource will be written.
027:             *
028:             * @return Returns the outlet.
029:             */
030:            public String getOutlet() {
031:                return outlet;
032:            }
033:
034:            /**
035:             * Sets the logical location to which output from this resource will be written.
036:             *
037:             * @param outlet The outlet to set.
038:             */
039:            public void setOutlet(final String outlet) {
040:                this .outlet = outlet;
041:            }
042:
043:            /**
044:             * Stores the outputCondition that must evalute to true for the template to be written.
045:             */
046:            private String outputCondition;
047:
048:            /**
049:             * Sets the outputCondition that must evaluate to true in order for the template to be written.
050:             * 
051:             * @param outputCondition the template engine outputCondition.
052:             */
053:            public void setOutputCondition(final String outputCondition) {
054:                this .outputCondition = outputCondition;
055:            }
056:
057:            /**
058:             * Gets the outputCondition that must evaluate to true in order for the template to be written.
059:             * 
060:             * @return the template engine outputCondition.
061:             */
062:            public String getOutputCondition() {
063:                return this .outputCondition;
064:            }
065:
066:            /**
067:             * Returns the fully qualified name of the resource output to be written, this means: <ul> <li>the output pattern
068:             * has been translated</li> <li>the output directory name has been prepended</li> </ul>
069:             *
070:             * @param arguments any arguments to be inserted into the MessageFormat style messages.
071:             * @param directory the directory to which output will be written.
072:             * @param outputPattern if undefined, the value of {@link #getOutputPattern()} will be used.
073:             * @return File absolute directory.
074:             */
075:            public File getOutputLocation(final Object[] arguments,
076:                    final File directory, String outputPattern) {
077:                File file = null;
078:
079:                // - clean any whitespace off the arguments
080:                if (directory != null && arguments != null
081:                        && arguments.length > 0) {
082:                    for (int ctr = 0; ctr < arguments.length; ctr++) {
083:                        arguments[ctr] = StringUtils.trimToEmpty(String
084:                                .valueOf(arguments[ctr]));
085:                    }
086:                    if (outputPattern == null
087:                            || outputPattern.trim().length() == 0) {
088:                        outputPattern = this .getOutputPattern();
089:                    }
090:                    String outputFileName;
091:                    try {
092:                        outputFileName = MessageFormat.format(outputPattern,
093:                                arguments);
094:                    } catch (final Exception exception) {
095:                        // - means the output pattern can't be parsed (but we still 
096:                        //   want to output the bad path anyway)
097:                        outputFileName = outputPattern;
098:                    }
099:                    file = new File(directory, outputFileName);
100:                }
101:                return file;
102:            }
103:
104:            /**
105:             * Stores whether or not the resource should be overwritten.
106:             */
107:            private boolean overwrite = false;
108:
109:            /**
110:             * Tells us whether output files produced by this resource should be overwritten if they already exist. Overwriting
111:             * can be turned on and off for entire cartridges by setting the <code>overwrite</code> property in a namespace.
112:             * This is useful for cartridge developers when they always want produced resources to be overwritten at first.
113:             *
114:             * @return Returns the overwrite.
115:             */
116:            public boolean isOverwrite() {
117:                final Property property = Namespaces.instance().getProperty(
118:                        this .getCartridge().getNamespace(),
119:                        NamespaceProperties.OVERWRITE, false);
120:                if (property != null) {
121:                    this .overwrite = Boolean.valueOf(property.getValue())
122:                            .booleanValue();
123:                }
124:                return this .overwrite;
125:            }
126:
127:            /**
128:             * Sets whether output files produced by this resource should be overwritten if they already exist.
129:             *
130:             * @param overwrite The overwrite to set.
131:             */
132:            public void setOverwrite(final boolean overwrite) {
133:                this .overwrite = overwrite;
134:            }
135:
136:            /**
137:             * Whether or not a last modified check should be performed before writing the resource.
138:             */
139:            private boolean lastModifiedCheck;
140:
141:            /**
142:             * Sets whether or not a last modified check should be performed before writing the resource.
143:             * 
144:             * @param lastModifiedCheck true/false
145:             */
146:            public void setLastModifiedCheck(final boolean lastModifiedCheck) {
147:                this .lastModifiedCheck = lastModifiedCheck;
148:            }
149:
150:            /**
151:             * Whether or not a last modified check should be performed before writing the resource.
152:             * 
153:             * @return true/false
154:             */
155:            public boolean isLastModifiedCheck() {
156:                return this .lastModifiedCheck;
157:            }
158:
159:            /**
160:             * Store the path to a cartridge resource.
161:             */
162:            private String path;
163:
164:            /**
165:             * Gets the path to the cartridge resource.
166:             *
167:             * @return Returns the path.
168:             */
169:            public String getPath() {
170:                return this .path;
171:            }
172:
173:            /**
174:             * Sets the path to the cartridge resource.
175:             *
176:             * @param path The path to set.
177:             */
178:            public void setPath(final String path) {
179:                this .path = path;
180:            }
181:
182:            /**
183:             * Stores the cartridge that owns this resource.
184:             */
185:            private Cartridge cartridge;
186:
187:            /**
188:             * The cartridge that owns this resource.
189:             *
190:             * @return Returns the owning cartridge.
191:             */
192:            public Cartridge getCartridge() {
193:                return this .cartridge;
194:            }
195:
196:            /**
197:             * Sets the Cartridge parent to which this Resource belongs.
198:             *
199:             * @param cartridge the parent Cartridge to set.
200:             */
201:            public void setCartridge(final Cartridge cartridge) {
202:                this .cartridge = cartridge;
203:            }
204:
205:            /**
206:             * Stores the output pattern for which the resource(s) should be written.
207:             */
208:            private String outputPattern;
209:
210:            /**
211:             * Sets the pattern that is used to build the name of the output file.
212:             *
213:             * @param outputPattern the pattern in java.text.MessageFormat syntax
214:             */
215:            public void setOutputPattern(final String outputPattern) {
216:                this .outputPattern = outputPattern;
217:            }
218:
219:            /**
220:             * Gets the pattern that is used to build the name of the output file.
221:             *
222:             * @return String the pattern in java.text.MessageFormat syntax
223:             */
224:            public String getOutputPattern() {
225:                return StringUtils.trimToEmpty(this.outputPattern);
226:            }
227:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.