public BeanT createInstance(UnmarshallingContext context) throws IllegalAccessException, InvocationTargetException, InstantiationException, SAXException { BeanT bean = null; if (factoryMethod == null) { bean = ClassFactory.create0(jaxbType); } else { Object o = ClassFactory.create(factoryMethod); if (jaxbType.isInstance(o)) { bean = (BeanT) o; } else { throw new InstantiationException("The factory method didn't return a correct object"); } } if (xmlLocatorField != null) // need to copy because Locator is mutable try { xmlLocatorField.set(bean, new LocatorImpl(context.getLocator())); } catch (AccessorException e) { context.handleError(e); } return bean; }
/* */ private void assign(BeanT bean, TargetT t, UnmarshallingContext context) throws AccessorException /* */ { /* 286 */ if (!this.targetType.isInstance(t)) /* 287 */ context.handleError( Messages.UNASSIGNABLE_TYPE.format(new Object[] {this.targetType, t.getClass()})); /* */ else /* 289 */ this.acc.set(bean, t); /* */ }
public UUID parse(CharSequence text) throws SAXException { TODO.checkSpec("JSR222 Issue #42"); try { return UUID.fromString(WhiteSpaceProcessor.trim(text).toString()); } catch (IllegalArgumentException e) { UnmarshallingContext.getInstance().handleError(e); return null; } }
public boolean reset(BeanT bean, UnmarshallingContext context) throws SAXException { try { if (superClazz != null) superClazz.reset(bean, context); for (Property<BeanT> p : properties) p.reset(bean); return true; } catch (AccessorException e) { context.handleError(e); return false; } }
/* */ public void parse(final BeanT bean, CharSequence lexical) throws AccessorException, SAXException { /* 293 */ final String idref = WhiteSpaceProcessor.trim(lexical).toString(); /* 294 */ final UnmarshallingContext context = UnmarshallingContext.getInstance(); /* */ /* 296 */ final Callable callable = context.getObjectFromId(idref, this.acc.valueType); /* 297 */ if (callable == null) /* */ { /* 299 */ context.errorUnresolvedIDREF(bean, idref, context.getLocator()); /* */ return; /* */ } /* */ Object t; /* */ try { /* 305 */ t = callable.call(); /* */ } catch (SAXException e) { /* 307 */ throw e; /* */ } catch (RuntimeException e) { /* 309 */ throw e; /* */ } catch (Exception e) { /* 311 */ throw new SAXException2(e); /* */ } /* 313 */ if (t != null) { /* 314 */ assign(bean, t, context); /* */ } /* */ else { /* 317 */ final LocatorEx loc = new LocatorEx.Snapshot(context.getLocator()); /* 318 */ context.addPatcher( new Patcher() { /* */ public void run() throws SAXException { /* */ try { /* 321 */ Object t = callable.call(); /* 322 */ if (t == null) /* 323 */ context.errorUnresolvedIDREF(bean, idref, loc); /* */ else /* 325 */ TransducedAccessor.IDREFTransducedAccessorImpl.this.assign( bean, t, context); /* */ } /* */ catch (AccessorException e) { /* 328 */ context.handleError(e); /* */ } catch (SAXException e) { /* 330 */ throw e; /* */ } catch (RuntimeException e) { /* 332 */ throw e; /* */ } catch (Exception e) { /* 334 */ throw new SAXException2(e); /* */ } /* */ } /* */ }); /* */ } /* */ }