@Override public void startElement(UnmarshallingContext.State state, TagName ea) { state.setTarget(new ArrayList()); }
@Override public void text(UnmarshallingContext.State state, CharSequence text) throws SAXException { List<Object> r = new FinalArrayList<Object>(); int idx = 0; int len = text.length(); while(true) { int p = idx; while( p<len && !WhiteSpaceProcessor.isWhiteSpace(text.charAt(p)) ) p++; CharSequence token = text.subSequence(idx,p); if (!token.equals("")) try { r.add(xducer.parse(token)); } catch (AccessorException e) { handleGenericException(e,true); continue; // move on to next } if(p==len) break; // done while( p<len && WhiteSpaceProcessor.isWhiteSpace(text.charAt(p)) ) p++; if(p==len) break; // done idx = p; } state.setTarget(toArray(r)); } };
state.setTarget(child);
public void text(UnmarshallingContext.State state, CharSequence text) throws SAXException { try { state.setTarget(xducer.parse(text)); } catch (AccessorException e) { handleGenericException(e,true); } catch (RuntimeException e) { handleParseConversionException(state,e); } } }
@Override public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException { state.setLoader(this); State s = (State) state.getPrev().getTarget(); s.depth++; state.setTarget(s); }
@Override protected void onNil(UnmarshallingContext.State state) { // let the receiver add this to the lister state.setTarget(null); } }
@Override public void childElement(UnmarshallingContext.State state, TagName ea) { state.setTarget(null); // registering this allows the discarder to process the whole subtree. state.setLoader(this); } }
@Override public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { UnmarshallingContext context = state.getContext(); context.startScope(1); // inherit the target so that our children can access its target state.setTarget(state.getPrev().getTarget()); // start it now, so that even if there's no children we can still return empty collection context.getScope(0).start(acc,lister); }
@Override public final void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { state.setLoader(core); state.setIntercepter(this); // TODO: make sure there aren't too many duplicate of this code // create the object to unmarshal Object child; UnmarshallingContext context = state.getContext(); // let's see if we can reuse the existing peer object child = context.getOuterPeer(); if(child!=null && jaxbType!=child.getClass()) child = null; // unexpected type. if(child!=null) reset((JAXBElement)child,context); if(child==null) child = context.createInstance(ElementBeanInfoImpl.this); fireBeforeUnmarshal(ElementBeanInfoImpl.this, child, state); context.recordOuterPeer(child); UnmarshallingContext.State p = state.getPrev(); p.setBackup(p.getTarget()); p.setTarget(child); core.startElement(state,ea); }
@Override public void leaveElement(UnmarshallingContext.State state, TagName ea) throws SAXException { State s = (State) state.getTarget(); UnmarshallingContext context = state.getContext(); try { s.handler.endElement(ea.uri, ea.local, ea.getQname()); s.undeclarePrefixes(context.getNewlyDeclaredPrefixes()); } catch( SAXException e ) { context.handleError(e); throw e; } if((--s.depth)==0) { // emulate the end of the document try { s.undeclarePrefixes(context.getAllDeclaredPrefixes()); s.handler.endDocument(); } catch( SAXException e ) { context.handleError(e); throw e; } // we are done state.setTarget(s.getElement()); } }
@Override public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { // create or obtain the Map object try { BeanT target = (BeanT) state.getPrev().getTarget(); ValueT mapValue = acc.get(target); if(mapValue == null) mapValue = ClassFactory.create(mapImplClass); else mapValue.clear(); Stack.push(this.target, target); Stack.push(map, mapValue); state.setTarget(mapValue); } catch (AccessorException e) { // recover from error by setting a dummy Map that receives and discards the values handleGenericException(e,true); state.setTarget(new HashMap()); } }
public Object intercept(UnmarshallingContext.State state, Object o) throws SAXException { JAXBElement e = (JAXBElement)state.getTarget(); state.setTarget(state.getBackup()); state.setBackup(null); if (state.isNil()) { e.setNil(true); state.setNil(false); } if(o!=null) // if the value is a leaf type, it's often already set to the element // through Accessor. e.setValue(o); fireAfterUnmarshal(ElementBeanInfoImpl.this, e, state); return e; } }
@Override public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { UnmarshallingContext context = state.getContext(); if (state.getTarget() == null) state.setTarget(new State(context)); State s = (State) state.getTarget(); try { s.declarePrefixes(context, context.getNewlyDeclaredPrefixes()); s.handler.startElement(ea.uri, ea.local, ea.getQname(), ea.atts); } catch (SAXException e) { context.handleError(e); throw e; } }
@Override public void leaveElement(UnmarshallingContext.State state, TagName ea) { state.setTarget(toArray((List)state.getTarget())); }
@Override public void startElement(UnmarshallingContext.State state, TagName ea) { state.setTarget(new Object[2]); // this is inefficient }
public void text(UnmarshallingContext.State state, CharSequence text) throws SAXException { try { state.setTarget(xducer.parse(text)); } catch (AccessorException e) { handleGenericException(e,true); } catch (RuntimeException e) { handleParseConversionException(state,e); } } }
@Override public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { UnmarshallingContext context = state.getContext(); context.startScope(1); // inherit the target so that our children can access its target state.setTarget(state.getPrev().getTarget()); // start it now, so that even if there's no children we can still return empty collection context.getScope(0).start(acc,lister); }
@Override public void childElement(UnmarshallingContext.State state, TagName ea) { state.setTarget(null); // registering this allows the discarder to process the whole subtree. state.setLoader(this); } }
@Override protected void onNil(UnmarshallingContext.State state) { // let the receiver add this to the lister state.setTarget(null); } }
@Override public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException { state.setLoader(this); State s = (State) state.getPrev().getTarget(); s.depth++; state.setTarget(s); }