Modifier error in DTDBinder

Richard Clark <[email protected]> Sat, 21 Jun 2003 21:29:50 -0700
Newsgroups gmane.comp.java.enhydra.zeus
Message-ID <[email protected]>
I was working on a new set of unit tests (to be offered back to the Zeus project) as a way of becoming familiar with Zeus, and I uncovered a problematic interaction between DTDBinder and PropertyContainer.

PropertyContainer defines a "private access" modifier bit in its constructor(s), and other routines depend on that bit. However, DTDBinder's convertToBinding function overwrites it:

> BitSet modifiers = new BitSet();
> modifiers.set(Property.SOURCE_ELEMENT);
> ContainerProperty container = new ContainerProperty(xmlName, xmlType);
> container.setModifier(modifiers); // <<< overwrites any existing modifier bits

If you subsequently call getModifierString() on this container, you get an exception as it no longer sees a recognized access control bit.

If "modifiers" is meant as a generic way for some classes to annotate a Container in ways other classes can read, perhaps it should become a collection of BitSet elements (keyed by the name of the class presenting the information?). This would give you:
  public void setModifiers(BitSet flags, String key)
  public BitSet getModifiers(String key);
which would reduce the risk of one class overwriting modifier bits it doesn't own.

What do you think?

..Richard