Source Code Cross Referenced for IVUrl.java in  » Ajax » Laszlo-4.0.10 » org » openlaszlo » iv » flash » url » 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 » Ajax » Laszlo 4.0.10 » org.openlaszlo.iv.flash.url 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: IVUrl.java,v 1.9 2002/07/15 02:15:03 skavish Exp $
003:         *
004:         * ==========================================================================
005:         *
006:         * The JGenerator Software License, Version 1.0
007:         *
008:         * Copyright (c) 2000-2007 Dmitry Skavish (skavish@usa.net). All rights reserved.
009:         *
010:         * Redistribution and use in source and binary forms, with or without
011:         * modification, are permitted provided that the following conditions are met:
012:         *
013:         * 1. Redistributions of source code must retain the above copyright
014:         *    notice, this list of conditions and the following disclaimer.
015:         *
016:         * 2. Redistributions in binary form must reproduce the above copyright
017:         *    notice, this list of conditions and the following disclaimer in
018:         *    the documentation and/or other materials provided with the
019:         *    distribution.
020:         *
021:         * 3. The end-user documentation included with the redistribution, if
022:         *    any, must include the following acknowlegement:
023:         *    "This product includes software developed by Dmitry Skavish
024:         *     (skavish@usa.net, http://www.flashgap.com/)."
025:         *    Alternately, this acknowlegement may appear in the software itself,
026:         *    if and wherever such third-party acknowlegements normally appear.
027:         *
028:         * 4. The name "The JGenerator" must not be used to endorse or promote
029:         *    products derived from this software without prior written permission.
030:         *    For written permission, please contact skavish@usa.net.
031:         *
032:         * 5. Products derived from this software may not be called "The JGenerator"
033:         *    nor may "The JGenerator" appear in their names without prior written
034:         *    permission of Dmitry Skavish.
035:         *
036:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
037:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
038:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
039:         * DISCLAIMED.  IN NO EVENT SHALL DMITRY SKAVISH OR THE OTHER
040:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
041:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
042:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
043:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
044:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
045:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
046:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
047:         * SUCH DAMAGE.
048:         *
049:         */
050:
051:        package org.openlaszlo.iv.flash.url;
052:
053:        import java.io.*;
054:        import java.net.*;
055:        import java.util.*;
056:        import org.openlaszlo.iv.flash.api.*;
057:        import org.openlaszlo.iv.flash.util.*;
058:
059:        /**
060:         * Abstract generator url
061:         * <p>
062:         * Usage example:<br>
063:         * <pre><code>
064:         * // creates url to file 'data.txt' in the same directory where 'file' is
065:         * IVUrl url = IVUrl.newUrl( "data.txt", file );
066:         *
067:         * // creates url to http://server/getdata.cgi
068:         * IVUrl url = IVUrl.newUrl( "http://server/getdata.cgi?parm=text" );
069:         *
070:         * </code></pre>
071:         */
072:        public abstract class IVUrl {
073:
074:            public static final String ENCODING = "genc";
075:            //private static IVVector handlers = new IVVector();
076:
077:            protected Hashtable parms;
078:
079:            /**
080:             * Creates new url from specified string
081:             *
082:             * @param surl   absolute url
083:             * @return generator url
084:             * @exception IVException
085:             */
086:            public static IVUrl newUrl(String surl) throws IVException {
087:                return newUrl(surl, null);
088:            }
089:
090:            /**
091:             * Creates new url relative from specified file
092:             *
093:             * @param surl   relative or absolute url
094:             * @return generator url
095:             * @exception IVException
096:             */
097:            public static IVUrl newUrl(String surl, FlashFile flashFile)
098:                    throws IVException {
099:                if (surl.startsWith("fgjdbc:///")) {
100:                    return new JDBCUrl(surl);
101:                } else if (surl.startsWith("fgjava:///")) {
102:                    return new JavaUrl(surl);
103:                } else if (surl.startsWith("fgjs:///")) {
104:                    // return new JSUrl( surl, flashFile );
105:                    try {
106:                        return (IVUrl) Util.newInstance(
107:                                "org.openlaszlo.iv.flash.url.JSUrl",
108:                                new Class[] { String.class, FlashFile.class },
109:                                new Object[] { surl, flashFile });
110:                    } catch (Exception e) {
111:                        throw new IVException(e);
112:                    }
113:                } else if (surl.startsWith("fgfilter:///")) {
114:                    return new FilterUrl(surl, flashFile);
115:                } else {
116:                    try {
117:                        URL url = new URL(surl);
118:                        return new URLUrl(url);
119:                    } catch (MalformedURLException e) {
120:                        return new FileUrl(surl, flashFile);
121:                    }
122:                }
123:            }
124:
125:            /**
126:             * Returns name of the url.
127:             *
128:             * @return name of this url
129:             */
130:            public abstract String getName();
131:
132:            /**
133:             * Returns input stream for this url
134:             *
135:             * @return url input stream
136:             * @exception Exception
137:             */
138:            public abstract InputStream getInputStream() throws IOException;
139:
140:            /**
141:             * Returns parameter of the url by name
142:             * <p>
143:             * Parameters are standard url parameters like 'parm' in: http://server/getdata.cgi?parm=text
144:             *
145:             * @param name   parameter name
146:             * @return parameter value or null
147:             */
148:            public String getParameter(String name) {
149:                if (parms == null)
150:                    return null;
151:                return (String) parms.get(name.toLowerCase());
152:            }
153:
154:            /**
155:             * Returns timestamp of last time this url was modified
156:             *
157:             * @return last modified time
158:             */
159:            public long lastModified() {
160:                return 0;
161:            }
162:
163:            /**
164:             * Refreshes this url. Updates last modified.
165:             */
166:            public void refresh() {
167:            }
168:
169:            /**
170:             * Returns encoding taken from parameters of this url if it
171:             * was specified.
172:             *
173:             * @return specified in this url encoding or null
174:             */
175:            public String getEncoding() {
176:                return getParameter(ENCODING);
177:            }
178:
179:            /**
180:             * Returns true if this url can provide data in name,value format right away
181:             * without parsing input stream. If returns true must implement {@link #getData} too.
182:             * @see #getData
183:             */
184:            public boolean hasDataReady() {
185:                return false;
186:            }
187:
188:            /**
189:             * Returns data in name,value format ready to be used.
190:             * @see #hasDataReady
191:             */
192:            public String[][] getData() throws IOException {
193:                return null;
194:            }
195:
196:            public String toString() {
197:                return getName();
198:            }
199:
200:            /**
201:             * Returns url reference (the part of url after #)
202:             *
203:             * @return reference
204:             */
205:            public String getRef() {
206:                return null;
207:            }
208:
209:            /**
210:             * Parses parameters of url-string
211:             * <p>
212:             * Parameters are pairs: name=value, separated by ampersand
213:             *
214:             * @param s      url
215:             */
216:            protected void parse(String s) throws IVException {
217:                int idx = s.indexOf('?');
218:                if (idx >= 0)
219:                    parse(s, idx);
220:            }
221:
222:            /**
223:             * Parses parameters of url-string begining after the specified index (usually index of '?')
224:             * <p>
225:             * Parameters are pairs: name=value, separated by ampersand
226:             *
227:             * @param s      url
228:             */
229:            protected void parse(String s, int idx) {
230:                parms = Util.parseUrlParms(s, idx);
231:            }
232:
233:            /**
234:             * Converts specified two-dimensional array of strings into InputStream
235:             *
236:             * @param data   specified array
237:             * @return input stream
238:             */
239:            protected InputStream arrayToStream(String[][] data) {
240:                StringBuffer sb = new StringBuffer(data.length * data[0].length
241:                        * 10);
242:                for (int i = 0; i < data.length; i++) {
243:                    int ilen = data[i].length;
244:                    for (int j = 0; j < ilen; j++) {
245:                        String s = data[i][j];
246:                        if (s == null)
247:                            sb.append("\"\"");
248:                        else {
249:                            sb.append("\"");
250:                            sb.append(s);
251:                            sb.append("\"");
252:                        }
253:                        if (j + 1 < ilen)
254:                            sb.append(',');
255:                    }
256:                    sb.append('\n');
257:                }
258:                String str = new String(sb);
259:                return new ByteArrayInputStream(str.getBytes());
260:            }
261:
262:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.