/** 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
/** * 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. * * <p> For interfaces, the argument <em>object</em> is queried for the interface * specified by the <em>type</em> argument.</p> * * <p>That query (UnoRuntime.queryInterface) might return null, if the interface * is not implemented or a null-ref or a VOID any is given.</p> * * @param type type of the returned value. * @param object the object that is to be converted. * @throws com.sun.star.lang.IllegalArgumentException in case conversion is * not possible. * * @return destination object. */ public static Object toObject(Type type, Object object) throws com.sun.star.lang.IllegalArgumentException { return convertSimple( type.getTypeClass(), type, object ); } /**
/** checks if the any contains an interface, struct, exception, sequence or enum. 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 interfaces are allowed to have a null value contrary to other UNO types. @param object the object to check @return true if the any contains an object */ static public boolean isObject(Object object) { int tc = getType(object).getTypeClass().getValue(); return (TypeClass.INTERFACE_value == tc || TypeClass.STRUCT_value == tc || TypeClass.EXCEPTION_value == tc || TypeClass.SEQUENCE_value == tc || TypeClass.ENUM_value == tc); }
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); }
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); }
/** * Checks if the any contains an interface, struct, exception, sequence or enum. * * <p>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 interfaces * are allowed to have a null value contrary to other UNO types.</p> * * @param object the object to check. * @return true if the any contains an object. */ public static boolean isObject(Object object) { int tc = getType(object).getTypeClass().getValue(); return (TypeClass.INTERFACE_value == tc || TypeClass.STRUCT_value == tc || TypeClass.EXCEPTION_value == tc || TypeClass.SEQUENCE_value == tc || TypeClass.ENUM_value == tc); }
/** 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){ return (getType(object).getTypeClass().getValue() == what.getValue()); }
_typeClass = t.getTypeClass() != TypeClass.UNKNOWN ? TypeClass.SEQUENCE : TypeClass.UNKNOWN; _typeName = "[]" + t.getTypeName();
/** * Examines the argument <em>object</em> if is correspond to the type in * argument <em>what</em>. * * <p><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.</p> */ private static boolean containsType( TypeClass what, Object object){ return (getType(object).getTypeClass().getValue() == what.getValue()); }
_typeClass = t.getTypeClass() != TypeClass.UNKNOWN ? TypeClass.SEQUENCE : TypeClass.UNKNOWN; _typeName = "[]" + t.getTypeName();
if (t.getTypeClass() != TypeClass.UNKNOWN)
if (t.getTypeClass() != TypeClass.UNKNOWN)
if (a.getType().getTypeClass() == TypeClass.INTERFACE) { object = a.getObject(); if (object instanceof Any) { Any a = (Any) object; object = a.getType().getTypeClass() == TypeClass.INTERFACE ? a.getObject() : null;
if (a.getType().getTypeClass() == TypeClass.INTERFACE) { object = a.getObject(); if (object instanceof Any) { Any a = (Any) object; object = a.getType().getTypeClass() == TypeClass.INTERFACE ? a.getObject() : null;
/** Determines the type of an any object. @param object any object @return type object */ static public Type getType( Object object ) { Type t; if (null == object) { t = m_XInterface_type; } else if (object instanceof Any) { t = ((Any)object).getType(); // nested any if (TypeClass.ANY_value == t.getTypeClass().getValue()) return getType( ((Any)object).getObject() ); } else { t = new Type( object.getClass() ); } return t; }
/** * Determines the type of an any object. * * @param object any object. * @return type object. */ public static Type getType( Object object ) { Type t; if (null == object) { t = m_XInterface_type; } else if (object instanceof Any) { t = ((Any)object).getType(); // nested any if (TypeClass.ANY_value == t.getTypeClass().getValue()) return getType( ((Any)object).getObject() ); } else { t = new Type( object.getClass() ); } return t; }
if (a.getType().getTypeClass() == TypeClass.INTERFACE) { result = a.getObject(); } else {
if (a.getType().getTypeClass() == TypeClass.INTERFACE) { result = a.getObject(); } else {
public Object getPropertyValue(String name) throws UnknownPropertyException, WrappedTargetException { Object ret= null; if (bInDispose || bDisposed) throw new com.sun.star.lang.DisposedException("The component has been disposed already"); Property prop= getProperty(name); if (prop == null) throw new UnknownPropertyException("The property " + name + " is unknown"); synchronized (this) { ret= getPropertyValue(prop); } // null must not be returned. Either a void any is returned or an any containing // an interface type and a null reference. if (ret == null) { if (prop.Type.getTypeClass() == TypeClass.INTERFACE) ret= new Any(prop.Type, null); else ret= new Any(new Type(void.class), null); } return ret; }
public Object getPropertyValue(String name) throws UnknownPropertyException, WrappedTargetException { Object ret= null; if (bInDispose || bDisposed) throw new com.sun.star.lang.DisposedException("The component has been disposed already"); Property prop= getProperty(name); if (prop == null) throw new UnknownPropertyException("The property " + name + " is unknown"); synchronized (this) { ret= getPropertyValue(prop); } // null must not be returned. Either a void any is returned or an any containing // an interface type and a null reference. if (ret == null) { if (prop.Type.getTypeClass() == TypeClass.INTERFACE) ret= new Any(prop.Type, null); else ret= new Any(new Type(void.class), null); } return ret; }