Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > class design - clarification

Reply
Thread Tools

class design - clarification

 
 
Spitfire
Guest
Posts: n/a
 
      02-16-2007
Whenever I parse an XML file, using a DOM parser, I get a DOM object
which I can use to access whichever element I want to extract. However,
I cannot mutate any of them in place, preserving therefore the
consistency of the values in the object. How do I design such a class if
I have to for another similar purpose?

Imagine a scenario in which I construct my own XML/HTML parser. So my
parser takes a URL or a file and then constructs a DOM object which
represents the entire parsed doc. How do I design this DOM object class?
I want to have variables which the other classes can only see, but not
modify! I want to have methods which the other class can invoke, like
'getElementsByName' ... etc. I'm stuck in finalizing the design of the
class. This is just for academic purposes and therefore lets keep
advices against 'reinventing the wheel' away for a while.

--
_ _ _]{5pitph!r3}[_ _ _
__________________________________________________
“I'm smart enough to know that I'm dumb.”
- Richard P Feynman
 
Reply With Quote
 
 
 
 
Chris Smith
Guest
Posts: n/a
 
      02-16-2007
Spitfire <(E-Mail Removed)> wrote:
> Imagine a scenario in which I construct my own XML/HTML parser. So my
> parser takes a URL or a file and then constructs a DOM object which
> represents the entire parsed doc. How do I design this DOM object class?
> I want to have variables which the other classes can only see, but not
> modify! I want to have methods which the other class can invoke, like
> 'getElementsByName' ... etc. I'm stuck in finalizing the design of the
> class. This is just for academic purposes and therefore lets keep
> advices against 'reinventing the wheel' away for a while.


Once smart way to proceed might be to implement wrapper classes for all
the standard DOM interfaces. These wrappers would throw exceptions if
the caller tries to modify the document; but would pass through the
function calls that just read from the document. They would also
construct wrappers on the fly for any other interfaces retrieved from
them.

This is the same thing that happens, for example, with Java's standard
Collections.unmodifiableList and other such functions.

--
Chris Smith
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
clarification on Shared class constructor Paul Wu ASP .Net 2 05-05-2005 08:33 AM
Class design/design pattern resources TomTom MCSD 2 10-09-2004 07:38 AM
class definition - namespace nomenclature clarification Karthik Kumar C++ 2 09-15-2004 03:58 PM
Character class [\W_] clarification Fiaz Idris Perl Misc 7 12-11-2003 06:10 AM



Advertisments