1 /*************************************************************************
3 * The Contents of this file are made available subject to the terms of
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
30 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
31 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *************************************************************************/
35 import java
.util
.ArrayList
;
36 import java
.util
.List
;
38 import com
.sun
.star
.beans
.IllegalTypeException
;
39 import com
.sun
.star
.beans
.MethodConcept
;
40 import com
.sun
.star
.beans
.Property
;
41 import com
.sun
.star
.beans
.XIntrospection
;
42 import com
.sun
.star
.beans
.XIntrospectionAccess
;
43 import com
.sun
.star
.container
.XEnumeration
;
44 import com
.sun
.star
.container
.XEnumerationAccess
;
45 import com
.sun
.star
.container
.XHierarchicalNameAccess
;
46 import com
.sun
.star
.container
.XIndexAccess
;
47 import com
.sun
.star
.lang
.XMultiComponentFactory
;
48 import com
.sun
.star
.lang
.XServiceInfo
;
49 import com
.sun
.star
.lang
.XTypeProvider
;
50 import com
.sun
.star
.lib
.uno
.helper
.WeakBase
;
51 import com
.sun
.star
.reflection
.TypeDescriptionSearchDepth
;
52 import com
.sun
.star
.reflection
.XConstantTypeDescription
;
53 import com
.sun
.star
.reflection
.XConstantsTypeDescription
;
54 import com
.sun
.star
.reflection
.XIdlClass
;
55 import com
.sun
.star
.reflection
.XIdlField
;
56 import com
.sun
.star
.reflection
.XIdlMethod
;
57 import com
.sun
.star
.reflection
.XIdlReflection
;
58 import com
.sun
.star
.reflection
.XIndirectTypeDescription
;
59 import com
.sun
.star
.reflection
.XInterfaceTypeDescription
;
60 import com
.sun
.star
.reflection
.XPropertyTypeDescription
;
61 import com
.sun
.star
.reflection
.XServiceTypeDescription
;
62 import com
.sun
.star
.reflection
.XTypeDescription
;
63 import com
.sun
.star
.reflection
.XTypeDescriptionEnumeration
;
64 import com
.sun
.star
.reflection
.XTypeDescriptionEnumerationAccess
;
65 import com
.sun
.star
.ucb
.XSimpleFileAccess
;
66 import com
.sun
.star
.uno
.AnyConverter
;
67 import com
.sun
.star
.uno
.Type
;
68 import com
.sun
.star
.uno
.TypeClass
;
69 import com
.sun
.star
.uno
.UnoRuntime
;
70 import com
.sun
.star
.uno
.XComponentContext
;
71 import com
.sun
.star
.util
.URL
;
73 public class Introspector
extends WeakBase
{
75 private XIntrospection m_xIntrospection
;
76 private XMultiComponentFactory m_xMultiComponentFactory
;
77 private XComponentContext m_xComponentContext
;
78 private XTypeDescriptionEnumerationAccess m_xTDEnumerationAccess
;
79 private static XComponentContext xOfficeComponentContext
;
80 private XIdlReflection mxIdlReflection
;
81 private URL openHyperlink
;
82 private static Introspector m_oIntrospector
= null;
83 private XSimpleFileAccess xSimpleFileAccess
= null;
87 public static Introspector
getIntrospector(){
88 if (m_oIntrospector
== null){
89 throw new NullPointerException();
92 return m_oIntrospector
;
96 public static Introspector
getIntrospector(XComponentContext _xComponentContext
){
97 if (m_oIntrospector
== null){
98 m_oIntrospector
= new Introspector(_xComponentContext
);
100 return m_oIntrospector
;
104 /** Creates a new instance of Introspection */
105 private Introspector(XComponentContext _xComponentContext
) {
107 m_xComponentContext
= _xComponentContext
;
108 m_xMultiComponentFactory
= m_xComponentContext
.getServiceManager();
109 Object o
= m_xMultiComponentFactory
.createInstanceWithContext("com.sun.star.beans.Introspection", m_xComponentContext
);
110 m_xIntrospection
= UnoRuntime
.queryInterface(XIntrospection
.class, o
);
111 Object oCoreReflection
= getXMultiComponentFactory().createInstanceWithContext("com.sun.star.reflection.CoreReflection", getXComponentContext());
112 mxIdlReflection
= UnoRuntime
.queryInterface(XIdlReflection
.class, oCoreReflection
);
113 initTypeDescriptionManager();
115 catch( Exception exception
) {
116 System
.err
.println( exception
);
120 protected XComponentContext
getXComponentContext(){
121 return m_xComponentContext
;
125 protected XMultiComponentFactory
getXMultiComponentFactory(){
126 return m_xMultiComponentFactory
;
130 protected XIntrospectionAccess
getXIntrospectionAccess(Object _oUnoComponent
){
131 return m_xIntrospection
.inspect(_oUnoComponent
);
135 public boolean isContainer(Object _oUnoObject
){
136 boolean bIsContainer
= false;
138 XIntrospectionAccess xIntrospectionAccessObject
= getXIntrospectionAccess(_oUnoObject
);
139 if (xIntrospectionAccessObject
!= null){
140 XEnumerationAccess xEnumerationAccess
= UnoRuntime
.queryInterface(XEnumerationAccess
.class, xIntrospectionAccessObject
.queryAdapter( new Type( XEnumerationAccess
.class ) ) );
141 if (xEnumerationAccess
!= null){
142 XEnumeration xEnumeration
= xEnumerationAccess
.createEnumeration();
143 bIsContainer
= xEnumeration
.hasMoreElements();
146 XIndexAccess xIndexAccess
= UnoRuntime
.queryInterface( XIndexAccess
.class, xIntrospectionAccessObject
.queryAdapter(new Type( XIndexAccess
.class )));
147 if (xIndexAccess
!= null){
148 bIsContainer
= (xIndexAccess
.getCount() > 0);
152 } catch (IllegalTypeException ex
) {
153 ex
.printStackTrace(System
.err
);
159 // add all containers for the given object to the tree under the node
161 public Object
[] getUnoObjectsOfContainer(Object _oUnoParentObject
) {
162 Object
[] oRetComponents
= null;
164 ArrayList
<Object
> oRetComponentsVector
= new ArrayList
<Object
>();
165 XIntrospectionAccess xIntrospectionAccessObject
= getXIntrospectionAccess(_oUnoParentObject
);
166 if ( xIntrospectionAccessObject
!= null ) {
167 XEnumerationAccess xEnumerationAccess
= UnoRuntime
.queryInterface(XEnumerationAccess
.class, xIntrospectionAccessObject
.queryAdapter( new Type( XEnumerationAccess
.class ) ) );
168 if ( xEnumerationAccess
!= null ) {
169 XEnumeration xEnumeration
= xEnumerationAccess
.createEnumeration();
170 while ( xEnumeration
.hasMoreElements() ) {
171 oRetComponentsVector
.add(xEnumeration
.nextElement());
174 XIndexAccess xIndexAccess
= UnoRuntime
.queryInterface( XIndexAccess
.class, xIntrospectionAccessObject
.queryAdapter(new Type( XIndexAccess
.class )));
175 if ( xIndexAccess
!= null ) {
176 XIdlMethod mMethod
= xIntrospectionAccessObject
.getMethod("getByIndex", com
.sun
.star
.beans
.MethodConcept
.INDEXCONTAINER
);
177 for ( int i
= 0; i
< xIndexAccess
.getCount(); i
++ ) {
178 Object
[][] aParamInfo
= new Object
[1][1];
179 aParamInfo
[0] = new Integer
[] { new Integer(i
) };
180 oRetComponentsVector
.add(mMethod
.invoke(_oUnoParentObject
, aParamInfo
));
184 if (oRetComponentsVector
!= null){
185 oRetComponents
= new Object
[oRetComponentsVector
.size()];
186 oRetComponentsVector
.toArray(oRetComponents
);
189 catch( Exception exception
) {
190 System
.err
.println( exception
);
192 return oRetComponents
;
196 protected XIdlMethod
[] getMethodsOfInterface(Type _aType
){
198 XIdlClass xIdlClass
= mxIdlReflection
.forName(_aType
.getTypeName());
199 return xIdlClass
.getMethods();
201 catch( Exception e
) {
202 System
.err
.println( e
);
207 protected XIdlField
[] getFieldsOfType(Type _aType
){
209 XIdlClass xIdlClass
= mxIdlReflection
.forName(_aType
.getTypeName());
210 return xIdlClass
.getFields();
212 catch( Exception e
) {
213 System
.err
.println( e
);
218 public boolean hasMethods(Object _oUnoObject
){
219 boolean bHasMethods
= (getMethods(_oUnoObject
).length
> 0);
224 // add all methods for the given object to the tree under the node parent
225 public XIdlMethod
[] getMethods(Object _oUnoParentObject
) {
227 XIntrospectionAccess xIntrospectionAccess
= getXIntrospectionAccess(_oUnoParentObject
);
228 if (xIntrospectionAccess
!= null){
229 XIdlMethod
[] xIdlMethods
= xIntrospectionAccess
.getMethods(MethodConcept
.ALL
- MethodConcept
.DANGEROUS
);
233 catch( Exception e
) {
234 System
.err
.println( e
);
240 public boolean hasProperties(Object _oUnoObject
){
241 boolean bHasProperties
= (getProperties(_oUnoObject
).length
> 0);
242 return bHasProperties
;
246 protected Property
[] getProperties( Object _oUnoParentObject
){
248 XIntrospectionAccess xIntrospectionAccess
= getXIntrospectionAccess(_oUnoParentObject
);
249 if (xIntrospectionAccess
!= null){
250 Property
[] aProperties
= xIntrospectionAccess
.getProperties(com
.sun
.star
.beans
.PropertyConcept
.ATTRIBUTES
+ com
.sun
.star
.beans
.PropertyConcept
.PROPERTYSET
);
254 catch( Exception e
) {
255 System
.err
.println( e
);
261 protected Property
[] getProperties(Object _oUnoObject
, String _sServiceName
){
262 Property
[] aProperties
= getProperties(_oUnoObject
);
263 List
<Property
> aListOfProperties
= java
.util
.Arrays
.asList(aProperties
);
264 ArrayList
<Property
> aPropertiesVector
= new ArrayList
<Property
>(aListOfProperties
);
265 if (aProperties
!= null){
266 XPropertyTypeDescription
[] xPropertyTypeDescriptions
= getPropertyDescriptionsOfService(_sServiceName
);
267 for (int i
= aProperties
.length
- 1; i
>= 0; i
--){
268 if (!hasByName(xPropertyTypeDescriptions
, _sServiceName
+ "." + aProperties
[i
].Name
)){
269 aPropertiesVector
.remove(i
);
273 Property
[] aRetProperties
= new Property
[aPropertiesVector
.size()];
274 aPropertiesVector
.toArray(aRetProperties
);
275 return aRetProperties
;
279 protected Type
[] getInterfaces(Object _oUnoObject
, String _sServiceName
){
280 Type
[] aTypes
= getInterfaces(_oUnoObject
);
281 List
<Type
> aListOfTypes
= java
.util
.Arrays
.asList(aTypes
);
282 ArrayList
<Type
> aTypesVector
= new ArrayList
<Type
>(aListOfTypes
);
284 XInterfaceTypeDescription
[] xInterfaceTypeDescriptions
= getInterfaceDescriptionsOfService(_sServiceName
);
285 for (int i
= aTypes
.length
- 1; i
>= 0; i
--){
286 if (!hasByName(xInterfaceTypeDescriptions
, aTypes
[i
].getTypeName())){
287 aTypesVector
.remove(i
);
291 Type
[] aRetTypes
= new Type
[aTypesVector
.size()];
292 aTypesVector
.toArray(aRetTypes
);
297 public boolean hasInterfaces(Object _oUnoObject
){
298 return (getInterfaces(_oUnoObject
).length
> 0);
302 protected Type
[] getInterfaces(Object _oUnoParentObject
){
303 Type
[] aTypes
= new Type
[]{};
304 XTypeProvider xTypeProvider
= UnoRuntime
.queryInterface( XTypeProvider
.class, _oUnoParentObject
);
305 if ( xTypeProvider
!= null ) {
306 aTypes
= xTypeProvider
.getTypes();
313 public static boolean isObjectSequence(Object _oUnoObject
){
314 Type aType
= AnyConverter
.getType(_oUnoObject
);
315 return aType
.getTypeClass().getValue() == TypeClass
.SEQUENCE_value
;
319 public static boolean isObjectPrimitive(Object _oUnoObject
){
320 boolean breturn
= false;
321 if (_oUnoObject
!= null){
322 Type aType
= AnyConverter
.getType(_oUnoObject
);
323 breturn
= isObjectPrimitive(_oUnoObject
.getClass(), aType
.getTypeClass());
329 public static boolean isPrimitive(TypeClass _typeClass
){
330 return (( _typeClass
== TypeClass
.BOOLEAN
)
331 || ( _typeClass
== TypeClass
.BYTE
)
332 || ( _typeClass
== TypeClass
.CHAR
)
333 || ( _typeClass
== TypeClass
.DOUBLE
)
334 || ( _typeClass
== TypeClass
.ENUM
)
335 || ( _typeClass
== TypeClass
.FLOAT
)
336 || ( _typeClass
== TypeClass
.HYPER
)
337 || ( _typeClass
== TypeClass
.LONG
)
338 || ( _typeClass
== TypeClass
.SHORT
)
339 || ( _typeClass
== TypeClass
.STRING
)
340 || ( _typeClass
== TypeClass
.UNSIGNED_HYPER
)
341 || ( _typeClass
== TypeClass
.UNSIGNED_LONG
)
342 || ( _typeClass
== TypeClass
.UNSIGNED_SHORT
));
345 public static boolean isObjectPrimitive(Class
<?
extends Object
> _oUnoClass
, TypeClass _typeClass
){
346 return !( ( !_oUnoClass
.isPrimitive() ) && ( _typeClass
!= TypeClass
.ARRAY
)
347 && ( _typeClass
!= TypeClass
.BOOLEAN
)
348 && ( _typeClass
!= TypeClass
.BYTE
)
349 && ( _typeClass
!= TypeClass
.CHAR
)
350 && ( _typeClass
!= TypeClass
.DOUBLE
)
351 && ( _typeClass
!= TypeClass
.ENUM
)
352 && ( _typeClass
!= TypeClass
.FLOAT
)
353 && ( _typeClass
!= TypeClass
.HYPER
)
354 && ( _typeClass
!= TypeClass
.LONG
)
355 && ( _typeClass
!= TypeClass
.SHORT
)
356 && ( _typeClass
!= TypeClass
.STRING
)
357 && ( _typeClass
!= TypeClass
.UNSIGNED_HYPER
)
358 && ( _typeClass
!= TypeClass
.UNSIGNED_LONG
)
359 && ( _typeClass
!= TypeClass
.UNSIGNED_SHORT
));
363 protected void initTypeDescriptionManager() {
365 Object oTypeDescriptionManager
= getXComponentContext().getValueByName("/singletons/com.sun.star.reflection.theTypeDescriptionManager");
366 m_xTDEnumerationAccess
= UnoRuntime
.queryInterface(XTypeDescriptionEnumerationAccess
.class, oTypeDescriptionManager
);
367 } catch ( java
.lang
.Exception e
) {
368 System
.out
.println(System
.out
);
372 protected XTypeDescriptionEnumerationAccess
getXTypeDescriptionEnumerationAccess(){
373 return m_xTDEnumerationAccess
;
377 protected XConstantTypeDescription
[] getFieldsOfConstantGroup(String _sTypeClass
){
378 XConstantTypeDescription
[] xConstantTypeDescriptions
= null;
380 TypeClass
[] eTypeClasses
= new com
.sun
.star
.uno
.TypeClass
[1];
381 eTypeClasses
[0] = com
.sun
.star
.uno
.TypeClass
.CONSTANTS
;
382 XTypeDescriptionEnumeration xTDEnumeration
= m_xTDEnumerationAccess
.createTypeDescriptionEnumeration(getModuleName(_sTypeClass
), eTypeClasses
, TypeDescriptionSearchDepth
.INFINITE
);
383 while (xTDEnumeration
.hasMoreElements()) {
384 XTypeDescription xTD
= xTDEnumeration
.nextTypeDescription();
385 if (xTD
.getName().equals(_sTypeClass
)){
386 XConstantsTypeDescription xConstantsTypeDescription
= UnoRuntime
.queryInterface(XConstantsTypeDescription
.class, xTD
);
387 xConstantTypeDescriptions
= xConstantsTypeDescription
.getConstants();
389 String sName
= xTD
.getName();
391 return xConstantTypeDescriptions
;
392 } catch ( java
.lang
.Exception e
) {
393 System
.out
.println(System
.out
);
398 private XServiceTypeDescription
getServiceTypeDescription(String _sServiceName
, TypeClass _eTypeClass
){
400 if (_sServiceName
.length() > 0){
401 TypeClass
[] eTypeClasses
= new com
.sun
.star
.uno
.TypeClass
[2];
402 eTypeClasses
[0] = com
.sun
.star
.uno
.TypeClass
.SERVICE
;
403 eTypeClasses
[1] = _eTypeClass
;
404 XTypeDescriptionEnumeration xTDEnumeration
= getXTypeDescriptionEnumerationAccess().createTypeDescriptionEnumeration(Introspector
.getModuleName(_sServiceName
), eTypeClasses
, TypeDescriptionSearchDepth
.INFINITE
);
405 while (xTDEnumeration
.hasMoreElements()) {
406 XTypeDescription xTD
= xTDEnumeration
.nextTypeDescription();
407 if (xTD
.getName().equals(_sServiceName
)){
408 XServiceTypeDescription xServiceTypeDescription
= UnoRuntime
.queryInterface(XServiceTypeDescription
.class, xTD
);
409 return xServiceTypeDescription
;
414 } catch (Exception ex
) {
415 ex
.printStackTrace(System
.err
);
420 public XPropertyTypeDescription
[] getPropertyDescriptionsOfService(String _sServiceName
){
422 XServiceTypeDescription xServiceTypeDescription
= getServiceTypeDescription(_sServiceName
, com
.sun
.star
.uno
.TypeClass
.PROPERTY
);
423 if (xServiceTypeDescription
!= null){
424 XPropertyTypeDescription
[] xPropertyTypeDescriptions
= xServiceTypeDescription
.getProperties();
425 return xPropertyTypeDescriptions
;
427 } catch ( java
.lang
.Exception e
) {
428 System
.out
.println(System
.out
);
430 return new XPropertyTypeDescription
[]{};
434 public XTypeDescription
getReferencedType(String _sTypeName
){
435 XTypeDescription xTypeDescription
= null;
437 XHierarchicalNameAccess xHierarchicalNameAccess
= UnoRuntime
.queryInterface(XHierarchicalNameAccess
.class, m_xTDEnumerationAccess
);
438 if (xHierarchicalNameAccess
!= null){
439 if (xHierarchicalNameAccess
.hasByHierarchicalName(_sTypeName
)){
440 XIndirectTypeDescription xIndirectTypeDescription
= UnoRuntime
.queryInterface(XIndirectTypeDescription
.class, xHierarchicalNameAccess
.getByHierarchicalName(_sTypeName
));
441 if (xIndirectTypeDescription
!= null){
442 xTypeDescription
= xIndirectTypeDescription
.getReferencedType();
446 } catch (Exception ex
) {
447 ex
.printStackTrace(System
.err
);
449 return xTypeDescription
;
453 public XInterfaceTypeDescription
[] getInterfaceDescriptionsOfService(String _sServiceName
){
455 XServiceTypeDescription xServiceTypeDescription
= getServiceTypeDescription(_sServiceName
, com
.sun
.star
.uno
.TypeClass
.INTERFACE
);
456 if (xServiceTypeDescription
!= null){
457 XInterfaceTypeDescription
[] xInterfaceTypeDescriptions
= xServiceTypeDescription
.getMandatoryInterfaces();
458 return xInterfaceTypeDescriptions
;
460 } catch ( java
.lang
.Exception e
) {
461 System
.out
.println(System
.out
);
463 return new XInterfaceTypeDescription
[]{};
467 static boolean hasByName(XTypeDescription
[] _xTypeDescriptions
, String _sTypeName
){
468 for (int i
= 0; i
< _xTypeDescriptions
.length
; i
++){
469 if (_xTypeDescriptions
[i
].getName().equals(_sTypeName
)){
477 public static String
getModuleName(String _sTypeClass
){
478 int nlastindex
= _sTypeClass
.lastIndexOf(".");
479 if (nlastindex
> -1){
480 return _sTypeClass
.substring(0, nlastindex
);
488 public static String
getShortClassName(String _sClassName
){
489 String sShortClassName
= _sClassName
;
490 int nindex
= _sClassName
.lastIndexOf(".");
491 if ((nindex
< _sClassName
.length()) && nindex
> -1){
492 sShortClassName
= _sClassName
.substring(nindex
+ 1);
494 return sShortClassName
;
499 public static boolean isUnoTypeObject(Object _oUnoObject
){
500 return isOfUnoType(_oUnoObject
, "com.sun.star.uno.Type");
504 public static boolean isUnoPropertyTypeObject(Object _oUnoObject
){
505 return isOfUnoType(_oUnoObject
, "com.sun.star.beans.Property");
509 public static boolean isUnoPropertyValueTypeObject(Object _oUnoObject
){
510 return isOfUnoType(_oUnoObject
, "com.sun.star.beans.PropertyValue");
514 public static boolean isOfUnoType(Object _oUnoObject
, String _sTypeName
){
515 boolean bIsUnoObject
= false;
516 if (_oUnoObject
!= null){
517 if (_oUnoObject
.getClass().isArray()){
518 if (!_oUnoObject
.getClass().getComponentType().isPrimitive()){
519 Object
[] oUnoArray
= (Object
[]) _oUnoObject
;
520 if (oUnoArray
.length
> 0){
521 bIsUnoObject
= ( oUnoArray
[0].getClass().getName().equals(_sTypeName
));
527 bIsUnoObject
= (_oUnoObject
.getClass().getName().equals(_sTypeName
));
533 public String
getConstantDisplayString(int _nValue
, XConstantTypeDescription
[] _xConstantTypeDescription
, String _sDisplayString
){
535 int[] nbits
= new int[_xConstantTypeDescription
.length
];
536 for (int i
= 0; i
< _xConstantTypeDescription
.length
; i
++){
537 short nConstantValue
= ((Short
) _xConstantTypeDescription
[i
].getConstantValue()).shortValue();
538 nbits
[i
] = _nValue
& nConstantValue
;
540 _sDisplayString
+= sPrefix
+ _xConstantTypeDescription
[i
].getName();
544 return _sDisplayString
;
548 public static boolean isValid(Object
[] _oObject
){
549 if (_oObject
!= null){
550 if (_oObject
.length
> 0){
558 public static boolean isValid(Object _oObject
){
559 if (_oObject
!= null){
560 return (!AnyConverter
.isVoid(_oObject
));
566 public static boolean isArray(Object _oObject
){
567 return _oObject
.getClass().isArray();
571 public boolean hasSupportedServices(Object _oUnoObject
){
572 boolean bHasSupportedServices
= false;
573 XServiceInfo xServiceInfo
= UnoRuntime
.queryInterface( XServiceInfo
.class, _oUnoObject
);
574 if ( xServiceInfo
!= null ){
575 String
[] sSupportedServiceNames
= xServiceInfo
.getSupportedServiceNames();
576 bHasSupportedServices
= sSupportedServiceNames
.length
> 0;
578 return bHasSupportedServices
;
582 public Object
getValueOfText(TypeClass aTypeClass
, String sText
){
583 Object oReturn
= null;
584 switch (aTypeClass
.getValue()){
585 case TypeClass
.CHAR_value
:
587 case TypeClass
.DOUBLE_value
:
588 oReturn
= Double
.valueOf(sText
);
590 case TypeClass
.ENUM_value
:
592 case TypeClass
.FLOAT_value
:
593 oReturn
= Float
.valueOf(sText
);
595 case TypeClass
.HYPER_value
:
596 oReturn
= Long
.valueOf(sText
);
598 case TypeClass
.LONG_value
:
599 oReturn
= Integer
.valueOf(sText
);
601 case TypeClass
.SHORT_value
:
602 oReturn
= Byte
.valueOf(sText
);
604 case TypeClass
.STRING_value
:
607 case TypeClass
.UNSIGNED_HYPER_value
:
608 oReturn
= Long
.valueOf(sText
);
610 case TypeClass
.UNSIGNED_LONG_value
:
611 oReturn
= Integer
.valueOf(sText
);
613 case TypeClass
.UNSIGNED_SHORT_value
:
614 oReturn
= Byte
.valueOf(sText
);
622 public XSimpleFileAccess
getXSimpleFileAccess(){
624 if (xSimpleFileAccess
== null){
625 Object oSimpleFileAccess
= m_xComponentContext
.getServiceManager().createInstanceWithContext("com.sun.star.ucb.SimpleFileAccess", m_xComponentContext
);
626 xSimpleFileAccess
= com
.sun
.star
.uno
.UnoRuntime
.queryInterface(XSimpleFileAccess
.class, oSimpleFileAccess
);
628 return xSimpleFileAccess
;
629 } catch (com
.sun
.star
.uno
.Exception ex
) {
630 ex
.printStackTrace(System
.err
);
635 public boolean isValidSDKInstallationPath(String _sSDKInstallationPath
){
636 boolean bIsValid
= false;
638 String sIDLFolder
= Introspector
.addToPath(_sSDKInstallationPath
, Inspector
.sIDLDOCUMENTSUBFOLDER
);
639 String sIndexFile
= Introspector
.addToPath(_sSDKInstallationPath
, "index.html");
640 if (getXSimpleFileAccess() != null){
641 bIsValid
= (getXSimpleFileAccess().exists(sIDLFolder
) && getXSimpleFileAccess().exists(sIndexFile
));
643 } catch (com
.sun
.star
.uno
.Exception ex
) {
644 ex
.printStackTrace(System
.err
);
650 public static String
addToPath(String _sPath
, String _sSubPath
){
651 if (!_sPath
.endsWith("/")){
654 return _sPath
+ _sSubPath
;