Thanks for your note, Simon - and sorry for not responding earlier.
I was off home - and as I work this out in my spare-time ...
Simon Kitching wrote:
> You are trying to avoid creating an object corresponding to the
> "addAttributes" xml element, yet process subelements associated
> with that element.
I did that, cause the entity-attribute relation is for me just a reference and
for so not worth to create a class for that purpose.
> This isn't exactly "invalid", but this kind of disconnect between the
> xml structure and your object structure leads to the kind of problems
> you are experiencing.
I don't consider it really a problem. The digester-stuff is easy to understand
and as well easy to expand. My "CallAncestorParamRule" works fine for me.
> If you were to define a class
>
> class OptionallyIndexedAttribute {
> String attributeName;
> Integer idxNr;
> Integer idxOrder;
>
> public void setName() {...};
> public void setUniqueIndex(int idxNr, int idxOrder) {...};
> }
>
> and have this method on class Entity:
> addAttribute(OptionallyIndexedAttribute attr) {
> }
Yes, may be that's the way, I should do it. Gonna think about it.
> (1)
> Assuming that there is only ever zero or one <unique-index> child
> of an <addAttribute> node,
>
> digester.addCallMethod(ADD_ATTRIBUTE_NODE, "addAttribute", 3);
> digester.addCallParam(ADD_ATTRIBUTE_NODE, 0, "name");
> digester.addCallParam(UINDEX_NODE, 1, "idx_number");
> digester.addCallParam(UINDEX_NODE, 2, "idx_order");
>
> and have this method on Entity:
> addAttribute(String name, Integer idxNr, Integer idxOrder) {...}
I didn't do that, cause at the moment I have 3 different index-types:
- unique index
- index (not unique)
- full text index
with the corresponding xpath of
- entity/addAttribute/unique-index
- entity/addAttribute/index
- entity/addAttribute/fulltext
well, I could spend the addAttribute()-method a fourth parameter "index type"
...
> (2)
> When a "unique-index" element is encountered, you know that it applies
> to the enclosing attribute, which will trigger an "addAttribute" method
> soon. So why not just cache the index info until the addAttribute method
> is invoked?
> This feels a bit hacky to me, but I don't see why it won't work.
> It certainly feels no hackier to me than referencing call parameters
As I devote myself to write easy understandable code, and the index property
is a property of the entity-attribute-relation, I think, the cleanest way is
to write a class for the entity-attribute-relation.
Thank you very much for your time and your attention.
regards Gero
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]