diff --git a/ridljar/com/sun/star/lib/uno/typedesc/FieldDescription.java b/ridljar/com/sun/star/lib/uno/typedesc/FieldDescription.java new file mode 100644 index 000000000000..0d3c5dd2b825 --- /dev/null +++ b/ridljar/com/sun/star/lib/uno/typedesc/FieldDescription.java @@ -0,0 +1,94 @@ +/************************************************************************* + * + * $RCSfile: FieldDescription.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: kr $ $Date: 2001-05-08 09:34:17 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package com.sun.star.lib.uno.typedesc; + + +import java.lang.reflect.Field; + + +import com.sun.star.uno.IMethodDescription; +import com.sun.star.uno.ITypeDescription; +import com.sun.star.uno.IFieldDescription; + +import com.sun.star.lib.uno.typeinfo.MemberTypeInfo; + +public class FieldDescription extends MemberTypeInfo implements IFieldDescription { + ITypeDescription _iTypeDescription; + Field _field; + + FieldDescription(MemberTypeInfo memberTypeInfo, Field field) { + super(memberTypeInfo.getName(), memberTypeInfo.getFlags()); + + _field = field; + } + + public ITypeDescription getTypeDescription() { + if(_iTypeDescription == null) + _iTypeDescription = TypeDescription.getTypeDescription(this, getField().getType()); + + return _iTypeDescription; + } + + public Field getField() { + return _field; + } +} diff --git a/ridljar/com/sun/star/lib/uno/typedesc/MethodDescription.java b/ridljar/com/sun/star/lib/uno/typedesc/MethodDescription.java index b5c279140e24..ebbb58a72a1e 100644 --- a/ridljar/com/sun/star/lib/uno/typedesc/MethodDescription.java +++ b/ridljar/com/sun/star/lib/uno/typedesc/MethodDescription.java @@ -2,9 +2,9 @@ * * $RCSfile: MethodDescription.java,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: kr $ $Date: 2001-04-17 15:01:37 $ + * last change: $Author: kr $ $Date: 2001-05-08 09:34:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,12 +65,16 @@ package com.sun.star.lib.uno.typedesc; import java.lang.reflect.Method; +import com.sun.star.uno.IMethodDescription; +import com.sun.star.uno.ITypeDescription; + + import com.sun.star.lib.uno.typeinfo.MethodTypeInfo; import com.sun.star.lib.uno.typeinfo.ParameterTypeInfo; import com.sun.star.lib.uno.typeinfo.TypeInfo; -public class MethodDescription extends MethodTypeInfo { +public class MethodDescription extends MethodTypeInfo implements IMethodDescription { static private final TypeDescription __xInterface = TypeDescription.getTypeDescription(com.sun.star.uno.XInterface.class); static private TypeDescription __xInterfaceArray; static private TypeDescription __xInterfaceArrayArray; @@ -132,15 +136,15 @@ public class MethodDescription extends MethodTypeInfo { _return_sig = TypeDescription.getTypeDescription(this, resultClass); } - public TypeDescription[] getInSignature() { + public ITypeDescription[] getInSignature() { return _in_sig; } - public TypeDescription[] getOutSignature() { + public ITypeDescription[] getOutSignature() { return _out_sig; } - public TypeDescription getReturnSig() { + public ITypeDescription getReturnSignature() { return _return_sig; } diff --git a/ridljar/com/sun/star/lib/uno/typedesc/TypeDescription.java b/ridljar/com/sun/star/lib/uno/typedesc/TypeDescription.java index 337d00fffa8a..14f48256bbc4 100644 --- a/ridljar/com/sun/star/lib/uno/typedesc/TypeDescription.java +++ b/ridljar/com/sun/star/lib/uno/typedesc/TypeDescription.java @@ -2,9 +2,9 @@ * * $RCSfile: TypeDescription.java,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: kr $ $Date: 2001-05-04 11:13:38 $ + * last change: $Author: kr $ $Date: 2001-05-08 09:34:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -72,6 +72,9 @@ import java.lang.reflect.Modifier; import com.sun.star.uno.Any; import com.sun.star.uno.Enum; +import com.sun.star.uno.IFieldDescription; +import com.sun.star.uno.IMethodDescription; +import com.sun.star.uno.ITypeDescription; import com.sun.star.uno.Type; import com.sun.star.uno.TypeClass; import com.sun.star.uno.Union; @@ -94,15 +97,15 @@ import com.sun.star.lib.uno.typeinfo.TypeInfo; * methods, which may be changed or moved in the furture, so please * do not use these methods. *
- * @version $Revision: 1.7 $ $ $Date: 2001-05-04 11:13:38 $ + * @version $Revision: 1.8 $ $ $Date: 2001-05-08 09:34:17 $ * @author Kay Ramme * @since UDK2.0 */ -public class TypeDescription { +public class TypeDescription implements ITypeDescription { /** * When set to true, enables various debugging output. */ - public static final boolean DEBUG = false; + private static final boolean DEBUG = false; public static final TypeDescription __void_TypeDescription = new TypeDescription(TypeClass.VOID, "void", "[Ljava.lang.Void;", void.class); // VOID public static final TypeDescription __char_TypeDescription = new TypeDescription(TypeClass.CHAR, "char", "[C", char.class); // CHAR @@ -121,7 +124,7 @@ public class TypeDescription { public static final TypeDescription __any_TypeDescription = new TypeDescription(TypeClass.ANY, "any", "[Ljava.lang.Object;", Object.class); // ANY - static private final Hashtable __classToTypeDescription = new Hashtable(); + static private final Hashtable __classToTypeDescription = new Hashtable(); static private final Hashtable __typeNameToTypeDescription = new Hashtable(); static private final Hashtable __typeClassToTypeName = new Hashtable(); @@ -528,6 +531,25 @@ public class TypeDescription { return typeDescription; } + static public ITypeDescription getTypeDescription(Type type) throws ClassNotFoundException { + ITypeDescription iTypeDescription = type.getTypeDescription(); + + if(iTypeDescription == null) { + if(type.getZClass() != null) + iTypeDescription = getTypeDescription(type.getZClass()); + + else if(type.getTypeClass() != null && type.getTypeClass() != TypeClass.UNKNOWN) + iTypeDescription = getTypeDescription(type.getTypeClass()); + + else if(type.getTypeName() != null) + iTypeDescription = getTypeDescription(type.getTypeName()); + + type.setTypeDescription(iTypeDescription); + } + + return iTypeDescription; + } + static public TypeDescription getTypeDescription(TypeClass typeClass) { TypeDescription typeDescription = null; @@ -548,11 +570,11 @@ public class TypeDescription { protected int _offset; protected MethodDescription _methodDescriptionsByIndex[]; protected Hashtable _methodDescriptionsByName; - protected Hashtable _memberTypeInfosByName; + protected Hashtable _iFieldDescriptionsByName; - protected Field _fields[]; + protected IFieldDescription _iFieldDescriptions[]; - protected TypeDescription _componentType; + protected ITypeDescription _componentType; private void _initByClass(Class zClass) { @@ -588,7 +610,7 @@ public class TypeDescription { _typeClass = TypeClass.SEQUENCE; _componentType = getTypeDescription(zClass.getComponentType()); - _typeName = "[]" + _componentType._typeName; + _typeName = "[]" + _componentType.getTypeName(); _arrayTypeName = "[" + _class.getName(); } @@ -602,7 +624,6 @@ public class TypeDescription { if(superClass != null && superClass != Object.class) _superType = getTypeDescription(superClass); - _initFields(); _initMemberTypeInfos(); } else { @@ -615,7 +636,6 @@ public class TypeDescription { if(superClass != null && superClass != Object.class) _superType = getTypeDescription(superClass); - _initFields(); _initMemberTypeInfos(); } @@ -642,8 +662,8 @@ public class TypeDescription { _typeClass = TypeClass.SEQUENCE; _componentType = getTypeDescription(typeName.substring(2)); - _class = Class.forName(_componentType._arrayTypeName); - _arrayTypeName = "[" + _componentType._arrayTypeName; + _class = Class.forName(_componentType.getArrayTypeName()); + _arrayTypeName = "[" + _componentType.getArrayTypeName(); __cyclicTypes.remove(typeName); } @@ -653,21 +673,6 @@ public class TypeDescription { } - private void _initFields() { - Field fields[] = _class.getFields(); - - int size = 0; - for(int i = 0; i < fields.length; ++ i) - if((fields[i].getModifiers() & (Modifier.STATIC | Modifier.TRANSIENT)) == 0) // neither static nor transient ? - ++ size; - - _fields = new Field[size]; - size = 0; - for(int i = 0; i < fields.length; ++ i) - if((fields[i].getModifiers() & (Modifier.STATIC | Modifier.TRANSIENT)) == 0) // neither static nor transient ? - _fields[size ++] = fields[i]; - } - private void _initMethodTypeInfos() { if(_methodDescriptionsByName != null) return; @@ -752,96 +757,94 @@ public class TypeDescription { private void _initMemberTypeInfos() { TypeInfo typeInfos[] = __getTypeInfos(_class); - Field fields[] = getFields(); - MemberTypeInfo memberTypeInfos[] = new MemberTypeInfo[fields.length]; + Field fields[] = _class.getFields(); + int index = 0; + IFieldDescription iFieldDescriptions[] = new IFieldDescription[fields.length]; + + _iFieldDescriptionsByName = new Hashtable(); - _memberTypeInfosByName = new Hashtable(); for(int i = 0; i < fields.length; ++ i) { - MemberTypeInfo memberTypeInfo = null; + if((fields[i].getModifiers() & (Modifier.STATIC | Modifier.TRANSIENT)) == 0) { // neither static nor transient ? - if(_superType != null) - memberTypeInfo = _superType.getMemberTypeInfo(fields[i].getName()); + IFieldDescription iFieldDescription = null; - if(memberTypeInfo == null) - memberTypeInfo = __findMemberTypeInfo(typeInfos, fields[i].getName()); + if(_superType != null) + iFieldDescription = _superType.getFieldDescription(fields[i].getName()); - if(memberTypeInfo == null) - memberTypeInfo = new MemberTypeInfo(fields[i].getName(), 0); + if(iFieldDescription == null) { + MemberTypeInfo memberTypeInfo = __findMemberTypeInfo(typeInfos, fields[i].getName()); - _memberTypeInfosByName.put(memberTypeInfo.getName(), memberTypeInfo); + if(memberTypeInfo == null) + memberTypeInfo = new MemberTypeInfo(fields[i].getName(), 0); + + + iFieldDescription = new FieldDescription(memberTypeInfo, fields[i]); + } + + _iFieldDescriptionsByName.put(iFieldDescription.getName(), iFieldDescription); + iFieldDescriptions[index ++] = iFieldDescription; + } } + + _iFieldDescriptions = new IFieldDescription[index]; + System.arraycopy(iFieldDescriptions, 0, _iFieldDescriptions, 0, index); } - public TypeDescription getSuperType() { + public ITypeDescription getSuperType() { return _superType; } - public MethodDescription []getMethodDescriptions() { + public IMethodDescription []getMethodDescriptions() { _initMethodTypeInfos(); - MethodDescription methodDescriptions[] = null; + IMethodDescription iMethodDescriptions[] = null; if(_methodDescriptionsByIndex != null) { - methodDescriptions = new MethodDescription[_methodDescriptionsByIndex.length]; + iMethodDescriptions = new IMethodDescription[_methodDescriptionsByIndex.length]; - System.arraycopy(_methodDescriptionsByIndex, 0, methodDescriptions, 0, _methodDescriptionsByIndex.length); + System.arraycopy(_methodDescriptionsByIndex, 0, iMethodDescriptions, 0, _methodDescriptionsByIndex.length); } - return methodDescriptions; + return iMethodDescriptions; } - public MethodDescription getMethodDescription(int methodId) { + public IMethodDescription getMethodDescription(int methodId) { _initMethodTypeInfos(); - MethodDescription methodDescription = null; + IMethodDescription iMethodDescription = null; int relMethodId = methodId - (_offset - _methodDescriptionsByIndex.length); if(relMethodId >= 0 && relMethodId < _methodDescriptionsByIndex.length) - methodDescription = _methodDescriptionsByIndex[relMethodId]; - else if(_superType != null) - methodDescription = _superType.getMethodDescription(methodId); + iMethodDescription = _methodDescriptionsByIndex[relMethodId]; - return methodDescription; + else if(_superType != null) + iMethodDescription = _superType.getMethodDescription(methodId); + + return iMethodDescription; } - public MethodDescription getMethodDescription(String name) { + public IMethodDescription getMethodDescription(String name) { _initMethodTypeInfos(); - MethodDescription methodDescription = (MethodDescription)_methodDescriptionsByName.get(name); - if(methodDescription == null && _superType != null) - methodDescription = _superType.getMethodDescription(name); + IMethodDescription iMethodDescription = (MethodDescription)_methodDescriptionsByName.get(name); + if(iMethodDescription == null && _superType != null) + iMethodDescription = _superType.getMethodDescription(name); - return methodDescription; + return iMethodDescription; } - public MemberTypeInfo []getMemberTypeInfos() { - MemberTypeInfo memberTypeInfos[] = null; - - if(_memberTypeInfosByName != null) { - memberTypeInfos = new MemberTypeInfo[_memberTypeInfosByName.size()]; - - Enumeration elements = _memberTypeInfosByName.elements(); - int i = 0; - while(elements.hasMoreElements()) { - memberTypeInfos[i ++] = (MemberTypeInfo)elements.nextElement(); - } - } - - return memberTypeInfos; + public IFieldDescription []getFieldDescriptions() { + return _iFieldDescriptions; } - public MemberTypeInfo getMemberTypeInfo(String name) { - MemberTypeInfo memberTypeInfo = (MemberTypeInfo)_memberTypeInfosByName.get(name); - if(memberTypeInfo == null && _superType != null) - memberTypeInfo = _superType.getMemberTypeInfo(name); + public IFieldDescription getFieldDescription(String name) { + IFieldDescription iFieldDescription = (IFieldDescription)_iFieldDescriptionsByName.get(name); + if(iFieldDescription == null && _superType != null) + iFieldDescription = _superType.getFieldDescription(name); - return memberTypeInfo; - } - - public Field []getFields() { - return _fields; + return iFieldDescription; } /** @@ -859,14 +862,14 @@ public class TypeDescription { *
* @return the TypeDescription
*/
- public TypeDescription getComponentType() {
- TypeDescription componentTypeDescription = null;
+ public ITypeDescription getComponentType() {
+ ITypeDescription iTypeDescription = null;
Class componentClass = getZClass().getComponentType();
if(componentClass != null)
- componentTypeDescription = getTypeDescription(componentClass);
+ iTypeDescription = getTypeDescription(componentClass);
- return componentTypeDescription;
+ return iTypeDescription;
}
/**
diff --git a/ridljar/com/sun/star/uno/Any.java b/ridljar/com/sun/star/uno/Any.java
index b5091d5fc629..baa12ab40150 100644
--- a/ridljar/com/sun/star/uno/Any.java
+++ b/ridljar/com/sun/star/uno/Any.java
@@ -2,9 +2,9 @@
*
* $RCSfile: Any.java,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: kr $ $Date: 2001-01-16 17:49:37 $
+ * last change: $Author: kr $ $Date: 2001-05-08 09:34:18 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -67,7 +67,7 @@ package com.sun.star.uno;
* The UNO IDL type any is mapped to java type java.lang.Object
.
* In special cases it is necessary to have an explicit any.
*
- * @version $Revision: 1.2 $ $ $Date: 2001-01-16 17:49:37 $
+ * @version $Revision: 1.3 $ $ $Date: 2001-05-08 09:34:18 $
* @author Kay Ramme
* @since UDK1.0
*/
@@ -95,13 +95,7 @@ public class Any {
* @deprecated as of UDK 2.0
*/
public Any(Class zInterface, Object object) {
- try {
- _type = new Type(zInterface);
- }
- catch(Throwable throwable) { // can not happen!
- System.err.println(getClass().getName() + ".
- * @deprecated as of UDK 2.0
- *
- * @return the type of the any.
- */
- public Class getInterface() {
- Class zClass = null;
-
- try {
- zClass = _type.getDescription();
- }
- catch(ClassNotFoundException classNotFoundException) { // can not happen
- System.err.println(getClass().getName() + ".getInterface - unexpected exception:" + classNotFoundException);
- }
-
- return zClass;
- }
-
/**
* Gets the type of the any.
*
diff --git a/ridljar/com/sun/star/uno/IFieldDescription.java b/ridljar/com/sun/star/uno/IFieldDescription.java
new file mode 100644
index 000000000000..7562ff9aae85
--- /dev/null
+++ b/ridljar/com/sun/star/uno/IFieldDescription.java
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * $RCSfile: IFieldDescription.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kr $ $Date: 2001-05-08 09:34:18 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.uno;
+
+
+import java.lang.reflect.Field;
+
+/**
+ * The
+ * @version $Revision: 1.1 $ $ $Date: 2001-05-08 09:34:18 $
+ * @author Kay Ramme
+ * @since UDK3.0
+ */
+public interface IFieldDescription extends IMemberDescription {
+ /**
+ * Gives the name of this member.
+ *
+ * @return the name
+ */
+ ITypeDescription getTypeDescription();
+
+ /**
+ * Gives native java field of this member.
+ *
+ * @return the java field
+ */
+ Field getField();
+}
diff --git a/ridljar/com/sun/star/uno/IMemberDescription.java b/ridljar/com/sun/star/uno/IMemberDescription.java
new file mode 100644
index 000000000000..d6579866640b
--- /dev/null
+++ b/ridljar/com/sun/star/uno/IMemberDescription.java
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * $RCSfile: IMemberDescription.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kr $ $Date: 2001-05-08 09:34:18 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.uno;
+
+/**
+ * The
+ * @version $Revision: 1.1 $ $ $Date: 2001-05-08 09:34:18 $
+ * @author Kay Ramme
+ * @since UDK3.0
+ */
+public interface IMemberDescription {
+ /**
+ * Gives the name of this member.
+ *
+ * @return the name
+ */
+ String getName();
+
+ /**
+ * Indicates if this member is unsigned.
+ *
+ * @return the unsigned state
+ */
+ boolean isUnsigned();
+
+ /**
+ * Indicates if this member is an any.
+ *
+ * @return the any state
+ */
+ boolean isAny();
+
+ /**
+ * Indicates if this member is an interface.
+ *
+ * @return the interface state
+ */
+ boolean isInterface();
+}
diff --git a/ridljar/com/sun/star/uno/IMethodDescription.java b/ridljar/com/sun/star/uno/IMethodDescription.java
new file mode 100644
index 000000000000..66184da81e20
--- /dev/null
+++ b/ridljar/com/sun/star/uno/IMethodDescription.java
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * $RCSfile: IMethodDescription.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kr $ $Date: 2001-05-08 09:34:18 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.uno;
+
+
+import java.lang.reflect.Method;
+
+
+/**
+ * The
+ * @version $Revision: 1.1 $ $ $Date: 2001-05-08 09:34:18 $
+ * @author Kay Ramme
+ * @since UDK3.0
+ */
+public interface IMethodDescription extends IMemberDescription {
+ /**
+ * Indicates if this method is
+ * @return true means may execute asynchronously .
+ */
+ boolean isOneway();
+
+ /**
+ * Gives the relative index of this method in the declaring
+ * interface.
+ *
+ * @return the realtive index of this method
+ */
+ int getIndex();
+
+ /**
+ * Indicates if this method is const.
+ *
+ * @return true means it is const.
+ */
+ boolean isConst();
+
+ /**
+ * Gives any array of
+ * @return the in parameters
+ */
+ ITypeDescription[] getInSignature();
+
+ /**
+ * Gives any array of
+ * @return the out parameters
+ */
+ ITypeDescription[] getOutSignature();
+
+ /**
+ * Gives the
+ * @return the return type
+ * @return the java methodd
+ */
+ Method getMethod();
+}
diff --git a/ridljar/com/sun/star/uno/ITypeDescription.java b/ridljar/com/sun/star/uno/ITypeDescription.java
new file mode 100644
index 000000000000..7788076df264
--- /dev/null
+++ b/ridljar/com/sun/star/uno/ITypeDescription.java
@@ -0,0 +1,161 @@
+/*************************************************************************
+ *
+ * $RCSfile: ITypeDescription.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kr $ $Date: 2001-05-08 09:34:18 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.uno;
+
+/**
+ * The
+ * @version $Revision: 1.1 $ $ $Date: 2001-05-08 09:34:18 $
+ * @author Kay Ramme
+ * @since UDK3.0
+ */
+public interface ITypeDescription {
+ /**
+ * Gets the
+ * @return the
+ * @return the
+ * @return the
+ * @return the
+ * @return the
+ * @return the
+ * @return the
+ * @return the
+ * @return the type name.
+ */
+ String getTypeName();
+
+ /**
+ * Gets the array type name.
+ *
+ * @return the array type name.
+ */
+ String getArrayTypeName();
+
+ /**
+ * Gets the corresponding java class for the type.
+ *
+ * @return the corresponding java class.
+ */
+ Class getZClass();
+}
diff --git a/ridljar/com/sun/star/uno/Type.java b/ridljar/com/sun/star/uno/Type.java
index d3b1f6464c6c..9e7e64163192 100644
--- a/ridljar/com/sun/star/uno/Type.java
+++ b/ridljar/com/sun/star/uno/Type.java
@@ -2,9 +2,9 @@
*
* $RCSfile: Type.java,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: kr $ $Date: 2001-02-19 10:07:03 $
+ * last change: $Author: kr $ $Date: 2001-05-08 09:34:18 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,9 +62,8 @@
package com.sun.star.uno;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
-//import java.lang.reflect.InstantiationException;
+
+import java.util.Hashtable;
/**
* The Type class represents the IDL builtin type
- * The current implementations holds various
- * @version $Revision: 1.4 $ $ $Date: 2001-02-19 10:07:03 $
+ * @version $Revision: 1.5 $ $ $Date: 2001-05-08 09:34:18 $
* @author Markus Meyer
* @author Kay Ramme
* @since UDK1.0
@@ -87,326 +82,237 @@ public class Type {
/**
* When set to true, enables various debugging output.
*/
- public static final boolean DEBUG = false;
+ private static final boolean DEBUG = false;
- static private Method __getFromClass;
- static private Method __getFromName;
- static private Method __getFromTypeClass;
+ static private final String[] __typeClassToTypeName = new String[]{
+ "void",
+ "char",
+ "boolean",
+ "byte",
+ "short",
+ "unsigned short",
+ "long",
+ "unsigned long",
+ "hyper",
+ "unsigned hyper",
+ "float",
+ "double",
+ "string",
+ "type",
+ "any"
+ };
- /* these variables will be removed with UDK 3.0 */
- static private Method __isTypeClassSimple;
- static private Method __getTypeClass;
- static private Method __getTypeName;
- static private Method __getArrayTypeName;
- static private Method __getZClass;
+ static private final Hashtable __javaClassToTypeName = new Hashtable();
+
+ static private final Hashtable __typeNameToTypeClass = new Hashtable();
static {
- if(DEBUG) System.err.println("##### com.sun.star.uno.Type.
- * @deprecated as of UDK 2.0 (moved to com.sun.star.lib.uno.typedesc.TypeDescription)
- *
- * @return
+ * @since UDK3.0
+ * @param zClass the class of this type
+ */
+ public Type(Class zClass) {
+ _class = zClass;
- protected Object _typeDescription;
+ _typeName = (String)__javaClassToTypeName.get(zClass);
+ if(_typeName != null)
+ _typeClass = (TypeClass)__typeNameToTypeClass.get(_typeName);
- protected void init(Class zClass) {
- Throwable throwable = null;
-
- try {
- _typeDescription = __getFromClass.invoke(null, new Object[]{zClass});
+ else {
+ if(Enum.class.isAssignableFrom(zClass)) {
+ _typeClass = TypeClass.ENUM;
+ _typeName = zClass.getName();
+ }
+ else if(Union.class.isAssignableFrom(zClass)) {
+ _typeClass = TypeClass.UNION;
+ _typeName = zClass.getName();
+ }
+ else if(zClass.isInterface()) {
+ _typeClass = TypeClass.INTERFACE;
+ _typeName = zClass.getName();
+ }
+ else if(zClass.isArray()) {
+ _typeClass = TypeClass.SEQUENCE;
+ _typeName = "[]" + (new Type(_class.getComponentType()).getTypeName());
+ }
+ else if(Throwable.class.isAssignableFrom(zClass)) {
+ _typeClass = TypeClass.EXCEPTION;
+ _typeName = zClass.getName();
+ }
+ else {
+ _typeClass = TypeClass.UNKNOWN;
+ _typeName = zClass.getName();
+ }
}
- catch(InvocationTargetException invocationTargetException) {
- throwable = invocationTargetException.getTargetException();
- }
- catch(IllegalAccessException illegalAccessException) {
- throwable = illegalAccessException;
- }
-
- if(throwable != null)
- throw new java.lang.RuntimeException(getClass().getName() + ".
+ * @since UDK3.0
* @param typeDescription a type description
*/
- public Type(Object typeDescription) {
- _typeDescription = typeDescription;
- }
-
- /**
- * Constructs a new
- */
- public Type() {
- init(void.class);
- }
-
- /**
- * Constructs a new
- * @param zClass the class of this type
- */
- public Type(Class zClass) throws Exception { // the exception is only for compatibility reasons
- init(zClass);
+ public Type(ITypeDescription iTypeDescription) {
+ _typeName = iTypeDescription.getTypeName();
+ _typeClass = iTypeDescription.getTypeClass();
+ _iTypeDescription = iTypeDescription;
}
/**
* Constructs a new
+ * @since UDK3.0
* @param typeName the name of this type
*/
- public Type(String typeName) throws com.sun.star.uno.Exception, ClassNotFoundException { // the com.sun.star.uno.Exception is only for compatibility reasons
- init(typeName);
+ public Type(String typeName) {
+ _typeClass = (TypeClass)__typeNameToTypeClass.get(typeName);
+
+ if(_typeClass == null)
+ _typeClass = TypeClass.UNKNOWN;
+
+ _typeName = typeName;
}
+
/**
* Constructs a new
+ * @since UDK3.0
* @param typeClass the
+ * @since UDK3.0
* @return the type description
*/
- public Object getTypeDescription() {
- return _typeDescription;
+ public ITypeDescription getTypeDescription() {
+ return _iTypeDescription;
}
-
-
/**
- * Gets the IDL
- * @deprecated as of UDK 2.0
- *
- * @return the
- * @deprecated as of UDK 2.0
- *
+ * @since UDK1.0
* @return the type name.
*/
public String getTypeName() {
- String typeName = null;
-
- try {
- typeName = (String)__getTypeName.invoke(_typeDescription, null);
- }
- catch(IllegalAccessException illegalAccessException) {
- }
- catch(InvocationTargetException invocationTargetException) {
- }
-
- return typeName;
- }
-
-
- /**
- * Gets the array type name.
- *
- * @deprecated as of UDK 2.0
- *
- * @return the array type name.
- */
- public String getArrayTypeName() {
- String arrayTypeName = null;
-
- try {
- arrayTypeName = (String)__getArrayTypeName.invoke(_typeDescription, null);
- }
- catch(IllegalAccessException illegalAccessException) {
- }
- catch(InvocationTargetException invocationTargetException) {
- }
-
- return arrayTypeName;
+ return _typeName;
}
/**
- * Gets the corresponding java class for the type.
+ * Gets the class.
+ * Returns
- * @deprecated as of UDK 2.0
- *
- * @return the corresponding java class.
+ * @since UDK1.0
+ * @return the type name.
*/
- public Class getDescription() throws ClassNotFoundException {
- Class zClass = null;
-
- try {
- zClass = (Class)__getZClass.invoke(_typeDescription, null);
- }
- catch(IllegalAccessException illegalAccessException) {
- }
- catch(InvocationTargetException invocationTargetException) {
- }
-
- return zClass;
+ public Class getZClass() {
+ return _class;
}
-
-
+ /**
+ * Gets the typeClass.
+ * Returns
+ * @since UDK1.0
+ * @return the type name.
+ */
+ public TypeClass getTypeClass() {
+ return _typeClass;
+ }
/**
* Compares two types.
*
* @return true, if the given type and this type are equal
*/
- public boolean equals(Object type) {
+ public boolean equals(Object object) {
boolean result = false;
- if(type != null) {
- result = _typeDescription == ((Type)type)._typeDescription;
+ Type type = (Type)object;
- if(!result && _typeDescription != null)
- result = _typeDescription.equals(((Type)type)._typeDescription);
- }
+ if(type != null)
+ result = _typeName.equals(type._typeName);
return result;
}
@@ -417,7 +323,7 @@ public class Type {
* @return the hash code
*/
public int hashCode() {
- return _typeDescription.hashCode();
+ return _typeName.hashCode();
}
/**
@@ -426,7 +332,7 @@ public class Type {
* @return a descriptive IFieldDescription
describes non
+ * method members.
+ * IMemberDescription
is the base interface
+ * for members of UNO types ITypeDescriptions
.
+ * IMethodDescription
allows to examine a method
+ * in detail. It gives a view to java methods from a UNO point.
+ * oneWay
,
+ * respectivly if this method may become executed asynchronously.
+ * ITypeDescription> of
+ * the [in] parameters.
+ *
ITypeDescription> of
+ * the [out] parameters.
+ *
ITypeDescription
of
+ * the return type.
+ * ITypeDescription
+ */
+ ITypeDescription getReturnSignature();
+
+ /**
+ * Gives native java method of this method.
+ * ITypeDescription
allows to examine a type
+ * in detail (e.g. it is used for marshaling/unmarshaling).
+ * ITypeDescription
of the
+ * super, if it exists.
+ * ITypeDescription
.
+ */
+ ITypeDescription getSuperType();
+
+ /**
+ * Gets the IMethodDescription
for every
+ * method, if this type is an interface. Otherwise
+ * returns null
.
+ * IMethodDescription[]
.
+ */
+ IMethodDescription []getMethodDescriptions();
+
+ /**
+ * Gets the IMethodDescription
for the
+ * method with index methodId, if it exists, otherwise
+ * returns null
.
+ * IMethodDescription
.
+ */
+ IMethodDescription getMethodDescription(int methodId);
+
+ /**
+ * Gets the IMethodDescription
for the
+ * method with the name name
, if it exists,
+ * otherwise returns null
.
+ * IMethodDescription
.
+ */
+ IMethodDescription getMethodDescription(String name);
+
+ /**
+ * Gets the IFieldDescription
for every
+ * field, if this type is an interface. Otherwise
+ * returns null
.
+ * IFieldDescription[]
.
+ */
+ IFieldDescription []getFieldDescriptions();
+
+ /**
+ * Gets the IFieldDescription
for the
+ * field with the name name
, if it exists,
+ * otherwise returns null
.
+ * IFieldDescription
.
+ */
+ IFieldDescription getFieldDescription(String name);
+
+ /**
+ * Gets the IDL TypeClass
of the type.
+ * TypeClass
.
+ */
+ TypeClass getTypeClass();
+
+ /**
+ * Gets the component ITypeDescription
if
+ * this is an array type, otherwise returns null
.
+ * ITypeDescription
+ */
+ ITypeDescription getComponentType();
+
+ /**
+ * Gets the type name.
+ * type
.
@@ -72,13 +71,9 @@ import java.lang.reflect.InvocationTargetException;
* The IDL type is not directly mapped to java.lang.Class
,
* because it can be necessary to describe a type which is unknown
* to the java runtime system, e.g. for delaying the need of a class,
- * so that it is possible to generate it one the fly.
+ * so that it is possible to generate it on the fly.
* static
helper
- * methods, which may be changed or moved in the furture, so please
- * do not use these methods.
- * TypeClass
is simple.
+ * Constructs a new Type
which defaults
+ * to void
* true
means simple
- * @param typeClass the IDL typeClass
+ * @since UDK3.0
*/
- static public boolean isTypeClassSimple(TypeClass typeClass) {
- boolean isSimple = false;
-
- try {
- isSimple = ((Boolean)__isTypeClassSimple.invoke(null, new Object[]{typeClass})).booleanValue();
- }
- catch(IllegalAccessException illegalAccessException) {
- }
- catch(InvocationTargetException invocationTargetException) {
- }
-
- return isSimple;
+ public Type() {
+ this(void.class);
}
+ /**
+ * Constructs a new Type
with
+ * the given class
.
+ * Type
with
* the given type description.
* Type
which defaults
- * to void
- * Type
with
- * the given class
.
- * Type
with
* the given type name.
* Type
with
* the given TypeClass
.
* TypeClass
of this type
*/
- public Type(TypeClass typeClass) throws com.sun.star.uno.Exception {
- init(typeClass);
- }
-
- /**
- * @deprecated as of UDK 2.0
- */
- public Type(TypeClass typeClass, String typeName) throws com.sun.star.uno.Exception {
- if(typeName != null) {
- try {
- init(typeName);
- }
- catch(ClassNotFoundException classNotFoundException) {
- throw new Exception(classNotFoundException.toString());
- }
+ public Type(TypeClass typeClass) throws IllegalArgumentException {
+ if(__isTypeClassPrimitive(typeClass)) {
+ _typeClass = typeClass;
+ _typeName = __typeClassToTypeName[typeClass.getValue()];
}
else
- init(typeClass);
+ throw new IllegalArgumentException(typeClass + " is not primitive");
}
/**
- * @deprecated as of UDK 2.0
- */
- public Type(TypeClass typeClass, String typeName, Class zClass) throws com.sun.star.uno.Exception {
- this(typeClass, typeName);
- }
-
-
- /**
- * @deprecated as of UDK 2.0
- */
- public Type(TypeClass typeClass, String typeName, String arrayTypeName, Class zClass) throws com.sun.star.uno.Exception {
- this(typeClass, typeName);
- }
-
-
- /**
- * Gives the the type description of this type.
+ * Gives the type description of this type.
* TypeClass
of the type.
+ * Sets the type description for this type.
* TypeClass
.
+ * @since UDK3.0
+ * @return the type description
*/
- public TypeClass getTypeClass() {
- TypeClass typeClass = null;
-
- try {
- typeClass = (TypeClass)__getTypeClass.invoke(_typeDescription, null);
- }
- catch(IllegalAccessException illegalAccessException) {
- }
- catch(InvocationTargetException invocationTargetException) {
- }
-
- return typeClass;
+ public void setTypeDescription(ITypeDescription iTypeDescription) {
+ _iTypeDescription = iTypeDescription;
}
/**
* Gets the type name.
+ * Returns null
if this
+ * type has not been constructed by name.
* null
if this
+ * type has not been constructed by Class
.
* null
if this
+ * type has not been constructed by TypeClass
.
+ * String
*/
public String toString() {
- return "Type<" + _typeDescription + ">";
+ return "Type<" + _typeName + ">";
}
}