Tom Schindl wrote:
This is the java code.of but can we move the discussion about this on the [EMAIL PROTECTED]. There are much more people reading and dicussing API-Topics than here;-) Post your code to the [EMAIL PROTECTED] Tom Vincenzo Giuliano wrote:Hi Tom, I have a class java, named Descriptor, which gets a description of services, interfaces, properties and values of UNO_Object on runtime. This class is still improvement (e.g. NullPointer Exception is not handed). However I believe it useful. If you can, you could take a look at this class, what do you think of it? Regards, Vincenzo. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] import com.sun.star.lang.*; import com.sun.star.uno.*; import com.sun.star.beans.*; import com.sun.star.comp.helper.Bootstrap; /[EMAIL PROTECTED] vincenzo giuliano, 16 February 2006. * @version 1.0*/ public class Describer { /** Print service,interface and property of Uno Object*/ public static void printServicesAndInterfaces(Object object){ XServiceInfo xsi = (XServiceInfo)UnoRuntime.queryInterface(XServiceInfo.class,object); //I could hand the NullPointerException on xsi here String[] services = xsi.getSupportedServiceNames(); System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); System.out.println(">Implementation Name"); System.out.println(xsi.getImplementationName().toUpperCase()); System.out.println(); System.out.println(">Implemented Services"); for(int i=0; i<services.length; i++){ System.out.println(">\t>>>"+services[i].toString()); } XTypeProvider xtp = (XTypeProvider)UnoRuntime.queryInterface(XTypeProvider.class,object); Type[] interfaces = xtp.getTypes(); System.out.println(">Supported Interfaces"); for(int i=0; i<interfaces.length; i++){ System.out.println(">\t\t>>>"+interfaces[i].toString()); } System.out.println(">Properties"); try{ XPropertySet xps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,object); XPropertySetInfo xpsi = xps.getPropertySetInfo(); Property[] properties = xpsi.getProperties(); for(int i=0; i<properties.length; i++){ System.out.println(">\t\t\t>>>"+properties[i].Name+" : "+xps.getPropertyValue(properties[i].Name)); } System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); } catch(java.lang.NullPointerException npe){ System.out.println(">\t\t\t>>> No Property"); System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); } catch(UnknownPropertyException e){ System.err.println(e.getStackTrace()); System.err.println(e.getMessage()); } catch(WrappedTargetException e){ System.err.println(e.getStackTrace()); System.err.println(e.getMessage()); } } public String toString(){ return "Uno Object Describer"; } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] |
