@SuppressWarnings("unchecked")
    protected <T extends Source>T createStAXSource(
            Class<T> sourceClass) throws SQLException {

        StAXSource      source      = null;
        Constructor     sourceCtor  = null;
        Reader          reader      = null;
        XMLInputFactory factory     = null;
        XMLEventReader  eventReader = null;

        try {
            factory = XMLInputFactory.newInstance();
        } catch (FactoryConfigurationError ex) {
            throw Exceptions.sourceInstantiation(ex);
        }

        try {
            sourceCtor =
                (sourceClass == null)
                ? StAXSource.class.getConstructor(XMLEventReader.class)
                : sourceClass.getConstructor(XMLEventReader.class);
        } catch (SecurityException ex) {
            throw Exceptions.sourceInstantiation(ex);
        } catch (NoSuchMethodException ex) {
            throw Exceptions.sourceInstantiation(ex);
        }
        reader = getCharacterStreamImpl();

        try {
            eventReader = factory.createXMLEventReader(reader);
        } catch (XMLStreamException ex) {
            throw Exceptions.sourceInstantiation(ex);
        }

        try {
            source = (StAXSource) sourceCtor.newInstance(eventReader);
        } catch (SecurityException ex) {
            throw Exceptions.sourceInstantiation(ex);
        } catch (IllegalArgumentException ex) {
            throw Exceptions.sourceInstantiation(ex);
        } catch (IllegalAccessException ex) {
            throw Exceptions.sourceInstantiation(ex);
        } catch (InstantiationException ex) {
            throw Exceptions.sourceInstantiation(ex);
        } catch (InvocationTargetException ex) {
            throw Exceptions.sourceInstantiation(ex.getTargetException());
        } catch (ClassCastException ex) {
            throw Exceptions.sourceInstantiation(ex);
        }

        return (T) source;
    }
@ SuppressWarnings ( "unchecked" ) protected < T extends Source > T createStAXSource ( Class < T > sourceClass ) throws SQLException { StAXSource source = null ; Constructor sourceCtor = null ; Reader reader = null ; XMLInputFactory factory = null ; XMLEventReader eventReader = null ; try { factory = XMLInputFactory . newInstance ( ) ; } catch ( FactoryConfigurationError ex ) { throw Exceptions . sourceInstantiation ( ex ) ; } try { sourceCtor = ( sourceClass == null ) ? StAXSource . class . getConstructor ( XMLEventReader . class ) : sourceClass . getConstructor ( XMLEventReader . class ) ; } catch ( SecurityException ex ) { throw Exceptions . sourceInstantiation ( ex ) ; } catch ( NoSuchMethodException ex ) { throw Exceptions . sourceInstantiation ( ex ) ; } reader = getCharacterStreamImpl ( ) ; try { eventReader = factory . createXMLEventReader ( reader ) ; } catch ( XMLStreamException ex ) { throw Exceptions . sourceInstantiation ( ex ) ; } try { source = ( StAXSource ) sourceCtor . newInstance ( eventReader ) ; } catch ( SecurityException ex ) { throw Exceptions . sourceInstantiation ( ex ) ; } catch ( IllegalArgumentException ex ) { throw Exceptions . sourceInstantiation ( ex ) ; } catch ( IllegalAccessException ex ) { throw Exceptions . sourceInstantiation ( ex ) ; } catch ( InstantiationException ex ) { throw Exceptions . sourceInstantiation ( ex ) ; } catch ( InvocationTargetException ex ) { throw Exceptions . sourceInstantiation ( ex . getTargetException ( ) ) ; } catch ( ClassCastException ex ) { throw Exceptions . sourceInstantiation ( ex ) ; } return ( T ) source ; }
Retrieves a new StAXSource for reading the XML value designated by this
SQLXML instance. <p>

@param sourceClass The class of the source
@throws java.sql.SQLException if there is an error processing the XML
value or if the given <tt>sourceClass</tt> is not supported.
@return a new StAXSource for reading the XML value designated by this
SQLXML instance