[jdom-interest] More JDK 1.1 incompatibilities in Beta 4
barry_shultz at hp.com
barry_shultz at hp.com
Wed Jun 14 09:29:55 PDT 2000
Hello everyone,
I received the following reply to my note, which I am posting
for the sender:
***************************************************************************
******
I am kind of lurker on the list, and I had exactly the same problems
yesterday compiling JDOM for JVM 1.1.8 (Apple MrJ 2.2).
Since I cannot post, I mail you directly. You can post this as you want.
Here are the workarounds and ideas my brother came up with:
(1) SAXBuilder method build(File) calls File.toURL()
This works for me:
/**
* Converts this abstract pathname into a <code>file:</code> URL. The
* exact form of the URL is system-dependent. If it can be determined
that
* the file denoted by this abstract pathname is a directory, then the
* resulting URL will end with a slash.
*
* @see java.net.URL
* @since JDK1.2
*/
private URL my_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);
}
/**
* <p>
* This builds a document from the supplied
* filename.
* </p>
*
* @param file <code>File</code> to read from.
* @return <code>Document</code> - resultant Document object.
* @throws <code>JDOMException</code> when errors occur in
* parsing.
*/
public Document build(File file) throws JDOMException {
try {
URL url = my_toURL(file);
return build(url);
} catch (MalformedURLException e) {
throw new JDOMException(e.getMessage(), e);
}
}
(2) Document and Element methods getSerializedForm()
throw UnsupportedOperationException
Idea:
throw new java.lang.RuntimeException("Unsupported")
(3) Element contains calls to parseFloat and parseDouble ( Attribute
already contained those calls in Beta 3 and I know there's a simple
workaround. )
Idea:
Float.parseFloat(String s) could be written using
public static Float valueOf(String s) throws NumberFormatException
(do not ask me where this comes from -- I am a java newbie)
Cheers,
Gabor
***************************************************************************
************
-----Original Message-----
From: SHULTZ, BARRY /HP-Israel,om1
Sent: Wednesday, June 14, 2000 10:35 AM
To: jdom-interest at jdom.org
Cc: SHULTZ, BARRY /HP-Israel,om1
Subject: FW: [jdom-interest] More JDK 1.1 incompatibilities in Beta 4
Hi everyone,
I searched the archives but did not see anything mentioned about the
following: I had been using Beta 3, with slight changes so that it
would be JDK 1.1 compatible. In Beta 4, there's more 1.2-specific
code. Here's a list of the *new* incompatibilities:
(1) SAXBuilder method build(File) calls File.toURL()
(2) Document and Element methods getSerializedForm()
throw UnsupportedOperationException
(3) Element contains calls to parseFloat and parseDouble ( Attribute
already contained those calls in Beta 3 and I know there's a simple
workaround. )
Can anyone suggest simple workarounds for ( 1) and (2)?
Also, I really like JDOM, but I'm stuck in JDK 1.1.8 for the forseeable
future. I'd be happy to help organize/create 1.1-compatible versions,
if someone would like to tell me how to go about it.
Regards,
Barry
_______________________________________________________________________
Barry Shultz
IT Dept
HP Israel
Telnet: 7810-420
Phone : +972 3 5380420
barry_shultz at hp.com
_______________________________________________________________________
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
More information about the jdom-interest
mailing list