Source Code Cross Referenced for TransientLocator.java in  » PDF » jPod » de » intarsys » tools » locator » 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 » PDF » jPod » de.intarsys.tools.locator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2007, intarsys consulting GmbH
003:         *
004:         * Redistribution and use in source and binary forms, with or without
005:         * modification, are permitted provided that the following conditions are met:
006:         *
007:         * - Redistributions of source code must retain the above copyright notice,
008:         *   this list of conditions and the following disclaimer.
009:         *
010:         * - Redistributions in binary form must reproduce the above copyright notice,
011:         *   this list of conditions and the following disclaimer in the documentation
012:         *   and/or other materials provided with the distribution.
013:         *
014:         * - Neither the name of intarsys nor the names of its contributors may be used
015:         *   to endorse or promote products derived from this software without specific
016:         *   prior written permission.
017:         *
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021:         * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
022:         * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023:         * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
024:         * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
025:         * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
026:         * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
027:         * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
028:         * POSSIBILITY OF SUCH DAMAGE.
029:         */
030:        package de.intarsys.tools.locator;
031:
032:        import java.io.FileNotFoundException;
033:        import java.io.IOException;
034:        import java.io.InputStream;
035:        import java.io.OutputStream;
036:        import java.io.Reader;
037:        import java.io.Writer;
038:        import java.net.URL;
039:
040:        import de.intarsys.tools.file.FileTools;
041:        import de.intarsys.tools.randomaccess.IRandomAccess;
042:
043:        /**
044:         * A "non persistent" locator. This is used as a placeholder where an
045:         * {@link ILocator} is necessary but no real location is yet defined.
046:         */
047:        public class TransientLocator extends CommonLocator {
048:            private boolean alwaysUnchanged;
049:
050:            private String canonicalName;
051:
052:            private String localName;
053:
054:            private String type;
055:
056:            public TransientLocator(String name, String type) {
057:                if ((name == null) || (type == null)) {
058:                    throw new NullPointerException(
059:                            "name and type may not be null for TransientLocator");
060:                }
061:                this .localName = name;
062:                this .canonicalName = canonical(name);
063:                this .type = canonical(type);
064:            }
065:
066:            private String canonical(String name) {
067:                return name.trim().toLowerCase();
068:            }
069:
070:            /*
071:             * (non-Javadoc)
072:             * 
073:             * @see java.lang.Object#equals(java.lang.Object)
074:             */
075:            public boolean equals(Object obj) {
076:                if (obj instanceof  TransientLocator) {
077:                    TransientLocator other = (TransientLocator) obj;
078:                    return other.canonicalName.equals(canonicalName)
079:                            && other.type.equals(type);
080:                }
081:                return false;
082:            }
083:
084:            /*
085:             * (non-Javadoc)
086:             * 
087:             * @see de.intarsys.tools.locator.ILocator#exists()
088:             */
089:            public boolean exists() {
090:                return false;
091:            }
092:
093:            /*
094:             * (non-Javadoc)
095:             * 
096:             * @see de.intarsys.tools.locator.ILocator#getChild(java.lang.String)
097:             */
098:            public ILocator getChild(String name) {
099:                return null;
100:            }
101:
102:            /*
103:             * (non-Javadoc)
104:             * 
105:             * @see de.intarsys.tools.locator.ILocator#getFullName()
106:             */
107:            public String getFullName() {
108:                return localName + "." + type;
109:            }
110:
111:            /*
112:             * (non-Javadoc)
113:             * 
114:             * @see de.intarsys.tools.locator.ILocator#getInputStream()
115:             */
116:            public InputStream getInputStream() throws IOException {
117:                throw new FileNotFoundException("transient locator");
118:            }
119:
120:            /*
121:             * (non-Javadoc)
122:             * 
123:             * @see de.intarsys.tools.locator.ILocator#getLocalName()
124:             */
125:            public String getLocalName() {
126:                return localName;
127:            }
128:
129:            /*
130:             * (non-Javadoc)
131:             * 
132:             * @see de.intarsys.tools.locator.ILocator#getOutputStream()
133:             */
134:            public OutputStream getOutputStream() throws IOException {
135:                throw new FileNotFoundException("transient locator");
136:            }
137:
138:            /*
139:             * (non-Javadoc)
140:             * 
141:             * @see de.intarsys.tools.locator.ILocator#getParent()
142:             */
143:            public ILocator getParent() {
144:                return null;
145:            }
146:
147:            /*
148:             * (non-Javadoc)
149:             * 
150:             * @see de.intarsys.tools.locator.ILocator#getRandomAccess()
151:             */
152:            public IRandomAccess getRandomAccess() throws IOException {
153:                throw new FileNotFoundException("transient locator");
154:            }
155:
156:            /*
157:             * (non-Javadoc)
158:             * 
159:             * @see de.intarsys.tools.locator.ILocator#getReader()
160:             */
161:            public Reader getReader() throws IOException {
162:                throw new FileNotFoundException("transient locator");
163:            }
164:
165:            /*
166:             * (non-Javadoc)
167:             * 
168:             * @see de.intarsys.tools.locator.ILocator#getReader(java.lang.String)
169:             */
170:            public Reader getReader(String encoding) throws IOException {
171:                throw new FileNotFoundException("transient locator");
172:            }
173:
174:            /*
175:             * (non-Javadoc)
176:             * 
177:             * @see de.intarsys.tools.locator.ILocator#getType()
178:             */
179:            public String getType() {
180:                return type;
181:            }
182:
183:            /*
184:             * (non-Javadoc)
185:             * 
186:             * @see de.intarsys.tools.locator.ILocator#getTypedName()
187:             */
188:            public String getTypedName() {
189:                return localName + "." + type;
190:            }
191:
192:            /*
193:             * (non-Javadoc)
194:             * 
195:             * @see de.intarsys.tools.locator.ILocator#getWriter()
196:             */
197:            public Writer getWriter() throws IOException {
198:                throw new FileNotFoundException("transient locator");
199:            }
200:
201:            /*
202:             * (non-Javadoc)
203:             * 
204:             * @see de.intarsys.tools.locator.ILocator#getWriter(java.lang.String)
205:             */
206:            public Writer getWriter(String encoding) throws IOException {
207:                throw new FileNotFoundException("transient locator");
208:            }
209:
210:            /*
211:             * (non-Javadoc)
212:             * 
213:             * @see java.lang.Object#hashCode()
214:             */
215:            public int hashCode() {
216:                return canonicalName.hashCode();
217:            }
218:
219:            public boolean isAlwaysUnchanged() {
220:                return alwaysUnchanged;
221:            }
222:
223:            /*
224:             * (non-Javadoc)
225:             * 
226:             * @see de.intarsys.tools.locator.ILocator#isDirectory()
227:             */
228:            public boolean isDirectory() {
229:                return false;
230:            }
231:
232:            /*
233:             * (non-Javadoc)
234:             * 
235:             * @see de.intarsys.tools.component.ISynchronizable#isOutOfSynch()
236:             */
237:            public boolean isOutOfSynch() {
238:                return false;
239:            }
240:
241:            /*
242:             * (non-Javadoc)
243:             * 
244:             * @see de.intarsys.tools.locator.ILocator#isReadOnly()
245:             */
246:            public boolean isReadOnly() {
247:                return true;
248:            }
249:
250:            /*
251:             * (non-Javadoc)
252:             * 
253:             * @see de.intarsys.tools.component.ISynchronizable#isSynchSynchronous()
254:             */
255:            public boolean isSynchSynchronous() {
256:                return false;
257:            }
258:
259:            /*
260:             * (non-Javadoc)
261:             * 
262:             * @see de.intarsys.tools.locator.ILocator#listLocators(de.intarsys.tools.locator.ILocatorNameFilter)
263:             */
264:            public ILocator[] listLocators(ILocatorNameFilter filter)
265:                    throws IOException {
266:                return new ILocator[0];
267:            }
268:
269:            public void rename(String newName) throws IOException {
270:                localName = FileTools.getBaseName(newName);
271:                type = FileTools.getExtension(newName);
272:            }
273:
274:            public void setAlwaysUnchanged(boolean paramAlwaysUnchanged) {
275:                alwaysUnchanged = paramAlwaysUnchanged;
276:            }
277:
278:            public void setLocalName(String name) {
279:                this .localName = name;
280:                this .canonicalName = canonical(name);
281:            }
282:
283:            /*
284:             * (non-Javadoc)
285:             * 
286:             * @see de.intarsys.tools.component.ISynchronizable#synch()
287:             */
288:            public void synch() {
289:                // no op
290:            }
291:
292:            /*
293:             * (non-Javadoc)
294:             * 
295:             * @see de.intarsys.tools.locator.ILocator#toURL()
296:             */
297:            public URL toURL() {
298:                return null;
299:            }
300:
301:            public void delete() throws IOException {
302:                // nothing to do...
303:            }
304:
305:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.