summaryrefslogtreecommitdiff
path: root/ridljar/com/sun/star/uno
diff options
context:
space:
mode:
authorKay Ramme <kr@openoffice.org>2001-05-08 08:34:18 +0000
committerKay Ramme <kr@openoffice.org>2001-05-08 08:34:18 +0000
commit2938ec91445bf68be60ea0382003fa83d5491e6e (patch)
tree51417da010d8fd02bebfad7c2b588ec68c0cf0d6 /ridljar/com/sun/star/uno
parent4cc8b7efdd23e69adaac055455bdc3d44dac225f (diff)
type clean up
Diffstat (limited to 'ridljar/com/sun/star/uno')
-rw-r--r--ridljar/com/sun/star/uno/Any.java34
-rw-r--r--ridljar/com/sun/star/uno/IFieldDescription.java89
-rw-r--r--ridljar/com/sun/star/uno/IMemberDescription.java100
-rw-r--r--ridljar/com/sun/star/uno/IMethodDescription.java130
-rw-r--r--ridljar/com/sun/star/uno/ITypeDescription.java161
-rw-r--r--ridljar/com/sun/star/uno/Type.java408
6 files changed, 641 insertions, 281 deletions
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 <code>java.lang.Object</code>.
* In special cases it is necessary to have an explicit any.
* <p>
- * @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() + ".<init> - unexpected exception:" + throwable);
- }
-
+ _type = new Type(zInterface);
_object = object;
}
@@ -113,26 +107,6 @@ public class Any {
/**
* Gets the type of the any.
* <p>
- * @deprecated as of UDK 2.0
- * <p>
- * @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.
- * <p>
* @return the type of the any.
*/
public Type getType() {
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 <code>IFieldDescription</code> describes non
+ * method members.
+ * <p>
+ * @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.
+ * <p>
+ * @return the name
+ */
+ ITypeDescription getTypeDescription();
+
+ /**
+ * Gives native java field of this member.
+ * <p>
+ * @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 <code>IMemberDescription</code> is the base interface
+ * for members of UNO types <code>ITypeDescriptions</code>.
+ * <p>
+ * @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.
+ * <p>
+ * @return the name
+ */
+ String getName();
+
+ /**
+ * Indicates if this member is unsigned.
+ * <p>
+ * @return the unsigned state
+ */
+ boolean isUnsigned();
+
+ /**
+ * Indicates if this member is an any.
+ * <p>
+ * @return the any state
+ */
+ boolean isAny();
+
+ /**
+ * Indicates if this member is an interface.
+ * <p>
+ * @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 <code>IMethodDescription</code> allows to examine a method
+ * in detail. It gives a view to java methods from a UNO point.
+ * <p>
+ * @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 <code>oneWay</code>,
+ * respectivly if this method may become executed asynchronously.
+ * <p>
+ * @return true means may execute asynchronously .
+ */
+ boolean isOneway();
+
+ /**
+ * Gives the relative index of this method in the declaring
+ * interface.
+ * <p>
+ * @return the realtive index of this method
+ */
+ int getIndex();
+
+ /**
+ * Indicates if this method is const.
+ * <p>
+ * @return true means it is const.
+ */
+ boolean isConst();
+
+ /**
+ * Gives any array of <code>ITypeDescription> of
+ * the [in] parameters.
+ * <p>
+ * @return the in parameters
+ */
+ ITypeDescription[] getInSignature();
+
+ /**
+ * Gives any array of <code>ITypeDescription> of
+ * the [out] parameters.
+ * <p>
+ * @return the out parameters
+ */
+ ITypeDescription[] getOutSignature();
+
+ /**
+ * Gives the <code>ITypeDescription</code> of
+ * the return type.
+ * <p>
+ * @return the return type <code>ITypeDescription</code>
+ */
+ ITypeDescription getReturnSignature();
+
+ /**
+ * Gives native java method of this method.
+ * <p>
+ * @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 <code>ITypeDescription</code> allows to examine a type
+ * in detail (e.g. it is used for marshaling/unmarshaling).
+ * <p>
+ * @version $Revision: 1.1 $ $ $Date: 2001-05-08 09:34:18 $
+ * @author Kay Ramme
+ * @since UDK3.0
+ */
+public interface ITypeDescription {
+ /**
+ * Gets the <code>ITypeDescription</code> of the
+ * super, if it exists.
+ * <p>
+ * @return the <code>ITypeDescription</code>.
+ */
+ ITypeDescription getSuperType();
+
+ /**
+ * Gets the <code>IMethodDescription</code> for every
+ * method, if this type is an interface. Otherwise
+ * returns <code>null</code>.
+ * <p>
+ * @return the <code>IMethodDescription[]</code>.
+ */
+ IMethodDescription []getMethodDescriptions();
+
+ /**
+ * Gets the <code>IMethodDescription</code> for the
+ * method with index methodId, if it exists, otherwise
+ * returns <code>null</code>.
+ * <p>
+ * @return the <code>IMethodDescription</code>.
+ */
+ IMethodDescription getMethodDescription(int methodId);
+
+ /**
+ * Gets the <code>IMethodDescription</code> for the
+ * method with the name <code>name</code>, if it exists,
+ * otherwise returns <code>null</code>.
+ * <p>
+ * @return the <code>IMethodDescription</code>.
+ */
+ IMethodDescription getMethodDescription(String name);
+
+ /**
+ * Gets the <code>IFieldDescription</code> for every
+ * field, if this type is an interface. Otherwise
+ * returns <code>null</code>.
+ * <p>
+ * @return the <code>IFieldDescription[]</code>.
+ */
+ IFieldDescription []getFieldDescriptions();
+
+ /**
+ * Gets the <code>IFieldDescription</code> for the
+ * field with the name <code>name</code>, if it exists,
+ * otherwise returns <code>null</code>.
+ * <p>
+ * @return the <code>IFieldDescription</code>.
+ */
+ IFieldDescription getFieldDescription(String name);
+
+ /**
+ * Gets the IDL <code>TypeClass</code> of the type.
+ * <p>
+ * @return the <code>TypeClass</code>.
+ */
+ TypeClass getTypeClass();
+
+ /**
+ * Gets the component <code>ITypeDescription</code> if
+ * this is an array type, otherwise returns <code>null</code>.
+ * <p>
+ * @return the <code>ITypeDescription</code>
+ */
+ ITypeDescription getComponentType();
+
+ /**
+ * Gets the type name.
+ * <p>
+ * @return the type name.
+ */
+ String getTypeName();
+
+ /**
+ * Gets the array type name.
+ * <p>
+ * @return the array type name.
+ */
+ String getArrayTypeName();
+
+ /**
+ * Gets the corresponding java class for the type.
+ * <p>
+ * @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 <code>type</code>.
@@ -72,13 +71,9 @@ import java.lang.reflect.InvocationTargetException;
* The IDL type is not directly mapped to <code>java.lang.Class</code>,
* 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.
- * <p>
- * The current implementations holds various <code>static</code> helper
- * methods, which may be changed or moved in the furture, so please
- * do not use these methods.
+ * so that it is possible to generate it on the fly.
* <p>
- * @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;
-
- static private Method __getFromClass;
- static private Method __getFromName;
- static private Method __getFromTypeClass;
-
- /* 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;
+ private static final boolean DEBUG = false;
+
+ 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"
+ };
+
+ 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.<sinit>");
-
- Throwable throwable = null;
-
- try {
- Class typeDesc_Class = Class.forName("com.sun.star.lib.uno.typedesc.TypeDescription");
-
- __getFromName = typeDesc_Class.getMethod("getTypeDescription", new Class[]{String.class});
- __getFromClass = typeDesc_Class.getMethod("getTypeDescription", new Class[]{Class.class});
- __getFromTypeClass = typeDesc_Class.getMethod("getTypeDescription", new Class[]{TypeClass.class});
-
- __isTypeClassSimple = typeDesc_Class.getMethod("isTypeClassSimple", new Class[]{TypeClass.class});
-
- __getTypeClass = typeDesc_Class.getMethod("getTypeClass", new Class[]{});
- __getTypeName = typeDesc_Class.getMethod("getTypeName", new Class[]{});
- __getArrayTypeName = typeDesc_Class.getMethod("getArrayTypeName", new Class[]{});
- __getZClass = typeDesc_Class.getMethod("getZClass", new Class[]{});
- }
- catch(NoSuchMethodException noSuchMethodException) {
- throwable = noSuchMethodException;
- }
- catch(ClassNotFoundException classNotFoundException) {
- throwable = classNotFoundException;
- }
-
- if(throwable != null) {
- String message = "com.sun.star.uno.Type.<sinit> - exception:" + throwable;
- throwable.printStackTrace();
- System.err.println(message);
- throw new java.lang.RuntimeException(message);
- }
- }
-
-
-
- /**
- * Determines if the given <code>TypeClass</code> is simple.
- * <p>
- * @deprecated as of UDK 2.0 (moved to com.sun.star.lib.uno.typedesc.TypeDescription)
- * <p>
- * @return <code>true</code> means simple
- * @param typeClass the IDL typeClass
- */
- 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;
- }
-
-
-
- protected Object _typeDescription;
-
- protected void init(Class zClass) {
- Throwable throwable = null;
-
- try {
- _typeDescription = __getFromClass.invoke(null, new Object[]{zClass});
- }
- catch(InvocationTargetException invocationTargetException) {
- throwable = invocationTargetException.getTargetException();
- }
- catch(IllegalAccessException illegalAccessException) {
- throwable = illegalAccessException;
- }
-
- if(throwable != null)
- throw new java.lang.RuntimeException(getClass().getName() + ".<init>(Class) - fatal - couldn't create typedescription - " + throwable + " " + zClass);
+ for(int i = 0; i < __typeClassToTypeName.length; ++ i)
+ __typeNameToTypeClass.put(__typeClassToTypeName[i], TypeClass.fromInt(i));
+
+ __javaClassToTypeName.put(Void.class, "void");
+ __javaClassToTypeName.put(void.class, "void");
+ __javaClassToTypeName.put(Character.class, "char");
+ __javaClassToTypeName.put(char.class, "char");
+ __javaClassToTypeName.put(Boolean.class, "boolean");
+ __javaClassToTypeName.put(boolean.class, "boolean");
+ __javaClassToTypeName.put(Byte.class, "byte");
+ __javaClassToTypeName.put(byte.class, "byte");
+ __javaClassToTypeName.put(Short.class, "short");
+ __javaClassToTypeName.put(short.class, "short");
+ __javaClassToTypeName.put(Integer.class, "long");
+ __javaClassToTypeName.put(int.class, "long");
+ __javaClassToTypeName.put(Long.class, "hyper");
+ __javaClassToTypeName.put(long.class, "hyper");
+ __javaClassToTypeName.put(Float.class, "float");
+ __javaClassToTypeName.put(float.class, "float");
+ __javaClassToTypeName.put(Double.class, "double");
+ __javaClassToTypeName.put(double.class, "double");
+ __javaClassToTypeName.put(String.class, "string");
+ __javaClassToTypeName.put(Type.class, "type");
+ __javaClassToTypeName.put(Any.class, "any");
+ __javaClassToTypeName.put(Object.class, "any");
}
- protected void init(TypeClass typeClass) {
- Throwable throwable = null;
-
- try {
- _typeDescription = __getFromTypeClass.invoke(null, new Object[]{typeClass});
- }
- catch(InvocationTargetException invocationTargetException) {
- throwable = invocationTargetException.getTargetException();
- }
- catch(IllegalAccessException illegalAccessException) {
- throwable = illegalAccessException;
- }
-
- if(throwable != null)
- throw new java.lang.RuntimeException(getClass().getName() + ".<init>(TypeClass) - fatal - couldn't create typedescription - " + throwable + " " + typeClass);
+ static private boolean __isTypeClassPrimitive(TypeClass typeClass) {
+ return typeClass.getValue() < 15;
}
- protected void init(String typeName) throws ClassNotFoundException {
- Throwable throwable = null;
- try {
- _typeDescription = __getFromName.invoke(null, new Object[]{typeName});
- }
- catch(InvocationTargetException invocationTargetException) {
- throwable = invocationTargetException.getTargetException();
- }
- catch(IllegalAccessException illegalAccessException) {
- throwable = illegalAccessException;
- }
+ protected String _typeName;
+ protected Class _class;
+ protected TypeClass _typeClass;
- if(throwable != null)
- throw new java.lang.ClassNotFoundException(getClass().getName() + ".<init>(String) - fatal - couldn't create typedescription - " + throwable);
- }
+ protected ITypeDescription _iTypeDescription;
- /**
- * Constructs a new <code>Type</code> with
- * the given type description.
- * <p>
- * @param typeDescription a type description
- */
- public Type(Object typeDescription) {
- _typeDescription = typeDescription;
- }
/**
* Constructs a new <code>Type</code> which defaults
* to <code>void</code>
* <p>
+ * @since UDK3.0
*/
public Type() {
- init(void.class);
+ this(void.class);
}
+
/**
* Constructs a new <code>Type</code> with
* the given <code>class</code>.
* <p>
+ * @since UDK3.0
* @param zClass the class of this type
*/
- public Type(Class zClass) throws Exception { // the exception is only for compatibility reasons
- init(zClass);
+ public Type(Class zClass) {
+ _class = zClass;
+
+ _typeName = (String)__javaClassToTypeName.get(zClass);
+ if(_typeName != null)
+ _typeClass = (TypeClass)__typeNameToTypeClass.get(_typeName);
+
+ 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();
+ }
+ }
}
/**
* Constructs a new <code>Type</code> with
- * the given type name.
+ * the given type description.
* <p>
- * @param typeName the name of this type
+ * @since UDK3.0
+ * @param typeDescription a type description
*/
- 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(ITypeDescription iTypeDescription) {
+ _typeName = iTypeDescription.getTypeName();
+ _typeClass = iTypeDescription.getTypeClass();
+ _iTypeDescription = iTypeDescription;
}
/**
* Constructs a new <code>Type</code> with
- * the given <code>TypeClass</code>.
+ * the given type name.
* <p>
- * @param typeClass the <code>TypeClass</code> of this type
+ * @since UDK3.0
+ * @param typeName the name of this type
*/
- public Type(TypeClass typeClass) throws com.sun.star.uno.Exception {
- init(typeClass);
- }
+ public Type(String typeName) {
+ _typeClass = (TypeClass)__typeNameToTypeClass.get(typeName);
- /**
- * @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());
- }
- }
- else
- init(typeClass);
- }
+ if(_typeClass == null)
+ _typeClass = TypeClass.UNKNOWN;
- /**
- * @deprecated as of UDK 2.0
- */
- public Type(TypeClass typeClass, String typeName, Class zClass) throws com.sun.star.uno.Exception {
- this(typeClass, typeName);
+ _typeName = typeName;
}
/**
- * @deprecated as of UDK 2.0
+ * Constructs a new <code>Type</code> with
+ * the given <code>TypeClass</code>.
+ * <p>
+ * @since UDK3.0
+ * @param typeClass the <code>TypeClass</code> of this type
*/
- public Type(TypeClass typeClass, String typeName, String arrayTypeName, Class zClass) throws com.sun.star.uno.Exception {
- this(typeClass, typeName);
+ public Type(TypeClass typeClass) throws IllegalArgumentException {
+ if(__isTypeClassPrimitive(typeClass)) {
+ _typeClass = typeClass;
+ _typeName = __typeClassToTypeName[typeClass.getValue()];
+ }
+ else
+ throw new IllegalArgumentException(typeClass + " is not primitive");
}
-
/**
- * Gives the the type description of this type.
+ * Gives the type description of this type.
* <p>
+ * @since UDK3.0
* @return the type description
*/
- public Object getTypeDescription() {
- return _typeDescription;
+ public ITypeDescription getTypeDescription() {
+ return _iTypeDescription;
}
-
-
/**
- * Gets the IDL <code>TypeClass</code> of the type.
+ * Sets the type description for this type.
* <p>
- * @deprecated as of UDK 2.0
- * <p>
- * @return the <code>TypeClass</code>.
+ * @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 <code>null</code> if this
+ * type has not been constructed by name.
* <p>
- * @deprecated as of UDK 2.0
- * <p>
+ * @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;
+ return _typeName;
}
-
/**
- * Gets the array type name.
+ * Gets the class.
+ * Returns <code>null</code> if this
+ * type has not been constructed by <code>Class</code>.
* <p>
- * @deprecated as of UDK 2.0
- * <p>
- * @return the array type name.
+ * @since UDK1.0
+ * @return the type name.
*/
- public String getArrayTypeName() {
- String arrayTypeName = null;
-
- try {
- arrayTypeName = (String)__getArrayTypeName.invoke(_typeDescription, null);
- }
- catch(IllegalAccessException illegalAccessException) {
- }
- catch(InvocationTargetException invocationTargetException) {
- }
-
- return arrayTypeName;
+ public Class getZClass() {
+ return _class;
}
/**
- * Gets the corresponding java class for the type.
- * <p>
- * @deprecated as of UDK 2.0
+ * Gets the typeClass.
+ * Returns <code>null</code> if this
+ * type has not been constructed by <code>TypeClass</code>.
* <p>
- * @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 TypeClass getTypeClass() {
+ return _typeClass;
}
-
-
-
/**
* Compares two types.
* <p>
* @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 <code>String</code>
*/
public String toString() {
- return "Type<" + _typeDescription + ">";
+ return "Type<" + _typeName + ">";
}
}