1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * The Contents of this file are made available subject to the terms of
7 * Copyright 2000, 2010 Oracle and/or its affiliates.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
29 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
31 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
32 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *************************************************************************/
36 import java
.util
.ArrayList
;
37 import java
.util
.List
;
39 import com
.sun
.star
.beans
.IllegalTypeException
;
40 import com
.sun
.star
.beans
.MethodConcept
;
41 import com
.sun
.star
.beans
.Property
;
42 import com
.sun
.star
.beans
.XIntrospection
;
43 import com
.sun
.star
.beans
.XIntrospectionAccess
;
44 import com
.sun
.star
.container
.XEnumeration
;
45 import com
.sun
.star
.container
.XEnumerationAccess
;
46 import com
.sun
.star
.container
.XHierarchicalNameAccess
;
47 import com
.sun
.star
.container
.XIndexAccess
;
48 import com
.sun
.star
.lang
.XMultiComponentFactory
;
49 import com
.sun
.star
.lang
.XServiceInfo
;
50 import com
.sun
.star
.lang
.XTypeProvider
;
51 import com
.sun
.star
.lib
.uno
.helper
.WeakBase
;
52 import com
.sun
.star
.reflection
.TypeDescriptionSearchDepth
;
53 import com
.sun
.star
.reflection
.XConstantTypeDescription
;
54 import com
.sun
.star
.reflection
.XConstantsTypeDescription
;
55 import com
.sun
.star
.reflection
.XIdlClass
;
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
;
72 public class Introspector
extends WeakBase
{
74 private XIntrospection m_xIntrospection
;
75 private XMultiComponentFactory m_xMultiComponentFactory
;
76 private XComponentContext m_xComponentContext
;
77 private XTypeDescriptionEnumerationAccess m_xTDEnumerationAccess
;
78 private XIdlReflection mxIdlReflection
;
79 private static Introspector m_oIntrospector
= null;
80 private XSimpleFileAccess xSimpleFileAccess
= null;
84 public static Introspector
getIntrospector(){
85 if (m_oIntrospector
== null){
86 throw new NullPointerException();
89 return m_oIntrospector
;
93 public static Introspector
getIntrospector(XComponentContext _xComponentContext
){
94 if (m_oIntrospector
== null){
95 m_oIntrospector
= new Introspector(_xComponentContext
);
97 return m_oIntrospector
;
101 /** Creates a new instance of Introspection */
102 private Introspector(XComponentContext _xComponentContext
) {
104 m_xComponentContext
= _xComponentContext
;
105 m_xMultiComponentFactory
= m_xComponentContext
.getServiceManager();
106 Object o
= m_xMultiComponentFactory
.createInstanceWithContext("com.sun.star.beans.Introspection", m_xComponentContext
);
107 m_xIntrospection
= UnoRuntime
.queryInterface(XIntrospection
.class, o
);
108 Object oCoreReflection
= getXMultiComponentFactory().createInstanceWithContext("com.sun.star.reflection.CoreReflection", getXComponentContext());
109 mxIdlReflection
= UnoRuntime
.queryInterface(XIdlReflection
.class, oCoreReflection
);
110 initTypeDescriptionManager();
112 catch( Exception exception
) {
113 System
.err
.println( exception
);
117 protected XComponentContext
getXComponentContext(){
118 return m_xComponentContext
;
122 private XMultiComponentFactory
getXMultiComponentFactory(){
123 return m_xMultiComponentFactory
;
127 protected XIntrospectionAccess
getXIntrospectionAccess(Object _oUnoComponent
){
128 return m_xIntrospection
.inspect(_oUnoComponent
);
132 public boolean isContainer(Object _oUnoObject
){
133 boolean bIsContainer
= false;
135 XIntrospectionAccess xIntrospectionAccessObject
= getXIntrospectionAccess(_oUnoObject
);
136 if (xIntrospectionAccessObject
!= null){
137 XEnumerationAccess xEnumerationAccess
= UnoRuntime
.queryInterface(XEnumerationAccess
.class, xIntrospectionAccessObject
.queryAdapter( new Type( XEnumerationAccess
.class ) ) );
138 if (xEnumerationAccess
!= null){
139 XEnumeration xEnumeration
= xEnumerationAccess
.createEnumeration();
140 bIsContainer
= xEnumeration
.hasMoreElements();
143 XIndexAccess xIndexAccess
= UnoRuntime
.queryInterface( XIndexAccess
.class, xIntrospectionAccessObject
.queryAdapter(new Type( XIndexAccess
.class )));
144 if (xIndexAccess
!= null){
145 bIsContainer
= (xIndexAccess
.getCount() > 0);
149 } catch (IllegalTypeException ex
) {
150 ex
.printStackTrace(System
.err
);
156 // add all containers for the given object to the tree under the node
158 public Object
[] getUnoObjectsOfContainer(Object _oUnoParentObject
) {
159 Object
[] oRetComponents
= null;
161 ArrayList
<Object
> oRetComponentsVector
= new ArrayList
<Object
>();
162 XIntrospectionAccess xIntrospectionAccessObject
= getXIntrospectionAccess(_oUnoParentObject
);
163 if ( xIntrospectionAccessObject
!= null ) {
164 XEnumerationAccess xEnumerationAccess
= UnoRuntime
.queryInterface(XEnumerationAccess
.class, xIntrospectionAccessObject
.queryAdapter( new Type( XEnumerationAccess
.class ) ) );
165 if ( xEnumerationAccess
!= null ) {
166 XEnumeration xEnumeration
= xEnumerationAccess
.createEnumeration();
167 while ( xEnumeration
.hasMoreElements() ) {
168 oRetComponentsVector
.add(xEnumeration
.nextElement());
171 XIndexAccess xIndexAccess
= UnoRuntime
.queryInterface( XIndexAccess
.class, xIntrospectionAccessObject
.queryAdapter(new Type( XIndexAccess
.class )));
172 if ( xIndexAccess
!= null ) {
173 XIdlMethod mMethod
= xIntrospectionAccessObject
.getMethod("getByIndex", com
.sun
.star
.beans
.MethodConcept
.INDEXCONTAINER
);
174 for ( int i
= 0; i
< xIndexAccess
.getCount(); i
++ ) {
175 Object
[][] aParamInfo
= new Object
[1][1];
176 aParamInfo
[0] = new Integer
[] { Integer
.valueOf(i
) };
177 oRetComponentsVector
.add(mMethod
.invoke(_oUnoParentObject
, aParamInfo
));
181 if (oRetComponentsVector
!= null){
182 oRetComponents
= new Object
[oRetComponentsVector
.size()];
183 oRetComponentsVector
.toArray(oRetComponents
);
186 catch( Exception exception
) {
187 System
.err
.println( exception
);
189 return oRetComponents
;
193 protected XIdlMethod
[] getMethodsOfInterface(Type _aType
){
195 XIdlClass xIdlClass
= mxIdlReflection
.forName(_aType
.getTypeName());
196 return xIdlClass
.getMethods();
198 catch( Exception e
) {
199 System
.err
.println( e
);
207 public boolean hasMethods(Object _oUnoObject
){
208 boolean bHasMethods
= (getMethods(_oUnoObject
).length
> 0);
213 // add all methods for the given object to the tree under the node parent
214 public XIdlMethod
[] getMethods(Object _oUnoParentObject
) {
216 XIntrospectionAccess xIntrospectionAccess
= getXIntrospectionAccess(_oUnoParentObject
);
217 if (xIntrospectionAccess
!= null){
218 XIdlMethod
[] xIdlMethods
= xIntrospectionAccess
.getMethods(MethodConcept
.ALL
- MethodConcept
.DANGEROUS
);
222 catch( Exception e
) {
223 System
.err
.println( e
);
229 public boolean hasProperties(Object _oUnoObject
){
230 boolean bHasProperties
= (getProperties(_oUnoObject
).length
> 0);
231 return bHasProperties
;
235 protected Property
[] getProperties( Object _oUnoParentObject
){
237 XIntrospectionAccess xIntrospectionAccess
= getXIntrospectionAccess(_oUnoParentObject
);
238 if (xIntrospectionAccess
!= null){
239 Property
[] aProperties
= xIntrospectionAccess
.getProperties(com
.sun
.star
.beans
.PropertyConcept
.ATTRIBUTES
+ com
.sun
.star
.beans
.PropertyConcept
.PROPERTYSET
);
243 catch( Exception e
) {
244 System
.err
.println( e
);
250 protected Property
[] getProperties(Object _oUnoObject
, String _sServiceName
){
251 Property
[] aProperties
= getProperties(_oUnoObject
);
252 List
<Property
> aListOfProperties
= java
.util
.Arrays
.asList(aProperties
);
253 ArrayList
<Property
> aPropertiesVector
= new ArrayList
<Property
>(aListOfProperties
);
254 if (aProperties
!= null){
255 XPropertyTypeDescription
[] xPropertyTypeDescriptions
= getPropertyDescriptionsOfService(_sServiceName
);
256 for (int i
= aProperties
.length
- 1; i
>= 0; i
--){
257 if (!hasByName(xPropertyTypeDescriptions
, _sServiceName
+ "." + aProperties
[i
].Name
)){
258 aPropertiesVector
.remove(i
);
262 Property
[] aRetProperties
= new Property
[aPropertiesVector
.size()];
263 aPropertiesVector
.toArray(aRetProperties
);
264 return aRetProperties
;
268 protected Type
[] getInterfaces(Object _oUnoObject
, String _sServiceName
){
269 Type
[] aTypes
= getInterfaces(_oUnoObject
);
270 List
<Type
> aListOfTypes
= java
.util
.Arrays
.asList(aTypes
);
271 ArrayList
<Type
> aTypesVector
= new ArrayList
<Type
>(aListOfTypes
);
273 XInterfaceTypeDescription
[] xInterfaceTypeDescriptions
= getInterfaceDescriptionsOfService(_sServiceName
);
274 for (int i
= aTypes
.length
- 1; i
>= 0; i
--){
275 if (!hasByName(xInterfaceTypeDescriptions
, aTypes
[i
].getTypeName())){
276 aTypesVector
.remove(i
);
280 Type
[] aRetTypes
= new Type
[aTypesVector
.size()];
281 aTypesVector
.toArray(aRetTypes
);
286 public boolean hasInterfaces(Object _oUnoObject
){
287 return (getInterfaces(_oUnoObject
).length
> 0);
291 protected Type
[] getInterfaces(Object _oUnoParentObject
){
292 Type
[] aTypes
= new Type
[]{};
293 XTypeProvider xTypeProvider
= UnoRuntime
.queryInterface( XTypeProvider
.class, _oUnoParentObject
);
294 if ( xTypeProvider
!= null ) {
295 aTypes
= xTypeProvider
.getTypes();
302 public static boolean isObjectSequence(Object _oUnoObject
){
303 Type aType
= AnyConverter
.getType(_oUnoObject
);
304 return aType
.getTypeClass().getValue() == TypeClass
.SEQUENCE_value
;
308 public static boolean isObjectPrimitive(Object _oUnoObject
){
309 boolean breturn
= false;
310 if (_oUnoObject
!= null){
311 Type aType
= AnyConverter
.getType(_oUnoObject
);
312 breturn
= isObjectPrimitive(_oUnoObject
.getClass(), aType
.getTypeClass());
318 public static boolean isPrimitive(TypeClass _typeClass
){
319 return (( _typeClass
== TypeClass
.BOOLEAN
)
320 || ( _typeClass
== TypeClass
.BYTE
)
321 || ( _typeClass
== TypeClass
.CHAR
)
322 || ( _typeClass
== TypeClass
.DOUBLE
)
323 || ( _typeClass
== TypeClass
.ENUM
)
324 || ( _typeClass
== TypeClass
.FLOAT
)
325 || ( _typeClass
== TypeClass
.HYPER
)
326 || ( _typeClass
== TypeClass
.LONG
)
327 || ( _typeClass
== TypeClass
.SHORT
)
328 || ( _typeClass
== TypeClass
.STRING
)
329 || ( _typeClass
== TypeClass
.UNSIGNED_HYPER
)
330 || ( _typeClass
== TypeClass
.UNSIGNED_LONG
)
331 || ( _typeClass
== TypeClass
.UNSIGNED_SHORT
));
334 public static boolean isObjectPrimitive(Class
<?
extends Object
> _oUnoClass
, TypeClass _typeClass
){
335 return !( ( !_oUnoClass
.isPrimitive() ) && ( _typeClass
!= TypeClass
.ARRAY
)
336 && ( _typeClass
!= TypeClass
.BOOLEAN
)
337 && ( _typeClass
!= TypeClass
.BYTE
)
338 && ( _typeClass
!= TypeClass
.CHAR
)
339 && ( _typeClass
!= TypeClass
.DOUBLE
)
340 && ( _typeClass
!= TypeClass
.ENUM
)
341 && ( _typeClass
!= TypeClass
.FLOAT
)
342 && ( _typeClass
!= TypeClass
.HYPER
)
343 && ( _typeClass
!= TypeClass
.LONG
)
344 && ( _typeClass
!= TypeClass
.SHORT
)
345 && ( _typeClass
!= TypeClass
.STRING
)
346 && ( _typeClass
!= TypeClass
.UNSIGNED_HYPER
)
347 && ( _typeClass
!= TypeClass
.UNSIGNED_LONG
)
348 && ( _typeClass
!= TypeClass
.UNSIGNED_SHORT
));
352 private void initTypeDescriptionManager() {
354 Object oTypeDescriptionManager
= getXComponentContext().getValueByName("/singletons/com.sun.star.reflection.theTypeDescriptionManager");
355 m_xTDEnumerationAccess
= UnoRuntime
.queryInterface(XTypeDescriptionEnumerationAccess
.class, oTypeDescriptionManager
);
356 } catch ( java
.lang
.Exception e
) {
357 System
.out
.println(System
.out
);
361 private XTypeDescriptionEnumerationAccess
getXTypeDescriptionEnumerationAccess(){
362 return m_xTDEnumerationAccess
;
366 protected XConstantTypeDescription
[] getFieldsOfConstantGroup(String _sTypeClass
){
367 XConstantTypeDescription
[] xConstantTypeDescriptions
= null;
369 TypeClass
[] eTypeClasses
= new com
.sun
.star
.uno
.TypeClass
[1];
370 eTypeClasses
[0] = com
.sun
.star
.uno
.TypeClass
.CONSTANTS
;
371 XTypeDescriptionEnumeration xTDEnumeration
= m_xTDEnumerationAccess
.createTypeDescriptionEnumeration(getModuleName(_sTypeClass
), eTypeClasses
, TypeDescriptionSearchDepth
.INFINITE
);
372 while (xTDEnumeration
.hasMoreElements()) {
373 XTypeDescription xTD
= xTDEnumeration
.nextTypeDescription();
374 if (xTD
.getName().equals(_sTypeClass
)){
375 XConstantsTypeDescription xConstantsTypeDescription
= UnoRuntime
.queryInterface(XConstantsTypeDescription
.class, xTD
);
376 xConstantTypeDescriptions
= xConstantsTypeDescription
.getConstants();
378 String sName
= xTD
.getName();
380 return xConstantTypeDescriptions
;
381 } catch ( java
.lang
.Exception e
) {
382 System
.out
.println(System
.out
);
387 private XServiceTypeDescription
getServiceTypeDescription(String _sServiceName
, TypeClass _eTypeClass
){
389 if (_sServiceName
.length() > 0){
390 TypeClass
[] eTypeClasses
= new com
.sun
.star
.uno
.TypeClass
[2];
391 eTypeClasses
[0] = com
.sun
.star
.uno
.TypeClass
.SERVICE
;
392 eTypeClasses
[1] = _eTypeClass
;
393 XTypeDescriptionEnumeration xTDEnumeration
= getXTypeDescriptionEnumerationAccess().createTypeDescriptionEnumeration(Introspector
.getModuleName(_sServiceName
), eTypeClasses
, TypeDescriptionSearchDepth
.INFINITE
);
394 while (xTDEnumeration
.hasMoreElements()) {
395 XTypeDescription xTD
= xTDEnumeration
.nextTypeDescription();
396 if (xTD
.getName().equals(_sServiceName
)){
397 XServiceTypeDescription xServiceTypeDescription
= UnoRuntime
.queryInterface(XServiceTypeDescription
.class, xTD
);
398 return xServiceTypeDescription
;
403 } catch (Exception ex
) {
404 ex
.printStackTrace(System
.err
);
409 public XPropertyTypeDescription
[] getPropertyDescriptionsOfService(String _sServiceName
){
411 XServiceTypeDescription xServiceTypeDescription
= getServiceTypeDescription(_sServiceName
, com
.sun
.star
.uno
.TypeClass
.PROPERTY
);
412 if (xServiceTypeDescription
!= null){
413 XPropertyTypeDescription
[] xPropertyTypeDescriptions
= xServiceTypeDescription
.getProperties();
414 return xPropertyTypeDescriptions
;
416 } catch ( java
.lang
.Exception e
) {
417 System
.out
.println(System
.out
);
419 return new XPropertyTypeDescription
[]{};
423 public XTypeDescription
getReferencedType(String _sTypeName
){
424 XTypeDescription xTypeDescription
= null;
426 XHierarchicalNameAccess xHierarchicalNameAccess
= UnoRuntime
.queryInterface(XHierarchicalNameAccess
.class, m_xTDEnumerationAccess
);
427 if (xHierarchicalNameAccess
!= null){
428 if (xHierarchicalNameAccess
.hasByHierarchicalName(_sTypeName
)){
429 XIndirectTypeDescription xIndirectTypeDescription
= UnoRuntime
.queryInterface(XIndirectTypeDescription
.class, xHierarchicalNameAccess
.getByHierarchicalName(_sTypeName
));
430 if (xIndirectTypeDescription
!= null){
431 xTypeDescription
= xIndirectTypeDescription
.getReferencedType();
435 } catch (Exception ex
) {
436 ex
.printStackTrace(System
.err
);
438 return xTypeDescription
;
442 private XInterfaceTypeDescription
[] getInterfaceDescriptionsOfService(String _sServiceName
){
444 XServiceTypeDescription xServiceTypeDescription
= getServiceTypeDescription(_sServiceName
, com
.sun
.star
.uno
.TypeClass
.INTERFACE
);
445 if (xServiceTypeDescription
!= null){
446 XInterfaceTypeDescription
[] xInterfaceTypeDescriptions
= xServiceTypeDescription
.getMandatoryInterfaces();
447 return xInterfaceTypeDescriptions
;
449 } catch ( java
.lang
.Exception e
) {
450 System
.out
.println(System
.out
);
452 return new XInterfaceTypeDescription
[]{};
456 private static boolean hasByName(XTypeDescription
[] _xTypeDescriptions
, String _sTypeName
){
457 for (int i
= 0; i
< _xTypeDescriptions
.length
; i
++){
458 if (_xTypeDescriptions
[i
].getName().equals(_sTypeName
)){
466 public static String
getModuleName(String _sTypeClass
){
467 int nlastindex
= _sTypeClass
.lastIndexOf(".");
468 if (nlastindex
> -1){
469 return _sTypeClass
.substring(0, nlastindex
);
477 public static String
getShortClassName(String _sClassName
){
478 String sShortClassName
= _sClassName
;
479 int nindex
= _sClassName
.lastIndexOf(".");
480 if ((nindex
< _sClassName
.length()) && nindex
> -1){
481 sShortClassName
= _sClassName
.substring(nindex
+ 1);
483 return sShortClassName
;
488 public static boolean isUnoTypeObject(Object _oUnoObject
){
489 return isOfUnoType(_oUnoObject
, "com.sun.star.uno.Type");
493 public static boolean isUnoPropertyTypeObject(Object _oUnoObject
){
494 return isOfUnoType(_oUnoObject
, "com.sun.star.beans.Property");
498 public static boolean isUnoPropertyValueTypeObject(Object _oUnoObject
){
499 return isOfUnoType(_oUnoObject
, "com.sun.star.beans.PropertyValue");
503 private static boolean isOfUnoType(Object _oUnoObject
, String _sTypeName
){
504 boolean bIsUnoObject
= false;
505 if (_oUnoObject
!= null){
506 if (_oUnoObject
.getClass().isArray()){
507 if (!_oUnoObject
.getClass().getComponentType().isPrimitive()){
508 Object
[] oUnoArray
= (Object
[]) _oUnoObject
;
509 if (oUnoArray
.length
> 0){
510 bIsUnoObject
= ( oUnoArray
[0].getClass().getName().equals(_sTypeName
));
516 bIsUnoObject
= (_oUnoObject
.getClass().getName().equals(_sTypeName
));
522 public String
getConstantDisplayString(int _nValue
, XConstantTypeDescription
[] _xConstantTypeDescription
, String _sDisplayString
){
524 int[] nbits
= new int[_xConstantTypeDescription
.length
];
525 for (int i
= 0; i
< _xConstantTypeDescription
.length
; i
++){
526 short nConstantValue
= ((Short
) _xConstantTypeDescription
[i
].getConstantValue()).shortValue();
527 nbits
[i
] = _nValue
& nConstantValue
;
529 _sDisplayString
+= sPrefix
+ _xConstantTypeDescription
[i
].getName();
533 return _sDisplayString
;
537 public static boolean isValid(Object
[] _oObject
){
538 if (_oObject
!= null){
539 if (_oObject
.length
> 0){
550 public static boolean isArray(Object _oObject
){
551 return _oObject
.getClass().isArray();
555 public boolean hasSupportedServices(Object _oUnoObject
){
556 boolean bHasSupportedServices
= false;
557 XServiceInfo xServiceInfo
= UnoRuntime
.queryInterface( XServiceInfo
.class, _oUnoObject
);
558 if ( xServiceInfo
!= null ){
559 String
[] sSupportedServiceNames
= xServiceInfo
.getSupportedServiceNames();
560 bHasSupportedServices
= sSupportedServiceNames
.length
> 0;
562 return bHasSupportedServices
;
566 public Object
getValueOfText(TypeClass aTypeClass
, String sText
){
567 Object oReturn
= null;
568 switch (aTypeClass
.getValue()){
569 case TypeClass
.CHAR_value
:
571 case TypeClass
.DOUBLE_value
:
572 oReturn
= Double
.valueOf(sText
);
574 case TypeClass
.ENUM_value
:
576 case TypeClass
.FLOAT_value
:
577 oReturn
= Float
.valueOf(sText
);
579 case TypeClass
.HYPER_value
:
580 oReturn
= Long
.valueOf(sText
);
582 case TypeClass
.LONG_value
:
583 oReturn
= Integer
.valueOf(sText
);
585 case TypeClass
.SHORT_value
:
586 oReturn
= Byte
.valueOf(sText
);
588 case TypeClass
.STRING_value
:
591 case TypeClass
.UNSIGNED_HYPER_value
:
592 oReturn
= Long
.valueOf(sText
);
594 case TypeClass
.UNSIGNED_LONG_value
:
595 oReturn
= Integer
.valueOf(sText
);
597 case TypeClass
.UNSIGNED_SHORT_value
:
598 oReturn
= Byte
.valueOf(sText
);
606 public XSimpleFileAccess
getXSimpleFileAccess(){
608 if (xSimpleFileAccess
== null){
609 Object oSimpleFileAccess
= m_xComponentContext
.getServiceManager().createInstanceWithContext("com.sun.star.ucb.SimpleFileAccess", m_xComponentContext
);
610 xSimpleFileAccess
= com
.sun
.star
.uno
.UnoRuntime
.queryInterface(XSimpleFileAccess
.class, oSimpleFileAccess
);
612 return xSimpleFileAccess
;
613 } catch (com
.sun
.star
.uno
.Exception ex
) {
614 ex
.printStackTrace(System
.err
);
619 public boolean isValidSDKInstallationPath(String _sSDKInstallationPath
){
620 boolean bIsValid
= false;
622 String sIDLFolder
= Introspector
.addToPath(_sSDKInstallationPath
, Inspector
.sIDLDOCUMENTSUBFOLDER
);
623 String sIndexFile
= Introspector
.addToPath(_sSDKInstallationPath
, "index.html");
624 if (getXSimpleFileAccess() != null){
625 bIsValid
= (getXSimpleFileAccess().exists(sIDLFolder
) && getXSimpleFileAccess().exists(sIndexFile
));
627 } catch (com
.sun
.star
.uno
.Exception ex
) {
628 ex
.printStackTrace(System
.err
);
634 public static String
addToPath(String _sPath
, String _sSubPath
){
635 if (!_sPath
.endsWith("/")){
638 return _sPath
+ _sSubPath
;
643 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */