Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2007

Tip: Looking for answers? Try searching our database.

Abstract class with Inner class - Inheritance

Thread view: 
sven.furrer@gmail.com - 18 Oct 2007 10:10 GMT
Hi everybody

I have an abstract outer class with an inner class.
My inner class has a isValide() method which uses attributes form my
outer class.

Various sub-classes extend my outer class.
An other package contains classes which in their turn extend all these
subclasses. Let's call them SubSubClass.

Confused? - Me too ;-)

My SubSubClass contains a new attribute, which has to be validated. I
kind of would have to overwrite my isValid() method in my inner
class.

Any idea how I could do this in an "easy" way?

Thanks a lot!
Sven

An attempt to draw the "class diagram":
===========
| abstract
| OuterClass
|
| ------------------
| ¦ InnerClass
| ¦-----------------
| ¦ isValide()
| ------------------
===========
^
¦
¦
===========
SubClass
===========
^
¦
¦    other package:
¦
===========
| SubSubClass
| int newAttr;
| ------------------
| ¦ InnerClass
| ¦-----------------
| ¦ isValide()
| ------------------
===========
Andreas Leitgeb - 18 Oct 2007 13:08 GMT
> I have an abstract outer class with an inner class.
> My inner class has a isValide() method which uses attributes form my
> outer class.

> Various sub-classes extend my outer class.
> An other package contains classes which in their turn extend all these
> subclasses. Let's call them SubSubClass.

> My SubSubClass contains a new attribute, which has to be validated. I
> kind of would have to overwrite my isValid() method in my inner
> class.

One way could be that you add some getter-Method into your abstract
OuterClass, that normally returns something "valid", which is then
overridden in MySubSubClass to return it's attribute.
The inner class' isValid() then accesses the getter-method and thus
sees the derived class' attribute's value :-)

If this extra attribute really doesn't fit into the abstract outerclass'
design, it would instead need a "pluggable" Validator, and a way to
re-plug a different Validator object, which then could be actually of
type MySpecialValidator, which would then know about that extra attribute
and call it's baseClass' isValid for the other attributes.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.