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 *************************************************************************/
36 This example shows a UNO component that inherits com.sun.star.lib.uno.helper.PropertySet in
37 order to provide implementations of these interfaces:
39 com.sun.star.beans.XPropertySet
40 com.sun.star.beans.XMultiPropertySet
41 com.sun.star.beans.XFastPropertySet
42 com.sun.star.lang.XComponent
43 com.sun.star.uno.XWeak
44 com.sun.star.lang.XTypeProvider
46 import com
.sun
.star
.lib
.uno
.helper
.PropertySet
;
47 import com
.sun
.star
.comp
.loader
.FactoryHelper
;
48 import com
.sun
.star
.lang
.XServiceInfo
;
49 import com
.sun
.star
.lang
.XMultiServiceFactory
;
50 import com
.sun
.star
.lang
.XSingleServiceFactory
;
51 import com
.sun
.star
.registry
.XRegistryKey
;
52 import com
.sun
.star
.uno
.Any
;
53 import com
.sun
.star
.uno
.Type
;
54 import com
.sun
.star
.uno
.XInterface
;
55 import com
.sun
.star
.lang
.XTypeProvider
;
56 import com
.sun
.star
.beans
.PropertyAttribute
;
59 This component contains the followin properties:
62 * <th> Property Name </th>
63 * <th> Type Name </th>
64 * <th> PropertyAttribute </th>
65 * <tr><td>boolA</td><td>BOOLEAN</td><td> - </td</tr>
66 * <tr><td>charA</td><td>CHAR</td><td> - </td></tr>
67 * <tr><td>byteA</td><td>BYTE</td><td> - </td></tr>
68 * <tr><td>shortA</td><td>SHORT</td><td> - </td></tr>
69 * <tr><td>intA</td><td>LONG</td><td> - </td></tr>
70 * <tr><td>longA</td><td>HYPER</td><td> - </td></tr>
71 * <tr><td>floatA</td><td>FLOAT</td><td> - </td></tr>
72 * <tr><td>doubleA</td><td>DOUBLE</td><td> - </td></tr>
73 * <tr><td>stringA</td><td>STRING</td><td> - </td></tr>
74 * <tr><td>objectA</td><td>ANY</td><td> - </td></tr>
75 * <tr><td>anyA</td><td>ANY</td><td> - </td></tr>
76 * <tr><td>typeA</td><td>TYPE</td><td> - </td></tr>
77 * <tr><td>xinterfaceA</td><td>INTERFACE</td><td> - </td></tr>
78 * <tr><td>xtypeproviderA</td><td>INTERFACE</td><td> - </td></tr>
79 * <tr><td>arBoolA</td><td>[]boolean</td><td> - </td></tr>
80 * <tr><td>arCharA</td><td>[]char</td><td> - </td></tr>
81 * <tr><td>arByteA</td><td>[]byte</td><td> - </td></tr>
82 * <tr><td>arShortA</td><td>[]short</td><td> - </td></tr>
83 * <tr><td>arIntA</td><td>[]long</td><td> - </td></tr>
84 * <tr><td>arLongA</td><td>[]hyper</td><td> - </td></tr>
85 * <tr><td>arFloatA</td><td>[]float</td><td> - </td></tr>
86 * <tr><td>arDoubleA</td><td>[]double</td><td> - </td></tr>
87 * <tr><td>arStringA</td><td>[]string</td><td> - </td></tr>
88 * <tr><td>arObjectA</td><td>[]any</td><td> - </td></tr>
89 * <tr><td>arXinterfaceA</td><td>[]com.sun.star.uno.XInterface</td><td> - </td></tr>
90 * <tr><td>ar2BoolA</td><td>[][]boolean</td><td> - </td></tr>
91 * <tr><td>boolClassA</td><td>boolean</td><td> - </td></tr>
92 * <tr><td>charClassA</td><td>char</td><td> - </td></tr>
93 * <tr><td>byteClassA</td><td>byte</td><td> - </td></tr>
94 * <tr><td>shortClassA</td><td>short</td><td> - </td></tr>
95 * <tr><td>intClassA</td><td>long</td><td> - </td></tr>
96 * <tr><td>longClassA</td><td>hyper</td><td> - </td></tr>
97 * <tr><td>floatClassA</td><td>float</td><td> - </td></tr>
98 * <tr><td>doubleClassA</td><td>double</td><td> - </td></tr>
99 * <tr><td>roIntA</td><td>long</td><td>READONLY</td></tr>
100 * <tr><td>roIntClassA</td><td>long</td><td>READONLY</td></tr>
101 * <tr><td>roObjectA</td><td>any</td><td>READONLY</td></tr>
102 * <tr><td>roAnyA</td><td>any</td><td>READONLY</td></tr>
103 * <tr><td>bcBoolA</td><td>boolean</td><td>BOUND,CONSTRAINED</td></tr>
104 * <tr><td>bcBoolClassA</td><td>boolean</td><td>BOUND,CONSTRAINED</td></tr>
105 * <tr><td>bcObjectA</td><td>any</td><td>BOUND,CONSTRAINED</td></tr>
106 * <tr><td>bcAnyA</td><td>any</td><td>BOUND,CONSTRAINED</td></tr>
107 * <tr><td>mvIntA</td><td>long</td><td>MAYBEVOID</td></tr>
108 * <tr><td>mvObjectA</td><td>any</td><td>MAYBEVOID</td></tr>
109 * <tr><td>mvAnyA</td><td>any</td><td>MAYBEVOID</td></tr>
110 * <tr><td>mvXinterfaceA</td><td>any</td><td>MAYBEVOID</td></tr>
114 public class PropTest
extends PropertySet
implements XServiceInfo
117 public boolean boolA
;
124 public double doubleA
;
125 public String stringA
; // MAYBEVOID
126 public Object objectA
; // MAYBEVOID
127 public Any anyA
; // MAYBEVOID
128 public Type typeA
;// MAYBEVOID
129 public XInterface xinterfaceA
;// MAYBEVOID
130 public XTypeProvider xtypeproviderA
;// MAYBEVOID
131 public boolean[] arBoolA
; // MAYBEVOID
132 public char[] arCharA
; // MAYBEVOID
133 public byte[] arByteA
; // MAYBEVOID
134 public short[] arShortA
; // MAYBEVOID
135 public int[] arIntA
; // MAYBEVOID
136 public long[] arLongA
; // MAYBEVOID
137 public float[] arFloatA
; // MAYBEVOID
138 public double[] arDoubleA
; // MAYBEVOID
139 public String
[] arStringA
; // MAYBEVOID
140 public Object
[] arObjectA
; // MAYBEVOID
141 public Any
[] arAnyA
; // MAYBEVOID
142 public XInterface
[] arXinterfaceA
; // MAYBEVOID
143 public boolean[][] ar2BoolA
; // MAYBEVOID
144 public Boolean boolClassA
; // MAYBEVOID
145 public Character charClassA
; // MAYBEVOID
146 public Byte byteClassA
; // MAYBEVOID
147 public Short shortClassA
; // MAYBEVOID
148 public Integer intClassA
; // MAYBEVOID
149 public Long longClassA
; // MAYBEVOID
150 public Float floatClassA
; // MAYBEVOID
151 public Double doubleClassA
; // MAYBEVOID
154 public int roIntA
= 100;
155 public Integer roIntClassA
= Integer
.valueOf(100);
156 public Object roObjectA
= Integer
.valueOf(101);
157 public Any roAnyA
= new Any( new Type(int.class), Integer
.valueOf(102));
159 // BOUND & CONSTRAINED
160 public boolean bcBoolA
;
161 public Boolean bcBoolClassA
; // MAYBEVOID
162 public Object bcObjectA
; // MAYBEVOID
163 public Any bcAnyA
; // MAYBEVOID
166 public Integer mvIntA
;
167 public Object mvObjectA
;
169 public XInterface mvXinterfaceA
;
171 public static final String __serviceName
="PropTest";
174 registerProperty("boolA", (short) 0);
175 registerProperty("charA", (short) 0);
176 registerProperty("byteA", (short) 0);
177 registerProperty("shortA", (short) 0);
178 registerProperty("intA", (short) 0);
179 registerProperty("longA", (short) 0);
180 registerProperty("floatA", (short) 0);
181 registerProperty("doubleA", (short) 0);
182 registerProperty("stringA", PropertyAttribute
.MAYBEVOID
);
183 registerProperty("objectA", PropertyAttribute
.MAYBEVOID
);
184 registerProperty("anyA", PropertyAttribute
.MAYBEVOID
);
185 registerProperty("typeA", PropertyAttribute
.MAYBEVOID
);
186 registerProperty("xinterfaceA", PropertyAttribute
.MAYBEVOID
);
187 registerProperty("xtypeproviderA", PropertyAttribute
.MAYBEVOID
);
188 registerProperty("arBoolA", PropertyAttribute
.MAYBEVOID
);
189 registerProperty("arCharA", PropertyAttribute
.MAYBEVOID
);
190 registerProperty("arByteA", PropertyAttribute
.MAYBEVOID
);
191 registerProperty("arShortA", PropertyAttribute
.MAYBEVOID
);
192 registerProperty("arIntA", PropertyAttribute
.MAYBEVOID
);
193 registerProperty("arLongA", PropertyAttribute
.MAYBEVOID
);
194 registerProperty("arFloatA", PropertyAttribute
.MAYBEVOID
);
195 registerProperty("arDoubleA", PropertyAttribute
.MAYBEVOID
);
196 registerProperty("arStringA", PropertyAttribute
.MAYBEVOID
);
197 registerProperty("arObjectA", PropertyAttribute
.MAYBEVOID
);
198 registerProperty("arAnyA", PropertyAttribute
.MAYBEVOID
);
199 registerProperty("arXinterfaceA", PropertyAttribute
.MAYBEVOID
);
200 registerProperty("ar2BoolA", PropertyAttribute
.MAYBEVOID
);
201 registerProperty("boolClassA", PropertyAttribute
.MAYBEVOID
);
202 registerProperty("charClassA", PropertyAttribute
.MAYBEVOID
);
203 registerProperty("byteClassA", PropertyAttribute
.MAYBEVOID
);
204 registerProperty("shortClassA", PropertyAttribute
.MAYBEVOID
);
205 registerProperty("intClassA", PropertyAttribute
.MAYBEVOID
);
206 registerProperty("longClassA", PropertyAttribute
.MAYBEVOID
);
207 registerProperty("floatClassA", PropertyAttribute
.MAYBEVOID
);
208 registerProperty("doubleClassA", PropertyAttribute
.MAYBEVOID
);
209 registerProperty("roIntA", PropertyAttribute
.READONLY
);
210 registerProperty("roIntClassA", PropertyAttribute
.READONLY
);
211 registerProperty("roObjectA", PropertyAttribute
.READONLY
);
212 registerProperty("roAnyA", PropertyAttribute
.READONLY
);
213 registerProperty("bcBoolA",(short) ( PropertyAttribute
.BOUND
| PropertyAttribute
.CONSTRAINED
));
214 registerProperty("bcBoolClassA", (short) (PropertyAttribute
.BOUND
| PropertyAttribute
.CONSTRAINED
| PropertyAttribute
.MAYBEVOID
));
215 registerProperty("bcObjectA", (short) (PropertyAttribute
.BOUND
| PropertyAttribute
.CONSTRAINED
| PropertyAttribute
.MAYBEVOID
));
216 registerProperty("bcAnyA", (short) (PropertyAttribute
.BOUND
| PropertyAttribute
.CONSTRAINED
|PropertyAttribute
.MAYBEVOID
));
217 registerProperty("mvIntA", PropertyAttribute
.MAYBEVOID
);
218 registerProperty("mvObjectA", PropertyAttribute
.MAYBEVOID
);
219 registerProperty("mvAnyA", PropertyAttribute
.MAYBEVOID
);
220 registerProperty("mvXinterfaceA", PropertyAttribute
.MAYBEVOID
);
225 public String
getImplementationName( )
227 return getClass().getName();
231 public boolean supportsService( /*IN*/String name
)
233 if (name
.equals(__serviceName
))
239 public String
[] getSupportedServiceNames( )
241 String
[] retValue
= new String
[]{__serviceName
};
245 public static XSingleServiceFactory
__getServiceFactory(String implName
,
246 XMultiServiceFactory multiFactory
,
249 XSingleServiceFactory xSingleServiceFactory
= null;
251 if (implName
.equals( PropTest
.class.getName()) )
252 xSingleServiceFactory
= FactoryHelper
.getServiceFactory( PropTest
.class,
253 PropTest
.__serviceName
,
257 return xSingleServiceFactory
;