/** * Constructs a new any. * <p> * @param zInterface the type of the any. * @param object the data of the any. * @deprecated as of UDK 2.0 */ public Any(Class zInterface, Object object) { this(new Type(zInterface), object); }
public static TypeDescription getTypeDescription(String typeName) throws ClassNotFoundException { Type t = new Type(typeName); if (t.getTypeClass() == TypeClass.UNKNOWN) { if (typeName.startsWith("[]")) { t = new Type(typeName, TypeClass.SEQUENCE); } else { t = new Type(Class.forName(typeName)); } } return get(t); }
/** Constructs a new any with a given type and value @param type the UNO type of the any. @param object the value of the any. */ public Any(Type type, Object object) { if (type.equals(Type.ANY)) { throw new IllegalArgumentException("Any cannot contain Any"); } _type = type; _object = object; }
public static TypeDescription getTypeDescription(Type type) throws ClassNotFoundException { //TODO: synchronize on type? TypeDescription desc = (TypeDescription) type.getTypeDescription(); if (desc == null) { desc = getTypeDescription(type.getTypeName()); type.setTypeDescription(desc); } return desc; }
private static TypeDescription create(Type type) throws ClassNotFoundException TypeClass typeClass = type.getTypeClass(); String typeName = type.getTypeName(); Class zClass = type.getZClass(); if (zClass == null) { throw new ClassNotFoundException("UNO type " + type); ? new TypeDescription[] { get(new Type(superClass)) } : null; ? null : new TypeDescription[] { get(new Type(zClass.getSuperclass())) }; Class[] interfaces = zClass.getInterfaces(); for (int i = 0; i < interfaces.length; ++i) { Type t = new Type(interfaces[i]); if (t.getTypeClass() == TypeClass.INTERFACE) { TypeDescription desc = getDefinitely(t); TypeDescription[] descs = desc.superTypes;
type = a.getType(); if (TypeClass.ANY_value == type.getTypeClass().getValue()) return convertSimple( destTClass, destType, object ); } else { object = object_; type = (null == object ? m_XInterface_type : new Type( object.getClass() )); int tc = type.getTypeClass().getValue(); int dest_tc = destTClass.getValue(); case TypeClass.ENUM_value: if (tc == TypeClass.ENUM_value && (null == destType || destType.equals( type ) /* optional destType */)) case TypeClass.STRUCT_value: case TypeClass.EXCEPTION_value: if (destType.isSupertypeOf(type)) { return object; case TypeClass.SEQUENCE_value: if (tc == TypeClass.SEQUENCE_value && (null == destType || destType.equals( type ) /* optional destType */))
Type t = new Type(zClass.getComponentType(), alternative); _typeClass = t.getTypeClass() != TypeClass.UNKNOWN ? TypeClass.SEQUENCE : TypeClass.UNKNOWN; _typeName = "[]" + t.getTypeName();
if (new Type(UnknownPropertyException.class).isSupertypeOf( AnyConverter.getType(e.TargetException)) && (p.property.Attributes & PropertyAttribute.OPTIONAL) != 0) boolean isDefaulted = false; while (undoAmbiguous || undoDefaulted || undoOptional) { String typeName = AnyConverter.getType(value).getTypeName(); if (undoAmbiguous && typeName.startsWith("com.sun.star.beans.Ambiguous<"))
return value; switch (type.getTypeClass().getValue()) { case TypeClass.BOOLEAN_value: return Boolean.FALSE; return null; case TypeClass.SEQUENCE_value: return Array.newInstance(type.getZClass().getComponentType(), 0); case TypeClass.STRUCT_value: try { return type.getZClass().getConstructor((Class[]) null). newInstance((Object[]) null); } catch (java.lang.RuntimeException e) { return type.getZClass().getMethod("getDefault", (Class[]) null). invoke(null, (Object[]) null); } catch (java.lang.RuntimeException e) {
if (new Type(UnknownPropertyException.class).isSupertypeOf( AnyConverter.getType(e.TargetException)) && (p.property.Attributes & PropertyAttribute.OPTIONAL) != 0) } else if (new Type(PropertyVetoException.class).isSupertypeOf( AnyConverter.getType(e.TargetException)) && ((p.property.Attributes
/** converts a UNO object (struct, exception, sequence, enum or interface) or an Any containing * these types into an UNO object of a specified destination type. * For interfaces, the argument <em>object</em> is queried for the interface specified * by the <em>type</em> argument. That query (UnoRuntime.queryInterface) might return null, * if the interface is not implemented or a null-ref or a VOID any is given. * * @param type type of the returned value * @param object the object that is to be converted * @return destination object * @throws com.sun.star.lang.IllegalArgumentException * in case conversion is not possible */ static public Object toObject(Type type, Object object) throws com.sun.star.lang.IllegalArgumentException { return convertSimple( type.getTypeClass(), type, object ); } /** converts a UNO object (struct, exception, sequence, enum or interface) or an Any containing
private static TypeDescription get(Type type) throws ClassNotFoundException { String typeName = type.getTypeName(); TypeDescription desc = cache.get(typeName); if (desc == null) { desc = create(type); cache.put(desc); } return desc; }
public Object create(String oid, Type type) { return Proxy.newProxyInstance( getClass().getClassLoader(), new Class[] { com.sun.star.lib.uno.Proxy.class, IQueryInterface.class, type.getZClass() }, new Handler(oid, type)); }
private boolean hasRefHolder(String oid, Type type) { synchronized (refHolders) { LinkedList<RefHolder> l = refHolders.get(oid); if (l != null) { for (RefHolder rh : l) { if (type.isSupertypeOf(rh.getType())) { return true; } } } } return false; }
/** * Dispatches a <code>queryInterface</code> call. * * @return the result of the call (should be an <code>Any</code>). */ protected Object dispatch_queryInterface(Type type) { Class<?> zInterface = type.getTypeDescription().getZClass(); Object result = null; Object face = UnoRuntime.queryInterface(zInterface, _object); // the hell knows why, but empty interfaces a given back as void anys if(face != null) result = new Any(type, face); return result; }
private static TypeDescription create(Type type) throws ClassNotFoundException TypeClass typeClass = type.getTypeClass(); String typeName = type.getTypeName(); Class<?> zClass = type.getZClass(); if (zClass == null) { throw new ClassNotFoundException("UNO type " + type); ? new TypeDescription[] { get(new Type(superClass)) } : null; ? null : new TypeDescription[] { get(new Type(zClass.getSuperclass())) }; Class<?>[] interfaces = zClass.getInterfaces(); for (int i = 0; i < interfaces.length; ++i) { Type t = new Type(interfaces[i]); if (t.getTypeClass() == TypeClass.INTERFACE) { TypeDescription desc = getDefinitely(t); TypeDescription[] descs = desc.superTypes;
type = a.getType(); if (TypeClass.ANY_value == type.getTypeClass().getValue()) return convertSimple( destTClass, destType, object ); type = (null == object ? m_XInterface_type : new Type( object.getClass() )); int tc = type.getTypeClass().getValue(); int dest_tc = destTClass.getValue(); case TypeClass.ENUM_value: if (tc == TypeClass.ENUM_value && (null == destTClass || destType.equals( type ) /* optional destType */)) case TypeClass.STRUCT_value: case TypeClass.EXCEPTION_value: if (destType.isSupertypeOf(type)) { return object; case TypeClass.SEQUENCE_value: if (tc == TypeClass.SEQUENCE_value && (null == destType || destType.equals( type ) /* optional destType */))