golf 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/golf.gemspec +1 -1
- data/lib/golf/version.rb +1 -1
- metadata +1 -121
- data/golf-java/README.markdown +0 -41
- data/golf-java/THANKS.markdown +0 -14
- data/golf-java/build/classes.zip +0 -0
- data/golf-java/build/com/thinkminimo/golf/GolfResource$MimeMapping$MimeMappingSingleton.class +0 -0
- data/golf-java/build/com/thinkminimo/golf/GolfResource$MimeMapping.class +0 -0
- data/golf-java/build/com/thinkminimo/golf/GolfResource.class +0 -0
- data/golf-java/build/com/thinkminimo/golf/GolfServlet$1.class +0 -0
- data/golf-java/build/com/thinkminimo/golf/GolfServlet$GolfContext.class +0 -0
- data/golf-java/build/com/thinkminimo/golf/GolfServlet$GolfParams.class +0 -0
- data/golf-java/build/com/thinkminimo/golf/GolfServlet$GolfSession.class +0 -0
- data/golf-java/build/com/thinkminimo/golf/GolfServlet$PermanentRedirectException.class +0 -0
- data/golf-java/build/com/thinkminimo/golf/GolfServlet$RedirectException.class +0 -0
- data/golf-java/build/com/thinkminimo/golf/GolfServlet$StoredJSVM.class +0 -0
- data/golf-java/build/com/thinkminimo/golf/GolfServlet.class +0 -0
- data/golf-java/build/com/thinkminimo/golf/JsonpTunnel.class +0 -0
- data/golf-java/build/com/thinkminimo/golf/Main$1.class +0 -0
- data/golf-java/build/com/thinkminimo/golf/Main$RingList.class +0 -0
- data/golf-java/build/com/thinkminimo/golf/Main.class +0 -0
- data/golf-java/build/com/thinkminimo/golf/ProxyServlet.class +0 -0
- data/golf-java/build/com/yahoo/platform/yui/compressor/CssCompressor.class +0 -0
- data/golf-java/build/com/yahoo/platform/yui/compressor/JarClassLoader.class +0 -0
- data/golf-java/build/com/yahoo/platform/yui/compressor/JavaScriptCompressor.class +0 -0
- data/golf-java/build/com/yahoo/platform/yui/compressor/JavaScriptIdentifier.class +0 -0
- data/golf-java/build/com/yahoo/platform/yui/compressor/JavaScriptToken.class +0 -0
- data/golf-java/build/com/yahoo/platform/yui/compressor/ScriptOrFnScope.class +0 -0
- data/golf-java/build/depends.zip +0 -0
- data/golf-java/build/golf +0 -2
- data/golf-java/build/org/json/JSONArray.class +0 -0
- data/golf-java/build/org/json/JSONException.class +0 -0
- data/golf-java/build/org/json/JSONObject$1.class +0 -0
- data/golf-java/build/org/json/JSONObject$Null.class +0 -0
- data/golf-java/build/org/json/JSONObject.class +0 -0
- data/golf-java/build/org/json/JSONString.class +0 -0
- data/golf-java/build/org/json/JSONStringer.class +0 -0
- data/golf-java/build/org/json/JSONTokener.class +0 -0
- data/golf-java/build/org/json/JSONWriter.class +0 -0
- data/golf-java/build/resources.zip +0 -0
- data/golf-java/build.xml +0 -174
- data/golf-java/dist/golf.zip +0 -0
- data/golf-java/lib/ant-launcher.jar +0 -0
- data/golf-java/lib/ant.jar +0 -0
- data/golf-java/lib/commons-codec-1.4.jar +0 -0
- data/golf-java/lib/commons-collections-3.2.1.jar +0 -0
- data/golf-java/lib/commons-fileupload-1.2.1.jar +0 -0
- data/golf-java/lib/commons-httpclient-3.1.jar +0 -0
- data/golf-java/lib/commons-io-1.4.jar +0 -0
- data/golf-java/lib/commons-lang-2.4.jar +0 -0
- data/golf-java/lib/commons-logging-1.1.1.jar +0 -0
- data/golf-java/lib/cssparser-0.9.5.jar +0 -0
- data/golf-java/lib/getopt-0.1-dev.jar +0 -0
- data/golf-java/lib/htmlunit-2.6.jar +0 -0
- data/golf-java/lib/htmlunit-core-js-2.6.jar +0 -0
- data/golf-java/lib/java-xmlbuilder-1.jar +0 -0
- data/golf-java/lib/jets3t-0.7.0.jar +0 -0
- data/golf-java/lib/jetty-6.1.15.jar +0 -0
- data/golf-java/lib/jetty-util-6.1.15.jar +0 -0
- data/golf-java/lib/log4j-1.2.15.jar +0 -0
- data/golf-java/lib/nekohtml-1.9.13.jar +0 -0
- data/golf-java/lib/sac-1.3.jar +0 -0
- data/golf-java/lib/serializer-2.7.1.jar +0 -0
- data/golf-java/lib/servlet-api-2.5-20081211.jar +0 -0
- data/golf-java/lib/xalan-2.7.1.jar +0 -0
- data/golf-java/lib/xercesImpl-2.9.1.jar +0 -0
- data/golf-java/lib/xml-apis-1.3.04.jar +0 -0
- data/golf-java/resources/app_error.html +0 -60
- data/golf-java/resources/error.html +0 -29
- data/golf-java/resources/forcebot.txt +0 -0
- data/golf-java/resources/forceclient.txt +0 -0
- data/golf-java/resources/forceproxy.txt +0 -0
- data/golf-java/resources/head.html +0 -0
- data/golf-java/resources/jquery.address.js +0 -439
- data/golf-java/resources/jquery.golf.js +0 -945
- data/golf-java/resources/jquery.js +0 -4376
- data/golf-java/resources/jsdetect.html +0 -23
- data/golf-java/resources/loading.gif +0 -0
- data/golf-java/resources/new.html +0 -45
- data/golf-java/resources/new.static.html +0 -45
- data/golf-java/resources/noscript.forceclient.html +0 -11
- data/golf-java/resources/noscript.html +0 -18
- data/golf-java/resources/noscript.static.html +0 -15
- data/golf-java/resources/project.xml +0 -21
- data/golf-java/resources/proxy_project.xml +0 -11
- data/golf-java/resources/proxy_web.xml +0 -40
- data/golf-java/resources/static_project.xml +0 -37
- data/golf-java/resources/version +0 -1
- data/golf-java/resources/web.xml +0 -36
- data/golf-java/resources/welcome2golf.html +0 -50
- data/golf-java/src/com/thinkminimo/golf/GolfResource.java +0 -582
- data/golf-java/src/com/thinkminimo/golf/GolfServlet.java +0 -1055
- data/golf-java/src/com/thinkminimo/golf/JsonpTunnel.java +0 -86
- data/golf-java/src/com/thinkminimo/golf/Main.java +0 -1299
- data/golf-java/src/com/thinkminimo/golf/ProxyServlet.java +0 -577
- data/golf-java/src/com/yahoo/platform/yui/compressor/CssCompressor.java +0 -188
- data/golf-java/src/com/yahoo/platform/yui/compressor/JarClassLoader.java +0 -158
- data/golf-java/src/com/yahoo/platform/yui/compressor/JavaScriptCompressor.java +0 -1281
- data/golf-java/src/com/yahoo/platform/yui/compressor/JavaScriptIdentifier.java +0 -55
- data/golf-java/src/com/yahoo/platform/yui/compressor/JavaScriptToken.java +0 -28
- data/golf-java/src/com/yahoo/platform/yui/compressor/ScriptOrFnScope.java +0 -160
- data/golf-java/src/org/json/JSONArray.java +0 -934
- data/golf-java/src/org/json/JSONException.java +0 -27
- data/golf-java/src/org/json/JSONObject.java +0 -1550
- data/golf-java/src/org/json/JSONString.java +0 -18
- data/golf-java/src/org/json/JSONStringer.java +0 -78
- data/golf-java/src/org/json/JSONTokener.java +0 -422
- data/golf-java/src/org/json/JSONWriter.java +0 -323
- data/golf-java/test/client/golftest/README.markdown +0 -3
- data/golf-java/test/client/golftest/components/com/thinkminimo/golf/test/Harness.css +0 -114
- data/golf-java/test/client/golftest/components/com/thinkminimo/golf/test/Harness.html +0 -17
- data/golf-java/test/client/golftest/components/com/thinkminimo/golf/test/Harness.js +0 -81
- data/golf-java/test/client/golftest/components/com/thinkminimo/golf/test/Harness.res/asc.gif +0 -0
- data/golf-java/test/client/golftest/components/com/thinkminimo/golf/test/Harness.res/bg.gif +0 -0
- data/golf-java/test/client/golftest/components/com/thinkminimo/golf/test/Harness.res/desc.gif +0 -0
- data/golf-java/test/client/golftest/components/com/thinkminimo/golf/test/Harness.res/test/test.html +0 -1
- data/golf-java/test/client/golftest/controller.js +0 -131
- data/golf-java/test/client/golftest/forceclient.txt +0 -0
- data/golf-java/test/client/golftest/forceproxy.txt +0 -0
- data/golf-java/test/client/golftest/head.html +0 -1
- data/golf-java/test/client/golftest/scripts/jquery.tablesort.js +0 -75
- data/golf-java/test/client/golftest/styles/style.css +0 -18
- data/golf-java/test/client/golftest/test/test.html +0 -1
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* YUI Compressor
|
|
3
|
-
* Author: Julien Lecomte <jlecomte@yahoo-inc.com>
|
|
4
|
-
* Copyright (c) 2007, Yahoo! Inc. All rights reserved.
|
|
5
|
-
* Code licensed under the BSD License:
|
|
6
|
-
* http://developer.yahoo.net/yui/license.txt
|
|
7
|
-
*
|
|
8
|
-
* This code is a port of Isaac Schlueter's cssmin utility.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
package com.yahoo.platform.yui.compressor;
|
|
12
|
-
|
|
13
|
-
import java.io.IOException;
|
|
14
|
-
import java.io.Reader;
|
|
15
|
-
import java.io.Writer;
|
|
16
|
-
import java.util.regex.Pattern;
|
|
17
|
-
import java.util.regex.Matcher;
|
|
18
|
-
|
|
19
|
-
public class CssCompressor {
|
|
20
|
-
|
|
21
|
-
private StringBuffer srcsb = new StringBuffer();
|
|
22
|
-
|
|
23
|
-
public CssCompressor(Reader in) throws IOException {
|
|
24
|
-
// Read the stream...
|
|
25
|
-
int c;
|
|
26
|
-
while ((c = in.read()) != -1) {
|
|
27
|
-
srcsb.append((char) c);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public void compress(Writer out, int linebreakpos)
|
|
32
|
-
throws IOException {
|
|
33
|
-
|
|
34
|
-
Pattern p;
|
|
35
|
-
Matcher m;
|
|
36
|
-
String css;
|
|
37
|
-
StringBuffer sb;
|
|
38
|
-
int startIndex, endIndex;
|
|
39
|
-
|
|
40
|
-
// Remove all comment blocks...
|
|
41
|
-
startIndex = 0;
|
|
42
|
-
boolean iemac = false;
|
|
43
|
-
boolean preserve = false;
|
|
44
|
-
sb = new StringBuffer(srcsb.toString());
|
|
45
|
-
while ((startIndex = sb.indexOf("/*", startIndex)) >= 0) {
|
|
46
|
-
preserve = sb.length() > startIndex + 2 && sb.charAt(startIndex + 2) == '!';
|
|
47
|
-
endIndex = sb.indexOf("*/", startIndex + 2);
|
|
48
|
-
if (endIndex < 0) {
|
|
49
|
-
if (!preserve) {
|
|
50
|
-
sb.delete(startIndex, sb.length());
|
|
51
|
-
}
|
|
52
|
-
} else if (endIndex >= startIndex + 2) {
|
|
53
|
-
if (sb.charAt(endIndex-1) == '\\') {
|
|
54
|
-
// Looks like a comment to hide rules from IE Mac.
|
|
55
|
-
// Leave this comment, and the following one, alone...
|
|
56
|
-
startIndex = endIndex + 2;
|
|
57
|
-
iemac = true;
|
|
58
|
-
} else if (iemac) {
|
|
59
|
-
startIndex = endIndex + 2;
|
|
60
|
-
iemac = false;
|
|
61
|
-
} else if (!preserve) {
|
|
62
|
-
sb.delete(startIndex, endIndex + 2);
|
|
63
|
-
} else {
|
|
64
|
-
startIndex = endIndex + 2;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
css = sb.toString();
|
|
70
|
-
|
|
71
|
-
// Normalize all whitespace strings to single spaces. Easier to work with that way.
|
|
72
|
-
css = css.replaceAll("\\s+", " ");
|
|
73
|
-
|
|
74
|
-
// Make a pseudo class for the Box Model Hack
|
|
75
|
-
css = css.replaceAll("\"\\\\\"}\\\\\"\"", "___PSEUDOCLASSBMH___");
|
|
76
|
-
|
|
77
|
-
// Remove the spaces before the things that should not have spaces before them.
|
|
78
|
-
// But, be careful not to turn "p :link {...}" into "p:link{...}"
|
|
79
|
-
// Swap out any pseudo-class colons with the token, and then swap back.
|
|
80
|
-
sb = new StringBuffer();
|
|
81
|
-
p = Pattern.compile("(^|\\})(([^\\{:])+:)+([^\\{]*\\{)");
|
|
82
|
-
m = p.matcher(css);
|
|
83
|
-
while (m.find()) {
|
|
84
|
-
String s = m.group();
|
|
85
|
-
s = s.replaceAll(":", "___PSEUDOCLASSCOLON___");
|
|
86
|
-
m.appendReplacement(sb, s);
|
|
87
|
-
}
|
|
88
|
-
m.appendTail(sb);
|
|
89
|
-
css = sb.toString();
|
|
90
|
-
css = css.replaceAll("\\s+([!{};:>+\\(\\)\\],])", "$1");
|
|
91
|
-
css = css.replaceAll("___PSEUDOCLASSCOLON___", ":");
|
|
92
|
-
|
|
93
|
-
// Remove the spaces after the things that should not have spaces after them.
|
|
94
|
-
css = css.replaceAll("([!{}:;>+\\(\\[,])\\s+", "$1");
|
|
95
|
-
|
|
96
|
-
// Add the semicolon where it's missing.
|
|
97
|
-
css = css.replaceAll("([^;\\}])}", "$1;}");
|
|
98
|
-
|
|
99
|
-
// Replace 0(px,em,%) with 0.
|
|
100
|
-
css = css.replaceAll("([\\s:])(0)(px|em|%|in|cm|mm|pc|pt|ex)", "$1$2");
|
|
101
|
-
|
|
102
|
-
// Replace 0 0 0 0; with 0.
|
|
103
|
-
css = css.replaceAll(":0 0 0 0;", ":0;");
|
|
104
|
-
css = css.replaceAll(":0 0 0;", ":0;");
|
|
105
|
-
css = css.replaceAll(":0 0;", ":0;");
|
|
106
|
-
// Replace background-position:0; with background-position:0 0;
|
|
107
|
-
css = css.replaceAll("background-position:0;", "background-position:0 0;");
|
|
108
|
-
|
|
109
|
-
// Replace 0.6 to .6, but only when preceded by : or a white-space
|
|
110
|
-
css = css.replaceAll("(:|\\s)0+\\.(\\d+)", "$1.$2");
|
|
111
|
-
|
|
112
|
-
// Shorten colors from rgb(51,102,153) to #336699
|
|
113
|
-
// This makes it more likely that it'll get further compressed in the next step.
|
|
114
|
-
p = Pattern.compile("rgb\\s*\\(\\s*([0-9,\\s]+)\\s*\\)");
|
|
115
|
-
m = p.matcher(css);
|
|
116
|
-
sb = new StringBuffer();
|
|
117
|
-
while (m.find()) {
|
|
118
|
-
String[] rgbcolors = m.group(1).split(",");
|
|
119
|
-
StringBuffer hexcolor = new StringBuffer("#");
|
|
120
|
-
for (int i = 0; i < rgbcolors.length; i++) {
|
|
121
|
-
int val = Integer.parseInt(rgbcolors[i]);
|
|
122
|
-
if (val < 16) {
|
|
123
|
-
hexcolor.append("0");
|
|
124
|
-
}
|
|
125
|
-
hexcolor.append(Integer.toHexString(val));
|
|
126
|
-
}
|
|
127
|
-
m.appendReplacement(sb, hexcolor.toString());
|
|
128
|
-
}
|
|
129
|
-
m.appendTail(sb);
|
|
130
|
-
css = sb.toString();
|
|
131
|
-
|
|
132
|
-
// Shorten colors from #AABBCC to #ABC. Note that we want to make sure
|
|
133
|
-
// the color is not preceded by either ", " or =. Indeed, the property
|
|
134
|
-
// filter: chroma(color="#FFFFFF");
|
|
135
|
-
// would become
|
|
136
|
-
// filter: chroma(color="#FFF");
|
|
137
|
-
// which makes the filter break in IE.
|
|
138
|
-
p = Pattern.compile("([^\"'=\\s])(\\s*)#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])");
|
|
139
|
-
m = p.matcher(css);
|
|
140
|
-
sb = new StringBuffer();
|
|
141
|
-
while (m.find()) {
|
|
142
|
-
// Test for AABBCC pattern
|
|
143
|
-
if (m.group(3).equalsIgnoreCase(m.group(4)) &&
|
|
144
|
-
m.group(5).equalsIgnoreCase(m.group(6)) &&
|
|
145
|
-
m.group(7).equalsIgnoreCase(m.group(8))) {
|
|
146
|
-
m.appendReplacement(sb, m.group(1) + m.group(2) + "#" + m.group(3) + m.group(5) + m.group(7));
|
|
147
|
-
} else {
|
|
148
|
-
m.appendReplacement(sb, m.group());
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
m.appendTail(sb);
|
|
152
|
-
css = sb.toString();
|
|
153
|
-
|
|
154
|
-
// Remove empty rules.
|
|
155
|
-
css = css.replaceAll("[^\\}]+\\{;\\}", "");
|
|
156
|
-
|
|
157
|
-
if (linebreakpos >= 0) {
|
|
158
|
-
// Some source control tools don't like it when files containing lines longer
|
|
159
|
-
// than, say 8000 characters, are checked in. The linebreak option is used in
|
|
160
|
-
// that case to split long lines after a specific column.
|
|
161
|
-
int i = 0;
|
|
162
|
-
int linestartpos = 0;
|
|
163
|
-
sb = new StringBuffer(css);
|
|
164
|
-
while (i < sb.length()) {
|
|
165
|
-
char c = sb.charAt(i++);
|
|
166
|
-
if (c == '}' && i - linestartpos > linebreakpos) {
|
|
167
|
-
sb.insert(i, '\n');
|
|
168
|
-
linestartpos = i;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
css = sb.toString();
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// Replace the pseudo class for the Box Model Hack
|
|
176
|
-
css = css.replaceAll("___PSEUDOCLASSBMH___", "\"\\\\\"}\\\\\"\"");
|
|
177
|
-
|
|
178
|
-
// Replace multiple semi-colons in a row by a single one
|
|
179
|
-
// See SF bug #1980989
|
|
180
|
-
css = css.replaceAll(";;+", ";");
|
|
181
|
-
|
|
182
|
-
// Trim the final string (for any leading or trailing white spaces)
|
|
183
|
-
css = css.trim();
|
|
184
|
-
|
|
185
|
-
// Write the output...
|
|
186
|
-
out.write(css);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* YUI Compressor
|
|
3
|
-
* Author: Julien Lecomte <jlecomte@yahoo-inc.com>
|
|
4
|
-
* Copyright (c) 2007, Yahoo! Inc. All rights reserved.
|
|
5
|
-
* Code licensed under the BSD License:
|
|
6
|
-
* http://developer.yahoo.net/yui/license.txt
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
package com.yahoo.platform.yui.compressor;
|
|
10
|
-
|
|
11
|
-
import java.io.ByteArrayOutputStream;
|
|
12
|
-
import java.io.IOException;
|
|
13
|
-
import java.io.InputStream;
|
|
14
|
-
import java.io.OutputStream;
|
|
15
|
-
import java.util.Enumeration;
|
|
16
|
-
import java.util.jar.JarEntry;
|
|
17
|
-
import java.util.jar.JarFile;
|
|
18
|
-
|
|
19
|
-
public class JarClassLoader extends ClassLoader {
|
|
20
|
-
|
|
21
|
-
private static String jarPath;
|
|
22
|
-
|
|
23
|
-
public Class loadClass(String name) throws ClassNotFoundException {
|
|
24
|
-
|
|
25
|
-
// First check if the class is already loaded
|
|
26
|
-
Class c = findLoadedClass(name);
|
|
27
|
-
if (c == null) {
|
|
28
|
-
c = findClass(name);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (c == null) {
|
|
32
|
-
c = ClassLoader.getSystemClassLoader().loadClass(name);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return c;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
private static String getJarPath() {
|
|
39
|
-
|
|
40
|
-
if (jarPath != null) {
|
|
41
|
-
return jarPath;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
String classname = JarClassLoader.class.getName().replace('.', '/') + ".class";
|
|
45
|
-
String classpath = System.getProperty("java.class.path");
|
|
46
|
-
String classpaths[] = classpath.split(System.getProperty("path.separator"));
|
|
47
|
-
|
|
48
|
-
for (int i = 0; i < classpaths.length; i++) {
|
|
49
|
-
|
|
50
|
-
String path = classpaths[i];
|
|
51
|
-
JarFile jarFile = null;
|
|
52
|
-
JarEntry jarEntry = null;
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
jarFile = new JarFile(path);
|
|
56
|
-
jarEntry = findJarEntry(jarFile, classname);
|
|
57
|
-
} catch (IOException ioe) {
|
|
58
|
-
/* ignore */
|
|
59
|
-
} finally {
|
|
60
|
-
if (jarFile != null) {
|
|
61
|
-
try {
|
|
62
|
-
jarFile.close();
|
|
63
|
-
} catch (IOException ioe) {
|
|
64
|
-
/* ignore */
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (jarEntry != null) {
|
|
70
|
-
jarPath = path;
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return jarPath;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private static JarEntry findJarEntry(JarFile jarFile, String entryName) {
|
|
79
|
-
|
|
80
|
-
Enumeration entries = jarFile.entries();
|
|
81
|
-
|
|
82
|
-
while (entries.hasMoreElements()) {
|
|
83
|
-
JarEntry entry = (JarEntry) entries.nextElement();
|
|
84
|
-
if (entry.getName().equals(entryName)) {
|
|
85
|
-
return entry;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
protected Class findClass(String name) {
|
|
93
|
-
|
|
94
|
-
Class c = null;
|
|
95
|
-
String jarPath = getJarPath();
|
|
96
|
-
|
|
97
|
-
if (jarPath != null) {
|
|
98
|
-
JarFile jarFile = null;
|
|
99
|
-
try {
|
|
100
|
-
jarFile = new JarFile(jarPath);
|
|
101
|
-
c = loadClassData(jarFile, name);
|
|
102
|
-
} catch (IOException ioe) {
|
|
103
|
-
/* ignore */
|
|
104
|
-
} finally {
|
|
105
|
-
if (jarFile != null) {
|
|
106
|
-
try {
|
|
107
|
-
jarFile.close();
|
|
108
|
-
} catch (IOException ioe) {
|
|
109
|
-
/* ignore */
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return c;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
private Class loadClassData(JarFile jarFile, String className) {
|
|
119
|
-
|
|
120
|
-
String entryName = className.replace('.', '/') + ".class";
|
|
121
|
-
JarEntry jarEntry = findJarEntry(jarFile, entryName);
|
|
122
|
-
if (jarEntry == null) {
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Create the necessary package if needed...
|
|
127
|
-
int index = className.lastIndexOf('.');
|
|
128
|
-
if (index >= 0) {
|
|
129
|
-
String packageName = className.substring(0, index);
|
|
130
|
-
if (getPackage(packageName) == null) {
|
|
131
|
-
definePackage(packageName, "", "", "", "", "", "", null);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Read the Jar File entry and define the class...
|
|
136
|
-
Class c = null;
|
|
137
|
-
try {
|
|
138
|
-
InputStream is = jarFile.getInputStream(jarEntry);
|
|
139
|
-
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
140
|
-
copy(is, os);
|
|
141
|
-
byte[] bytes = os.toByteArray();
|
|
142
|
-
c = defineClass(className, bytes, 0, bytes.length);
|
|
143
|
-
} catch (IOException ioe) {
|
|
144
|
-
/* ignore */
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return c;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
private void copy(InputStream in, OutputStream out) throws IOException {
|
|
151
|
-
byte[] buf = new byte[1024];
|
|
152
|
-
while (true) {
|
|
153
|
-
int len = in.read(buf);
|
|
154
|
-
if (len < 0) break;
|
|
155
|
-
out.write(buf, 0, len);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|