001    package railo.runtime.query.caster;
002    
003    import java.io.IOException;
004    import java.sql.ResultSet;
005    import java.sql.SQLException;
006    
007    import oracle.sql.OPAQUE;
008    
009    public class _OracleOpaqueCast {
010            public static Object toCFType(ResultSet rst, int columnIndex) throws SQLException, IOException {
011                    validateClasses();
012                    
013                    Object o = rst.getObject(columnIndex);
014                    if(o==null) return null;
015                    
016                    OPAQUE opaque = ((oracle.sql.OPAQUE)o);
017                    if(opaque.getSQLTypeName().equals("SYS.XMLTYPE")){
018                            return oracle.xdb.XMLType.createXML(opaque).getStringVal();
019                    }
020                    return o;
021            }
022    
023            private static void validateClasses() throws IOException {
024                    try {
025                            if(oracle.xdb.XMLType.class==null);
026                            if(oracle.xml.parser.v2.XMLParseException.class==null);
027                    }
028                    catch(Throwable t) {
029                            throw new IOException("the xdb.jar/xmlparserv2.jar is missing, please download at " +
030                                            "http://www.oracle.com/technology/tech/xml/xdk/xdk_java.html and copy it into the railo lib directory");
031                    }
032            }
033    }