commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Baltz, Kenneth" <Kba...@firstam.com>
Subject RE: Newbie: Digester "clazz" ???
Date Thu, 02 Jan 2003 16:39:35 GMT
I'll agree with Henri and add that the .class variable is usually used for
Reflection, a process by which java object are dynamically instantiated at
runtime.  There are basically two ways to refer to a class: by String name
(e.g. "java.lang.BigInteger" ) or by .class (e.g.
java.lang.BigInteger.class).  The former is more flexible, but also more
prone to error.  The latter gives the compiler the ability to catch errors
(spelling, missing class) at compile time.

K.C.


> -----Original Message-----
> From: Henri Yandell [mailto:bayard@generationjava.com]
> Sent: Thursday, January 02, 2003 5:29 AM
> To: Jakarta Commons Users List; me@howardmiller.co.uk
> Subject: Re: Newbie: Digester "clazz" ???
> 
> 
> 
> It's a feature of Java. You can specify the java.lang.Class 
> object for a
> class as a literal:  java.lang.String.class  or
> org.apache.log4j.Log.class etc. These are then automatically 
> turned into
> the Class object [as found through getClass() on an object of 
> that class].
> 
> As 'class' is a reserved word, people often use 'clss' or 'clazz' as a
> variable name for it.
> 
> My apologies if I've not understood the question,
> 
> Hen
> 
> On Thu, 2 Jan 2003, Howard Miller wrote:
> 
> > Hi,
> >
> > Sorry this is going to be a stupid newbie question....
> >
> > In the Javadocs for the Digester components, a number of the rule
> > setting methods have parameters in the form "java.lang.Class
> > clazz". This has got me worried, as I don't understand what is going
> > on here. My expectation is that if the rule just created a 
> new object it
> > would be "java.lang.Object object", so I have obviously failed to
> > understand something. What are the ZZs all about?
> >
> > Furthermore an example I found the The O'Reilly site used this
> > method with a (actual) parameter looking like "Catalog.class", I
> > haven't seen the ".class" method used before, and I'm not that new
> > to Java!!
> >
> > What's going on here? Help appreciated.
> >
> > Howard Miller
> >
> > --
> > To unsubscribe, e-mail:   
> <mailto:commons-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail: 
> <mailto:commons-user-help@jakarta.apache.org>
> >
> >
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:commons-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: 
> <mailto:commons-user-help@jakarta.apache.org>
> 
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message