[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Java-Specific Question

  • From: Andrew n marshall <amarshal@u...>
  • To: "'David Megginson'" <ak117@f...>, "'xml-dev Mailing List'" <xml-dev@i...>
  • Date: Sat, 4 Apr 1998 00:24:57 -0800

java media framework
On Friday, April 03, 1998 5:44 PM, David Megginson 
[SMTP:ak117@f...] wrote:
> Here's a Java question.  Let's say that I have a class with a method
>
>   public void parse (String publicId, String systemId, Reader reader)
>     throws java.lang.Exception;
>
> What will happen if the "java.io.Reader" class is not available on my
> system (perhaps because I'm using a 1.0.2 browser), but I never invoke
> this method (I'm assuming that I compiled my code under JDK 1.1 or JDK
> 1.2)?

The JavaVM will throw a ClassNotFoundException because it will try to 
preload the class in case you do use the method.

> I'm becoming convinced that we need to support character streams in
> SAX, and I'm trying to figure out how to handle it in the Java
> version -- I think that I've worked out pretty much everything else
> now, except for a few minor details.

I'm dealing with a similar problem on an applet at work where I need to be 
able to support the Java Media Framework for sound if available.  My 
solution is to abstract everything that references the possibly missing 
classes into a second class, then in build an initialization routine like 
the following:

Class parserClass;  // used if creating several Parser objects
Parser parser = null;  // Parser is an abstract class or interface
                       // Used if only need one parser

void init() {
  try {
    Class.forName( "java.io.Reader" ); // checks if supported
    parserClass = Class.forName( "MyParserFor11" );
  } catch( ClassNotFoundException err ) {
    parserClass = Class.forName( "MyParserFor10" );
  }
  try {
    parser = (Parser) parserClass.newInstance();
  } catch( InstantiationException err ) { // Constructor requires argument
  } catch( IllegalAccessException err ) { // Constructor isn't public
  }
}

NOTE: Apparently my understandings reflected Don Park's >>original<< 
message which is apparently wrong.  But even so, the above will still work.

Andrew n marshall
  student - artist - programmer
    http://www.media-electronica.com/anm-bin/anm
      "Everyone a mentor,  Everyone a pupil"
 

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.