summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/jdbc/InputStream.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/drivers/jdbc/InputStream.cxx')
-rw-r--r--connectivity/source/drivers/jdbc/InputStream.cxx95
1 files changed, 18 insertions, 77 deletions
diff --git a/connectivity/source/drivers/jdbc/InputStream.cxx b/connectivity/source/drivers/jdbc/InputStream.cxx
index 32e893f5c665..522c1f67973e 100644
--- a/connectivity/source/drivers/jdbc/InputStream.cxx
+++ b/connectivity/source/drivers/jdbc/InputStream.cxx
@@ -51,27 +51,14 @@ java_io_InputStream::~java_io_InputStream()
SDBThreadAttach::releaseRef();
}
-jclass java_io_InputStream::getMyClass()
+jclass java_io_InputStream::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t;
- if( !t.pEnv ) return (jclass)NULL;
- jclass tempClass = t.pEnv->FindClass( "java/io/InputStream" );
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/io/InputStream");
return theClass;
}
-void java_io_InputStream::saveClassRef( jclass pClass )
-{
- if( pClass==NULL )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
sal_Int32 SAL_CALL java_io_InputStream::readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
{
@@ -80,61 +67,19 @@ sal_Int32 SAL_CALL java_io_InputStream::readSomeBytes( ::com::sun::star::uno::Se
void SAL_CALL java_io_InputStream::skipBytes( sal_Int32 nBytesToSkip ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
{
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- static const char * cSignature = "(I)I";
- static const char * cMethodName = "skip";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- out = t.pEnv->CallIntMethod( object, mID,nBytesToSkip);
- ThrowSQLException(t.pEnv,*this);
- }
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callIntMethodWithIntArg("skip",mID,nBytesToSkip);
}
sal_Int32 SAL_CALL java_io_InputStream::available( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
{
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- static const char * cSignature = "()Z";
- static const char * cMethodName = "available";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- out = t.pEnv->CallBooleanMethod( object, mID);
- ThrowSQLException(t.pEnv,*this);
- }
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callIntMethod("available",mID);
}
void SAL_CALL java_io_InputStream::closeInput( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
{
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- static const char * cSignature = "()V";
- static const char * cMethodName = "close";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- t.pEnv->CallVoidMethod( object, mID);
- ThrowSQLException(t.pEnv,*this);
- }
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callVoidMethod("close",mID);
}
// -----------------------------------------------------
sal_Int32 SAL_CALL java_io_InputStream::readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
@@ -143,25 +88,21 @@ sal_Int32 SAL_CALL java_io_InputStream::readBytes( ::com::sun::star::uno::Sequen
throw ::com::sun::star::io::BufferSizeExceededException();
jint out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
jbyteArray pByteArray = t.pEnv->NewByteArray(nBytesToRead);
static const char * cSignature = "([BII)I";
static const char * cMethodName = "read";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = t.pEnv->CallIntMethod( object, mID, pByteArray, 0, nBytesToRead );
+ if ( !out )
+ ThrowSQLException(t.pEnv,*this);
+ if(out > 0)
{
- out = t.pEnv->CallIntMethod( object, mID, pByteArray, 0, nBytesToRead );
- if ( !out )
- ThrowSQLException(t.pEnv,*this);
- if(out > 0)
- {
- jboolean p = sal_False;
- memcpy(aData.getArray(),t.pEnv->GetByteArrayElements(pByteArray,&p),out);
- }
+ jboolean p = sal_False;
+ memcpy(aData.getArray(),t.pEnv->GetByteArrayElements(pByteArray,&p),out);
}
t.pEnv->DeleteLocalRef((jbyteArray)pByteArray);
} //t.pEnv