Source Code Cross Referenced for JarURLConnection.java in  » Apache-Harmony-Java-SE » java-package » java » net » 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 » Apache Harmony Java SE » java package » java.net 
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 java.net;
019:
020:        import java.io.IOException;
021:        import java.security.cert.Certificate;
022:        import java.util.jar.Attributes;
023:        import java.util.jar.JarEntry;
024:        import java.util.jar.JarFile;
025:        import java.util.jar.Manifest;
026:
027:        /**
028:         * This class establishes a connection to a URL using the jar protocol. Jar URLs
029:         * are specified as follows: <center><code>jar:<url>!/{entry}</code></center>
030:         * where "!/" is called a seperator.
031:         */
032:        public abstract class JarURLConnection extends URLConnection {
033:
034:            // the location of the separator
035:            protected URLConnection jarFileURLConnection;
036:
037:            private String entryName;
038:
039:            private URL fileURL;
040:
041:            // the file component of the URL
042:            private String file;
043:
044:            /**
045:             * Constructs an instance of <code>JarURLConnection</code>.
046:             * 
047:             * @param url
048:             *            java.net.URL the URL that contains the location to connect to
049:             */
050:            protected JarURLConnection(URL url) throws MalformedURLException {
051:                super (url);
052:                file = url.getFile();
053:                int sepIdx;
054:                if ((sepIdx = file.indexOf("!/")) < 0) { //$NON-NLS-1$
055:                    throw new MalformedURLException();
056:                }
057:                fileURL = new URL(url.getFile().substring(0, sepIdx)); //$NON-NLS-1$
058:                sepIdx += 2;
059:                if (file.length() == sepIdx) {
060:                    return;
061:                }
062:                entryName = file.substring(sepIdx, file.length());
063:                if (null != url.getRef()) {
064:                    entryName += "#" + url.getRef(); //$NON-NLS-1$
065:                }
066:            }
067:
068:            /**
069:             * Answers the attributes of the JarEntry referenced by this
070:             * <code>JarURLConnection</code>.
071:             * 
072:             * @return java.util.jar.Attributes the attributes of the the JarEntry
073:             * @exception java.io.IOException
074:             *                thrown if an IO exception occurs while retrieving the
075:             *                JarEntry
076:             */
077:            public Attributes getAttributes() throws java.io.IOException {
078:                JarEntry jEntry = getJarEntry();
079:                return (jEntry == null) ? null : jEntry.getAttributes();
080:            }
081:
082:            /**
083:             * Answers the Certificates of the JarEntry referenced by this
084:             * <code>URLConnection</code>. This method will return null until the
085:             * InputStream has been completely verified
086:             * 
087:             * @return Certificate[] the Certificates of the JarEntry.
088:             * @exception java.io.IOException
089:             *                thrown if there is an IO exception occurs while getting
090:             *                the JarEntry.
091:             */
092:            public Certificate[] getCertificates() throws java.io.IOException {
093:                JarEntry jEntry = getJarEntry();
094:                if (jEntry == null) {
095:                    return null;
096:                }
097:
098:                return jEntry.getCertificates();
099:            }
100:
101:            /**
102:             * Answers the JarEntry name of the entry referenced by this
103:             * <code>URLConnection</code>.
104:             * 
105:             * @return java.lang.String the JarEntry name
106:             */
107:            public String getEntryName() {
108:                return entryName;
109:            }
110:
111:            /**
112:             * Answers the JarEntry of the entry referenced by this
113:             * <code>URLConnection</code>.
114:             * 
115:             * @return java.util.jar.JarEntry the JarEntry referenced
116:             */
117:            public JarEntry getJarEntry() throws IOException {
118:                if (!connected) {
119:                    connect();
120:                }
121:                if (entryName == null) {
122:                    return null;
123:                }
124:                // The entry must exist since the connect succeeded
125:                return getJarFile().getJarEntry(entryName);
126:            }
127:
128:            /**
129:             * Answers the Manifest associated with the Jar URL
130:             * 
131:             * @return java.util.jar.Manifest The JarFile's Manifest
132:             */
133:            public Manifest getManifest() throws java.io.IOException {
134:                return (Manifest) getJarFile().getManifest().clone();
135:            }
136:
137:            /**
138:             * Answers the the JarFile referenced by this <code>URLConnection</code>.
139:             * 
140:             * @return java.util.jar.JarFile the JarFile
141:             * @exception java.io.IOException
142:             *                thrown if an IO exception occurs while retrieving the Jar
143:             *                file
144:             */
145:            public abstract JarFile getJarFile() throws java.io.IOException;
146:
147:            /**
148:             * Answers the URL of the JarFile referenced by this
149:             * <code>URLConnection</code>.
150:             * 
151:             * @return java.net.URL the URL of the JarFile.
152:             */
153:            public URL getJarFileURL() {
154:                return fileURL;
155:            }
156:
157:            /**
158:             * Answers the main Attributes of the JarFile referenced by this
159:             * <code>URLConnection</code>.
160:             * 
161:             * @return java.util.jar.Attributes the Attributes of the the JarFile
162:             * @exception java.io.IOException
163:             *                thrown if an IO exception occurs while retrieving the
164:             *                JarFile
165:             */
166:            public Attributes getMainAttributes() throws java.io.IOException {
167:                Manifest m = getJarFile().getManifest();
168:                return (m == null) ? null : m.getMainAttributes();
169:            }
170:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.