[jdom-interest] JDK1.1 Compatibility - B4
Joseph Bowbeer
jozart at csi.com
Wed Jun 7 06:14:39 PDT 2000
Fyi. I just migrated the B4 sources to JDK1.1. Here are some
specifics.
Files modified: 11
Attribute.java
Document.java
DocType.java
Element.java
Entity.java
Namespace.java
PartialList.java
ProcessingInstruction.java
input/DOMBuilder.java
input/SAXBuilder.java
output/XMLOutputter.java
Most modifications are similar to the following:
/*if[JAVA2]
import java.util.LinkedList;
import java.util.List;
/*else[JAVA2]*/
import com.sun.java.util.collections.LinkedList;
import com.sun.java.util.collections.List;
/*end[JAVA2]*/
However, there are currently three special cases that require more
work.
1. UnsupportedOperationException workaround
Import UnsupportedOperationException where needed; this exception
is imported by default from java.lang in Java2.
Document.java
Element.java
/*if[JAVA2]
/*else[JAVA2]*/
import
com.sun.java.util.collections.UnsupportedOperationException;
/*end[JAVA2]*/
2. File.toURL() workaround
Steal some code from Java2 and add it to SAXBuilder.
/*if[JAVA2]
URL url = file.toURL();
/*else[JAVA2]*/
URL url = toURL(file);
/*end[JAVA2]*/
/*if[JAVA2]
/*else[JAVA2]*/
private static URL toURL(File file) throws
MalformedURLException {
String path = file.getAbsolutePath();
if (File.separatorChar != '/') {
path = path.replace(File.separatorChar, '/');
}
if (!path.startsWith("/")) {
path = "/" + path;
}
if (!path.endsWith("/") && file.isDirectory()) {
path = path + "/";
}
return new URL("file", "", path);
}
/*end[JAVA2]*/
3. Float.parseFloat() and Double.parseDouble() workaround
Attribute and Element need code like the following in a eight
places (four each).
/*if[JAVA2]
return Double.parseDouble(value);
/*else[JAVA2]*/
return Double.valueOf(value).doubleValue();
/*end[JAVA2]*/
--
Joe Bowbeer
PS - The line termination in the B4 sources is strange. I haven't
investigated it, but the Sun Forte IDE (formerly NetBeans)
double-spaces everything and MS WordPad concatenates everything
onto one line. (MS Notepad does just fine, though - for once.)
More information about the jdom-interest
mailing list