I need a flexible mapping and an unnamed collection and JibX 1.1.6 prevents
this. I have a work-around that may be of note to others. I would also like
to know if there are any pitfalls with this modification.
Disclaimer: I have not worked with the JibX source until today. :)
This modification maintains the constraint that all children of a flexible
mapping must be named -- with an exception for collection. In this case,
each of a collection's "leaf components" must be named.
Any comments?
Thanks,
Jonathan
package org.jibx.binding.model;
public class ContainerElementBase ... {
...
protected void classifyComponents(ValidationContext vctx) {
.....
if (!comp.hasName()) {
if (isFlexible()) {
if (comp instanceof CollectionElement) {
verifyAllLeafComponentsHaveNames((CollectionElement)comp);
} else {
vctx.addError("All child components
must define element names for flexible='true'", comp);
}
} else if (comp instanceof ValueElement &&
!isOrdered()) {
vctx.addError("Text values cannot be
used with ordered='false'", comp);
}
}
}
}
}
m_inClassify = false;
}
}
}
private boolean verifyAllLeafComponentsHaveNames(CollectionElement
collectionElement) {
for(Iterator it = collectionElement.childIterator(); it.hasNext(); )
{
Object nextObj = it.next();
if (nextObj instanceof IComponent) {
IComponent childComp = (IComponent)nextObj;
if (! childComp.hasName()) {
if (childComp instanceof CollectionElement) {
if (!
verifyAllLeafComponentsHaveNames((CollectionElement)childComp)) {
return false;
}
} else {
return false;
}
}
}
}
return true;
}
...
}
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
jibx-devs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-devs