Difference between revisions of "Documentation/DevGuide/FirstSteps/How do I know Which Type I Have?"

From Apache OpenOffice Wiki
Jump to: navigation, search
Line 1: Line 1:
<maintab>[[Development Concepts|Concepts]]||[[Programming|Programming]]||[[Applications|Applications]]||[[Get Started|Get Started]]||[[Get Objects|Get Objects]]||[[Work with Objects|Work with Objects]]||[[Types|Types]]||[[Example|Example]]</maintab>
+
{{DevGuide|Chapter1=block}}
<subtab></subtab>
+
 
A common problem is deciding what capabilities an object really has, after you receive it from a method.
 
A common problem is deciding what capabilities an object really has, after you receive it from a method.
 
By observing the code completion in Java IDE, you can discover the base interface of an object returned from a method. You will notice that loadComponentFromURL() returns a [IDL:com.sun.star.lang.XComponent].  
 
By observing the code completion in Java IDE, you can discover the base interface of an object returned from a method. You will notice that loadComponentFromURL() returns a [IDL:com.sun.star.lang.XComponent].  

Revision as of 09:52, 12 April 2007

Template:DevGuide A common problem is deciding what capabilities an object really has, after you receive it from a method. By observing the code completion in Java IDE, you can discover the base interface of an object returned from a method. You will notice that loadComponentFromURL() returns a [IDL:com.sun.star.lang.XComponent]. By pressing Alt + F1in the NetBeans IDE you can read specifications about the interfaces and services you are using. However, methods can only be specified to return one interface type. The interface you get from a method very often supports more interfaces than the one that is returned by the method (especially when the design of those interfaces predates the availability of multiple-inheritance interface types in UNO). Furthermore, the interface does not tell anything about the properties the object contains. Therefore you should uses this manual to get an idea how things work. Then start writing code, using the code completion and the API reference. In addition, you can try the InstanceInspector, a Java tool which is part of the [PRODUCTNAME] SDK examples. It is a Java component that can be registered with the office and shows interfaces and properties of the object you are currently working with. In [PRODUCTNAME] Basic, you can inspect objects using the following Basic properties.

 sub main
   oDocument = thiscomponent
   msgBox(oDocument.dbg_methods)
   msgBox(oDocument.dbg_properties)
   msgBox(oDocument.dbg_supportedInterfaces)
 end sub
Personal tools