public Object unmarshal(Object obj, IUnmarshallingContext ictx) throws JiBXException { // make sure we're at the appropriate start tag UnmarshallingContext ctx = (UnmarshallingContext)ictx; if (!ctx.isAt(m_uri, m_name)) { return null; } // get object reference for ID obj = ctx.attributeExistingIDREF(null, getAttributeName(), 0); // skip past the element ctx.parsePastEndTag(m_uri, m_name); return obj; } }
public void marshal(Object obj, IMarshallingContext ictx) throws JiBXException { // make sure the parameters are as expected if (obj == null) { return; } else if (!(ictx instanceof MarshallingContext)) { throw new JiBXException("Invalid context type for marshaller"); } else { // generate the element start tag MarshallingContext ctx = (MarshallingContext)ictx; ctx.startTagAttributes(m_index, m_name); // add attribute reference to object ID ctx.attribute(0, getAttributeName(), getIdValue(obj)); // close start tag for empty element ctx.closeStartEmpty(); } }