Source Code Cross Referenced for DotnetResource.java in  » Build » ANT » org » apache » tools » ant » taskdefs » optional » dotnet » 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 » Build » ANT » org.apache.tools.ant.taskdefs.optional.dotnet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:        package org.apache.tools.ant.taskdefs.optional.dotnet;
019:
020:        import org.apache.tools.ant.BuildException;
021:
022:        import java.io.File;
023:        import java.util.ArrayList;
024:        import org.apache.tools.ant.types.FileSet;
025:        import java.util.Iterator;
026:        import org.apache.tools.ant.Project;
027:        import org.apache.tools.ant.DirectoryScanner;
028:
029:        /**
030:         * Used by {@link DotnetCompile} to name resources.
031:         * Could be upgraded to a datatype in the distant future.
032:         * A resource maps to /res:file,name
033:         */
034:        public class DotnetResource {
035:
036:            /**
037:             * name of resource
038:             */
039:            private File file;
040:
041:            /**
042:             * embed (default) or link the resource
043:             */
044:            private boolean embed = true;
045:
046:            /**
047:             * this is used in VBC and JSC
048:             */
049:            private Boolean isPublic = null;
050:
051:            /**
052:             * name of the object
053:             */
054:            private String name = null;
055:
056:            /**
057:             * A list of filesets with resources.
058:             */
059:            private ArrayList fileSets = new ArrayList();
060:
061:            /**
062:             * a namespace to be used with <filesets>
063:             */
064:            private String namespace = null;
065:
066:            /**
067:             * Return the embed attribute.
068:             * @return the embed value.
069:             */
070:            public boolean isEmbed() {
071:                return embed;
072:            }
073:
074:            /**
075:             * embed the resource in the assembly (default, true) or just link to it.
076:             *
077:             * @param embed a <code>boolean</code> value.
078:             */
079:            public void setEmbed(boolean embed) {
080:                this .embed = embed;
081:            }
082:
083:            /**
084:             * The file resource.
085:             * @return the file resource.
086:             */
087:            public File getFile() {
088:                return file;
089:            }
090:
091:            /**
092:             * name the resource
093:             *
094:             * @param file the file.
095:             */
096:            public void setFile(File file) {
097:                this .file = file;
098:            }
099:
100:            /**
101:             * Get the public attribute.
102:             * @return the public attribute.
103:             */
104:            public Boolean getPublic() {
105:                return isPublic;
106:            }
107:
108:            /**
109:             * VB and J# only: is a resource public or not?
110:             *
111:             * @param aPublic a <code>boolean</code> value.
112:             */
113:            public void setPublic(Boolean aPublic) {
114:                isPublic = aPublic;
115:            }
116:
117:            /**
118:             * The name of the resource.
119:             * @return the name of the resource.
120:             */
121:            public String getName() {
122:                return name;
123:            }
124:
125:            /**
126:             * should the resource have a name?
127:             *
128:             * @param name the name of the resource.
129:             */
130:            public void setName(String name) {
131:                this .name = name;
132:            }
133:
134:            /**
135:             * Filesets root namespace. The value always ends with '.' .
136:             *
137:             * @return String namespace name
138:             */
139:            public String getNamespace() {
140:                return namespace;
141:            }
142:
143:            /**
144:             * Sets filesets root namespace.
145:             *
146:             * @param namespace
147:             *            String root namespace
148:             */
149:            public void setNamespace(String namespace) {
150:                if (namespace == null) {
151:                    this .namespace = null;
152:                } else {
153:                    this .namespace = (namespace.length() == 0
154:                            || namespace.endsWith(".") ? namespace
155:                            : namespace + '.');
156:                }
157:            }
158:
159:            private void checkParameters() {
160:                if (hasFilesets()) {
161:                    if (getName() != null) {
162:                        throw new BuildException(
163:                                "Cannot use <resource name=\"...\"> attribute with filesets");
164:                    }
165:                    if (getFile() != null) {
166:                        throw new BuildException(
167:                                "Cannot use <resource file=\"...\"> attribute with filesets");
168:                    }
169:                } else {
170:                    if (getNamespace() != null) {
171:                        throw new BuildException(
172:                                "Cannot use <resource namespace=\"...\"> attribute without filesets");
173:                    }
174:                }
175:            }
176:
177:            /**
178:             * build the C# style parameter (which has no public/private option)
179:             * @param p the current project.
180:             * @param command the command.
181:             * @param csharpStyle a <code>boolean</code> attribute.
182:             */
183:            public void getParameters(Project p, NetCommand command,
184:                    boolean csharpStyle) {
185:                checkParameters();
186:                if (hasFilesets()) {
187:                    for (Iterator listIter = fileSets.iterator(); listIter
188:                            .hasNext();) {
189:                        FileSet fs = (FileSet) listIter.next();
190:                        String baseDirectory = fs.getDir(p).toString();
191:                        String namespace = getNamespace(); // ends with '.' or null
192:                        DirectoryScanner ds = fs.getDirectoryScanner(p);
193:                        String[] files = ds.getIncludedFiles();
194:                        for (int i = 0; i < files.length; i++) {
195:                            String file = files[i];
196:                            command.addArgument(getParameter(baseDirectory
197:                                    + File.separatorChar + file,
198:                                    (namespace == null ? null : namespace
199:                                            + file.replace(File.separatorChar,
200:                                                    '.')), csharpStyle));
201:                        }
202:                    }
203:                } else {
204:                    command.addArgument(getParameter(getFile().toString(),
205:                            getName(), csharpStyle));
206:                }
207:            }
208:
209:            private String getParameter(String fileName, String name,
210:                    boolean csharpStyle) {
211:                StringBuffer buffer = new StringBuffer();
212:                buffer.append(isEmbed() ? "/resource" : "/linkresource");
213:                buffer.append(':');
214:                buffer.append(fileName);
215:                if (name != null) {
216:                    buffer.append(',');
217:                    buffer.append(name);
218:                    if (csharpStyle) {
219:                        if (getPublic() != null) {
220:                            throw new BuildException(
221:                                    "This compiler does not support the "
222:                                            + "public/private option.");
223:                        } else {
224:                            if (getPublic() != null) {
225:                                buffer.append(',');
226:                                buffer
227:                                        .append(getPublic().booleanValue() ? "public"
228:                                                : "private");
229:
230:                            }
231:                        }
232:                    } else if (getPublic() != null) {
233:                        throw new BuildException(
234:                                "You cannot have a public or private "
235:                                        + "option without naming the resource");
236:                    }
237:                }
238:                return buffer.toString();
239:            }
240:
241:            /**
242:             * Adds a resource file set.
243:             *
244:             * @param fileset
245:             *            FileSet
246:             */
247:            public void addFileset(FileSet fileset) {
248:                fileSets.add(fileset);
249:            }
250:
251:            /**
252:             * Checks that <resource> node has embedded <filesets>
253:             *
254:             * @return boolean
255:             */
256:            public boolean hasFilesets() {
257:                return fileSets.size() > 0;
258:            }
259:        }
www___.___j_a___v_a___2s___.__c_om__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.