cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ugo Cei <>
Subject [Forms] Protected methods in o.a.c.forms.datatype.typeimpl.AbstractDatatype
Date Fri, 15 Jul 2005 15:29:56 GMT

I'm trying to write a custom CForms datatype. I'd have some general 
considerations about how hard this is, considering the need to patch 
cocoon.xconf to extend the forms type system, which makes me want to go 
growing vineyards in the hillsides (do we really need all this Avalon 
stuff just to configure a set of factories?), but I'll leave that for 
another thread.

Anyway, my problem at the moment is that I started by copying 
StringType and StringTypeBuilder and trying to modify them for my 
needs. I also copied them to a package belonging to my application and 
outside of o.a.c.forms.datatype.typeimpl. This datatype is peculiar to 
my app and it makes no sense as part of Cocoon.

Unfortunately, this breaks StringTypeBuilder (which is now called, say, 
MyTypeBuilder) because it does things like:


those methods are inherited from AbstractDatatype, where they are 
declared as "protected". Thus, I was painfully reminded that protected 
members in Java are visible not only to subclasses, but to all other 
classes in the same package as well! As long as StringTypeBuilder is in 
the same package as AbstractDatatype, all is well, but as soon as I 
copy it to com.example.mypackage.MyTypeBuilder, it doesn't compile 

Now, there's a quick workaround to that: I could just override the 
methods in MyType and delegate to super. Somehow I think this is not 
very elegant.

I'd like to make them public, but this bugs me a little, as it means 
increasing the "surface complexity" of AbstractDatatype. However, I 
cannot think of a better solution. Do you?


Ugo Cei
Tech Blog:
Open Source Zone:
Wine & Food Blog:

View raw message