You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Edward Blazer <5....@gmail.com> on 2007/01/13 00:51:39 UTC
Sub-classing Scomp'd Impl classes
Hello,
I'm dealing with rather large XML objects that have 10's of thousands of
elements. Instead of using a String object for each elements value, I'd like
to pass a different object that uses a byte[] and have xmlBeans call the
object's toString() method which does all the converting. This would save a
lot of memory. So, I'd like to sub-class the appropriate Impl.class (or
modify the src) generated by scomp such that it delegates the stringValue()
method to the object that is backed by a byte[]. This part is no problem.
The problem arises when calling a parent element's xmltext() method; it
returns a null value. I don't know much about how xmlbeans works
behind-the-scenes, but my guess is that my object with the byte[] needs to
make it to the cursor somehow?
Any ideas for this. Is there a better way to solve my problem?
Thanks,
Eddie
-------------------Code------------------
public class MyStringImpl extends
org.apache.xmlbeans.impl.values.JavaStringHolderEx implements test.MyString{
private MyObject o;
public MyStringImpl(org.apache.xmlbeans.SchemaType sType) {
super(sType, false);
}
protected MyStringImpl(org.apache.xmlbeans.SchemaType sType, boolean b)
{
super(sType, b);
}
public void setMyObject(MyObject o) {
this.o = o;
}
public String stringValue() {
o.toString();
}
public String compute_text(NamespaceManager namespaceManager) {
return stringValue();
}
public XmlCursor newCursor() {
XmlCursor c = super.newCursor();
c.toNextToken();
c.insertChars(stringValue());
return c;
}
}