blob: 0564500e9f8d36d25ea44b802e7e5493cb8f654a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
package org.openoffice.tools.types;
import java.util.ArrayList;
import java.util.Arrays;
import com.sun.star.reflection.XPropertyTypeDescription;
import com.sun.star.reflection.XServiceTypeDescription2;
import com.sun.star.reflection.XTypeDescription;
import com.sun.star.uno.TypeClass;
import com.sun.star.uno.UnoRuntime;
/**
* Wrapper class to get the informations on a service.
*
* @author cbosdonnat
*
*/
public class Service {
XServiceTypeDescription2 mDescr;
ArrayList<XTypeDescription> mRefs;
public Service( XTypeDescription pDescr ) {
if ( !pDescr.getTypeClass().equals( TypeClass.SERVICE ) ) {
throw new IllegalArgumentException( "Not a service description" );
}
mDescr = (XServiceTypeDescription2)UnoRuntime.queryInterface(
XServiceTypeDescription2.class, pDescr );
mRefs = new ArrayList<XTypeDescription>();
if ( !isNewStyleService() ) {
mRefs.addAll( Arrays.asList( mDescr.getMandatoryServices() ) );
mRefs.addAll( Arrays.asList( mDescr.getOptionalServices() ) );
mRefs.addAll( Arrays.asList( mDescr.getMandatoryInterfaces() ) );
mRefs.addAll( Arrays.asList( mDescr.getOptionalInterfaces() ) );
}
}
public XServiceTypeDescription2 getDescription( ) {
return mDescr;
}
public boolean isNewStyleService( ) {
return mDescr.isSingleInterfaceBased();
}
public XTypeDescription getSupertype( ) {
XTypeDescription superType = null;
if ( isNewStyleService() ) {
superType = mDescr.getInterface();
}
return superType;
}
public int getReferenceCount( ) {
return mRefs.size();
}
public String getReferenceTypeName( int pRefNumber ) {
String name = new String( );
return name;
}
public int getMethodCount( ) {
return mDescr.getConstructors().length;
}
public String getMethodName( int pMethodNumber ) {
String name = new String();
if ( pMethodNumber >= 0 && pMethodNumber < getMethodCount() ) {
name = mDescr.getConstructors()[ pMethodNumber ].getName();
}
return name;
}
public int getPropertiesCount( ) {
int count = 0;
if ( !isNewStyleService() ) {
count = mDescr.getProperties().length;
}
return count;
}
public XPropertyTypeDescription getProperty( int pPropNumber ) {
XPropertyTypeDescription result = null;
if ( pPropNumber >= 0 && pPropNumber < getPropertiesCount() ) {
result = mDescr.getProperties()[ pPropNumber ];
}
return result;
}
}
|