/** * Reports an exception found during the unmarshalling to the user. * This method is a convenience method that calls into * {@link #handleEvent(ValidationEvent, boolean)} */ public void handleError(Exception e) throws SAXException { handleError(e,true); }
/** * This method is called by the generated derived class * when a datatype parse method throws an exception. */ protected static void handleParseConversionException(UnmarshallingContext.State state, Exception e) throws SAXException { // wrap it into a ParseConversionEvent and report it state.getContext().handleError(e); } }
public URI parse(CharSequence text) throws SAXException { try { return new URI(text.toString()); } catch (URISyntaxException e) { UnmarshallingContext.getInstance().handleError(e); return null; } }
public URI parse(CharSequence text) throws SAXException { try { return new URI(text.toString()); } catch (URISyntaxException e) { UnmarshallingContext.getInstance().handleError(e); return null; } }
public Object createInstance() throws SAXException { try { return method.invoke(factorInstance); } catch (IllegalAccessException e) { getInstance().handleError(e,false); } catch (InvocationTargetException e) { getInstance().handleError(e,false); } return null; // can never be executed } }
private void invokeUnmarshallCallback(Method m, Object child, UnmarshallerImpl unm, Object parent) throws SAXException { try { m.invoke(child,unm,parent); } catch (IllegalAccessException e) { UnmarshallingContext.getInstance().handleError(e, false); } catch (InvocationTargetException e) { UnmarshallingContext.getInstance().handleError(e, false); } }
public XMLGregorianCalendar parse(CharSequence lexical) throws SAXException { try { return DatatypeConverterImpl.getDatatypeFactory() .newXMLGregorianCalendar(lexical.toString().trim()); // (.trim() - issue 396) } catch (Exception e) { UnmarshallingContext.getInstance().handleError(e); return null; } }
private void assign( BeanT bean, TargetT t, UnmarshallingContext context ) throws AccessorException { if(!targetType.isInstance(t)) context.handleError(Messages.UNASSIGNABLE_TYPE.format(targetType,t.getClass())); else acc.set(bean,t); }
@Override public void text(UnmarshallingContext.State state, CharSequence text) throws SAXException { if(text.length()==0) return; // there's no point in creating an empty Text node in DOM. try { State s = (State) state.getTarget(); s.handler.characters(text.toString().toCharArray(),0,text.length()); } catch( SAXException e ) { state.getContext().handleError(e); throw e; } }
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 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 Image parse(CharSequence text) throws SAXException { try { InputStream is; if(text instanceof Base64Data) is = ((Base64Data)text).getInputStream(); else is = new ByteArrayInputStream(decodeBase64(text)); // TODO: buffering is inefficient // technically we should check the MIME type here, but // normally images can be content-sniffed. // so the MIME type check will only make us slower and draconian, both of which // JAXB 2.0 isn't interested. try { return ImageIO.read(is); } finally { is.close(); } } catch (IOException e) { UnmarshallingContext.getInstance().handleError(e); return null; } }
public URL parse(CharSequence text) throws SAXException { TODO.checkSpec("JSR222 Issue #42"); try { return new URL(WhiteSpaceProcessor.trim(text).toString()); } catch (MalformedURLException e) { UnmarshallingContext.getInstance().handleError(e); return null; } } public String print(URL v) {
public void run() throws SAXException { try { TargetT t = (TargetT)callable.call(); if(t==null) { context.errorUnresolvedIDREF(bean,idref,loc); } else { assign(bean,t,context); } } catch (AccessorException e) { context.handleError(e); } catch (SAXException e) {// from callable.call throw e; } catch (RuntimeException e) {// from callable.call throw e; } catch (Exception e) {// from callable.call throw new SAXException2(e); } } });
public QName parse(CharSequence text) throws SAXException { try { return DatatypeConverterImpl._parseQName(text.toString(),UnmarshallingContext.getInstance()); } catch (IllegalArgumentException e) { UnmarshallingContext.getInstance().handleError(e); return null; } }
public Class parse(CharSequence text) throws SAXException { TODO.checkSpec("JSR222 Issue #42"); try { String name = WhiteSpaceProcessor.trim(text).toString(); ClassLoader cl = UnmarshallingContext.getInstance().classLoader; if(cl==null) cl = Thread.currentThread().getContextClassLoader(); if(cl!=null) return cl.loadClass(name); else return Class.forName(name); } catch (ClassNotFoundException e) { UnmarshallingContext.getInstance().handleError(e); return null; } } public String print(Class v) {
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; }
@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()); } }
public Source parse(CharSequence text) throws SAXException { try { if(text instanceof Base64Data) return new DataSourceSource( ((Base64Data)text).getDataHandler() ); else return new DataSourceSource(new ByteArrayDataSource(decodeBase64(text), UnmarshallingContext.getInstance().getXMIMEContentType())); } catch (MimeTypeParseException e) { UnmarshallingContext.getInstance().handleError(e); return null; } }
@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; } }