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; } }
if (ctx.isAt(m_uri, m_name)) { ctx.parsePastStartTag(m_uri, m_name); } else {
if (ctx.isAt(m_uri, m_name)) { ctx.parsePastStartTag(m_uri, m_name); } else {
public Object read(MessagePartInfo part, XMLStreamReader input) { Class<?> type = part.getTypeClass(); try { UnmarshallingContext ctx = getUnmarshallingContext(input, type); if (JibxSimpleTypes.isSimpleType(type)) { QName stype = part.getTypeQName(); QName ctype = part.getConcreteName(); if (ctx.isAt(ctype.getNamespaceURI(), ctype.getLocalPart())) { String text = ctx.parseElementText(ctype.getNamespaceURI(), ctype.getLocalPart()); return JibxSimpleTypes.toObject(text, stype); } else { throw new RuntimeException("Missing required element [" + ctype + "]"); } } else { return ctx.unmarshalElement(part.getTypeClass()); } } catch (JiBXException e) { throw new RuntimeException(e); } }
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)) { ctx.throwStartTagNameError(m_uri, m_name); } // create new hashmap if needed int size = ctx.attributeInt(m_uri, getSizeAttributeName(), DEFAULT_SIZE); Map map = (Map)obj; if (map == null) { map = new HashMap(size); } // process all entries present in document ctx.parsePastStartTag(m_uri, m_name); while (ctx.isAt(m_uri, getEntryElementName())) { Object key = ctx.attributeText(m_uri, getKeyAttributeName(), null); ctx.parsePastStartTag(m_uri, getEntryElementName()); Object value = ctx.unmarshalElement(); map.put(key, value); ctx.parsePastEndTag(m_uri, getEntryElementName()); } ctx.parsePastEndTag(m_uri, m_name); return map; } }
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; } else { // check for reference to existing ID String id = ctx.attributeText(null, getAttributeName(), null); if (id == null) { // no ID value supplied, unmarshal full definition obj = ctx.unmarshalElement(); } else { // find object based on ID obj = ctx.findID(id, 0); ctx.parsePastEndTag(m_uri, m_name); if (obj == null) { ctx.throwStartTagException("Reference to undefined ID " + id); } } } return obj; } }