--- Finn Bock <[EMAIL PROTECTED]> wrote:
> [Glen Mazza]
> > Could you explain why we have the datatypes
> instances
> > to begin with--what they're for?  I'm not sure
> what
> > their precise purpose is.
> The datatypes are the slightly more complex property
> values. The 
> property classes wraps the datatype in order to give
> the datatypes a 
> common interface.

Thanks for taking the time to explain this.  My
comprehension has increased quite a bit.

> Some of the concrete property subclasses wraps
> standard java types such 
> as int, char, String, Number and Vector and for
> these properties we 
> still need a wrapper. But some of them, marked with
> (*), wraps a 
> datatype which is under our own control and for
> those properties, the 
> datatype class could also function as the property
> wrapper.

I now understand what you're saying, and like the
simplification you're suggesting.  The current naming
however, is probably preferable--the word "Property" 
figures quite highly in the spec!  Do you have a
problem remaining with it?

For those (*)'ed datatypes, can't we get rid of the
datatype instead by rolling that datatype into the
equivalently named Property?  In turn, have *those*
Properties extend AbstractProperty as you suggest. 
Actually, I guess I'm just saying the same thing
you're suggesting, except to use "--Property" instead
of "--Type" for everything.

> > Offhand, it's doesn't seem natural to go without
> > Property objects--they are kept in the
> PropertyList
> > and indexed by the property ID in that list. 
> That would still be the case. Everything stored in
> the PropertyList 
> implements the Property interface. 

But only a few of them would extend AbstractProperty,
correct--or would you plan on having all do so?

> I remember two cases, but I can only find one at the
> moment: In 
> Title.setup():
>          prop =
> this.propertyList.get(PR_BASELINE_SHIFT);
>          if (prop instanceof LengthProperty) {
>              Length bShift = prop.getLength();
>          } else if (prop instanceof EnumProperty) {
>              int bShift = prop.getEnum();
>          }
> This would stay the same, except LengthProperty
> would be called 
> LengthType and EnumProperty would be called
> EnumType. Except that the 
> code above should IMHO use "if (prop.getLength() !=
> null)" to test for a 
> length type instead of using instanceof.

Well, instanceof is slower I believe, but better
self-commenting.  If you switch to this type of
conditional for speed, just add a short comment of its
purpose--here, to determine if we are working with an
EnumProperty or a LengthProperty.

(Another option, BTW, if you think it will cut down on
buggy programming, is to have the classes implementing
this Property interface supply unsupported interface
methods a la Peter's Read-Only BitSet[1], i.e., throw
exceptions.  We can revisit this topic later if code
errors are becoming a problem.)



Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!

Reply via email to