aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Wrapper Class ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Wrapper Class ?" Watch "Wrapper Class ?" New topic
Author

Wrapper Class ?

Kruger Scheitz
Ranch Hand

Joined: Jul 31, 2002
Posts: 72
i ve been reading a lot of threads talking about wrapper class. What is wrapper class means over here? can u give me an example plsss.
Mag Hoehme
Ranch Hand

Joined: Apr 07, 2002
Posts: 194
Hi Kruger,
examples of wrapper classes are Integer, Double etc. A wrapper actually holds some other object (or value) and offers some methods to do something with the wrapped object.

I hope this makes clear what a wrapper is and how it works.


Mag
Nate Johnson
Ranch Hand

Joined: May 13, 2002
Posts: 301
Originally posted by Kruger Scheitz:
i ve been reading a lot of threads talking about wrapper class. What is wrapper class means over here? can u give me an example plsss.

I think people use wrappers in this assignment by using the DAO pattern... they want to separate the database from the gui... I wrapped the DataInfo data in a wrapper so that I could swap out the Sun database for any other database with a few simple interface implementations.


scwcd, scjd, scjp<br /><a href="http://natejohnson.us" target="_blank" rel="nofollow">http://natejohnson.us</a><br /><a href="http://rice.kuali.org" target="_blank" rel="nofollow">http://rice.kuali.org</a>
Kruger Scheitz
Ranch Hand

Joined: Jul 31, 2002
Posts: 72
thx brother... sometimes i wonder how could i passed the SCJP...sighhhhhhhhhh
Kruger Scheitz
Ranch Hand

Joined: Jul 31, 2002
Posts: 72
why we need a wrapper class to wrap up another object class? isn't it more efficient to call up the object that you want to call instead of using wrapper object to call another object. and isn't it more memory consumption if u call wrapper object which then call another object since u have to pass object reference from methods to methods ?
Ruby Wong
Greenhorn

Joined: Aug 29, 2002
Posts: 5
Originally posted by Kruger Scheitz:
i ve been reading a lot of threads talking about wrapper class. What is wrapper class means over here? can u give me an example plsss.

Why not read the definitive reference for design patterns (GoF book)? wrapper = decorator and you can find a whole chapter on this pattern in the book.


--<br />Ruby
Mag Hoehme
Ranch Hand

Joined: Apr 07, 2002
Posts: 194
Originally posted by Kruger Scheitz:
isn't it more efficient to call up the object that you want to call instead of using wrapper object to call another object. and isn't it more memory consumption if u call wrapper object which then call another object since u have to pass object reference from methods to methods ?

Actually yes. But there are a lot of reasons to use wrappers... For example:
  • You want to handle primitives in collections such as lists or hashtables
  • The interface of your wrapped object does not fit - you can wrap it with a so-called Adapter

  • Wrappers do add indirection, require (usually slightly) more memory - that is their downside. But this is a trade-off that can be accepted.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Wrapper Class ?