summaryrefslogtreecommitdiff
path: root/jurt/com
diff options
context:
space:
mode:
authorJoachim Lingner <jl@openoffice.org>2002-08-08 13:34:27 +0000
committerJoachim Lingner <jl@openoffice.org>2002-08-08 13:34:27 +0000
commit04aa8014c256ca530999f66f3d4badeec17c85ea (patch)
tree853949a55beab1a6476a90528ea894272cbe51ba /jurt/com
parentffe9020305759d3fd66d4cfffed4169aeb152b74 (diff)
#99466# isObject and toObject now treat an Any with interface type and null reference as vali objects,i.e. do not throw IllegalArgumentException
Diffstat (limited to 'jurt/com')
-rw-r--r--jurt/com/sun/star/uno/AnyConverter.java27
1 files changed, 24 insertions, 3 deletions
diff --git a/jurt/com/sun/star/uno/AnyConverter.java b/jurt/com/sun/star/uno/AnyConverter.java
index ef6917d74d9d..51af79904a72 100644
--- a/jurt/com/sun/star/uno/AnyConverter.java
+++ b/jurt/com/sun/star/uno/AnyConverter.java
@@ -99,13 +99,25 @@ public class AnyConverter
}
/** checks if the any contains a value which implements interfaces.
+ If <em>object</em> is an any with an interface type, then true is also returned if the any contains
+ a null reference. This is because interfacec are allowed to have a null value contrary
+ to other UNO types.
@param object the object to check
@return true when the any contains an object which implements interfaces, false otherwise.
*/
static public boolean isObject(Object object){
boolean retVal= false;
if (object instanceof Any)
+ {
+ if( ((Any) object).getObject() == null )
+ {
+ Type _t= ((Any) object).getType();
+ if (_t.getTypeClass() == TypeClass.INTERFACE)
+ return true;
+ }
object= ((Any) object).getObject();
+
+ }
if (object != null && object.getClass().getInterfaces().length > 0)
retVal= true;
return retVal;
@@ -233,6 +245,8 @@ public class AnyConverter
* The argument <em>object</em> is examined for implemented interfaces. If it has implemented interfaces
* then the method attempts to query for the interface specified by the <em>type</em> argument. That query
* (UnoRuntime.queryInterface) might return null, if the interface is not implemented.
+ * If <em>object</em> is an Any which contains an interface type and a null reference,
+ * then null is returned.
*
* @param type the Type of the returned value
* @param object the object that is to be converted
@@ -254,8 +268,8 @@ public class AnyConverter
}
/**
- Examines the argument |object| if is correspond to the type in argument |what|.
- |object| is either matched directly against the type or if it is an any then the
+ Examines the argument <em>object</em> if is correspond to the type in argument <em>what</em>.
+ <em>object</em> is either matched directly against the type or if it is an any then the
contained object is matched against the type.
*/
static private boolean containsType( TypeClass what, Object object){
@@ -277,7 +291,14 @@ public class AnyConverter
int srcTypeValue=0;
if (src instanceof Any)
- _src= ((Any) src).getObject();
+ {
+ Any _a= (Any) src;
+ // If the any contains an Interface with a null reference then it is valid and
+ // null is returned
+ if ( _a.getObject() == null && _a.getType().getTypeClass() == TypeClass.INTERFACE)
+ return null;
+ _src= _a.getObject();
+ }
if (_src != null)
{