Update ooo320-m1
[ooovba.git] / odk / examples / java / PropertySet / PropTest.java
blob18b8c7c05a31d5705f8e3c3e20f6af473cbaf9ff
1 /*************************************************************************
3 * $RCSfile: PropTest.java,v $
5 * $Revision: 1.4 $
7 * last change: $Author: hr $ $Date: 2003-06-30 15:57:45 $
9 * The Contents of this file are made available subject to the terms of
10 * the BSD license.
12 * Copyright (c) 2003 by Sun Microsystems, Inc.
13 * All rights reserved.
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
34 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
35 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
36 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
37 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *************************************************************************/
42 This example shows a UNO component that inherits com.sun.star.lib.uno.helper.PropertySet in
43 order to provide implementations of these interfaces:
45 com.sun.star.beans.XPropertySet
46 com.sun.star.beans.XMultiPropertySet
47 com.sun.star.beans.XFastPropertySet
48 com.sun.star.lang.XComponent
49 com.sun.star.uno.XWeak
50 com.sun.star.lang.XTypeProvider
52 import com.sun.star.lib.uno.helper.PropertySet;
53 import com.sun.star.comp.loader.FactoryHelper;
54 import com.sun.star.lang.XServiceInfo;
55 import com.sun.star.lang.XMultiServiceFactory;
56 import com.sun.star.lang.XSingleServiceFactory;
57 import com.sun.star.registry.XRegistryKey;
58 import com.sun.star.uno.Any;
59 import com.sun.star.uno.Type;
60 import com.sun.star.uno.XInterface;
61 import com.sun.star.lang.XTypeProvider;
62 import com.sun.star.beans.PropertyAttribute;
64 /**
65 This component contains the followin properties:
66 * <table border>
67 * <tr>
68 * <th> Property Name </th>
69 * <th> Type Name </th>
70 * <th> PropertyAttribute </th>
71 * <tr><td>boolA</td><td>BOOLEAN</td><td> - </td</tr>
72 * <tr><td>charA</td><td>CHAR</td><td> - </td></tr>
73 * <tr><td>byteA</td><td>BYTE</td><td> - </td></tr>
74 * <tr><td>shortA</td><td>SHORT</td><td> - </td></tr>
75 * <tr><td>intA</td><td>LONG</td><td> - </td></tr>
76 * <tr><td>longA</td><td>HYPER</td><td> - </td></tr>
77 * <tr><td>floatA</td><td>FLOAT</td><td> - </td></tr>
78 * <tr><td>doubleA</td><td>DOUBLE</td><td> - </td></tr>
79 * <tr><td>stringA</td><td>STRING</td><td> - </td></tr>
80 * <tr><td>objectA</td><td>ANY</td><td> - </td></tr>
81 * <tr><td>anyA</td><td>ANY</td><td> - </td></tr>
82 * <tr><td>typeA</td><td>TYPE</td><td> - </td></tr>
83 * <tr><td>xinterfaceA</td><td>INTERFACE</td><td> - </td></tr>
84 * <tr><td>xtypeproviderA</td><td>INTERFACE</td><td> - </td></tr>
85 * <tr><td>arBoolA</td><td>[]boolean</td><td> - </td></tr>
86 * <tr><td>arCharA</td><td>[]char</td><td> - </td></tr>
87 * <tr><td>arByteA</td><td>[]byte</td><td> - </td></tr>
88 * <tr><td>arShortA</td><td>[]short</td><td> - </td></tr>
89 * <tr><td>arIntA</td><td>[]long</td><td> - </td></tr>
90 * <tr><td>arLongA</td><td>[]hyper</td><td> - </td></tr>
91 * <tr><td>arFloatA</td><td>[]float</td><td> - </td></tr>
92 * <tr><td>arDoubleA</td><td>[]double</td><td> - </td></tr>
93 * <tr><td>arStringA</td><td>[]string</td><td> - </td></tr>
94 * <tr><td>arObjectA</td><td>[]any</td><td> - </td></tr>
95 * <tr><td>arXinterfaceA</td><td>[]com.sun.star.uno.XInterface</td><td> - </td></tr>
96 * <tr><td>ar2BoolA</td><td>[][]boolean</td><td> - </td></tr>
97 * <tr><td>boolClassA</td><td>boolean</td><td> - </td></tr>
98 * <tr><td>charClassA</td><td>char</td><td> - </td></tr>
99 * <tr><td>byteClassA</td><td>byte</td><td> - </td></tr>
100 * <tr><td>shortClassA</td><td>short</td><td> - </td></tr>
101 * <tr><td>intClassA</td><td>long</td><td> - </td></tr>
102 * <tr><td>longClassA</td><td>hyper</td><td> - </td></tr>
103 * <tr><td>floatClassA</td><td>float</td><td> - </td></tr>
104 * <tr><td>doubleClassA</td><td>double</td><td> - </td></tr>
105 * <tr><td>roIntA</td><td>long</td><td>READONLY</td></tr>
106 * <tr><td>roIntClassA</td><td>long</td><td>READONLY</td></tr>
107 * <tr><td>roObjectA</td><td>any</td><td>READONLY</td></tr>
108 * <tr><td>roAnyA</td><td>any</td><td>READONLY</td></tr>
109 * <tr><td>bcBoolA</td><td>boolean</td><td>BOUND,CONSTRAINED</td></tr>
110 * <tr><td>bcBoolClassA</td><td>boolean</td><td>BOUND,CONSTRAINED</td></tr>
111 * <tr><td>bcObjectA</td><td>any</td><td>BOUND,CONSTRAINED</td></tr>
112 * <tr><td>bcAnyA</td><td>any</td><td>BOUND,CONSTRAINED</td></tr>
113 * <tr><td>mvIntA</td><td>long</td><td>MAYBEVOID</td></tr>
114 * <tr><td>mvObjectA</td><td>any</td><td>MAYBEVOID</td></tr>
115 * <tr><td>mvAnyA</td><td>any</td><td>MAYBEVOID</td></tr>
116 * <tr><td>mvXinterfaceA</td><td>any</td><td>MAYBEVOID</td></tr>
117 </table>
120 public class PropTest extends PropertySet implements XServiceInfo
123 public boolean boolA;
124 public char charA;
125 public byte byteA;
126 public short shortA;
127 public int intA;
128 public long longA;
129 public float floatA;
130 public double doubleA;
131 public String stringA; // MAYBEVOID
132 public Object objectA; // MAYBEVOID
133 public Any anyA; // MAYBEVOID
134 public Type typeA;// MAYBEVOID
135 public XInterface xinterfaceA;// MAYBEVOID
136 public XTypeProvider xtypeproviderA;// MAYBEVOID
137 public boolean[] arBoolA; // MAYBEVOID
138 public char[] arCharA; // MAYBEVOID
139 public byte[] arByteA; // MAYBEVOID
140 public short[] arShortA; // MAYBEVOID
141 public int[] arIntA; // MAYBEVOID
142 public long[] arLongA; // MAYBEVOID
143 public float[] arFloatA; // MAYBEVOID
144 public double[] arDoubleA; // MAYBEVOID
145 public String[] arStringA; // MAYBEVOID
146 public Object[] arObjectA; // MAYBEVOID
147 public Any[] arAnyA; // MAYBEVOID
148 public XInterface[] arXinterfaceA; // MAYBEVOID
149 public boolean[][] ar2BoolA; // MAYBEVOID
150 public Boolean boolClassA; // MAYBEVOID
151 public Character charClassA; // MAYBEVOID
152 public Byte byteClassA; // MAYBEVOID
153 public Short shortClassA; // MAYBEVOID
154 public Integer intClassA; // MAYBEVOID
155 public Long longClassA; // MAYBEVOID
156 public Float floatClassA; // MAYBEVOID
157 public Double doubleClassA; // MAYBEVOID
159 // readonly
160 public int roIntA= 100;
161 public Integer roIntClassA= new Integer(100);
162 public Object roObjectA= new Integer(101);
163 public Any roAnyA= new Any( new Type(int.class), new Integer(102));
165 // BOUND & CONSTRAINED
166 public boolean bcBoolA;
167 public Boolean bcBoolClassA; // MAYBEVOID
168 public Object bcObjectA; // MAYBEVOID
169 public Any bcAnyA; // MAYBEVOID
171 // MAYBEVOID
172 public Integer mvIntA;
173 public Object mvObjectA;
174 public Any mvAnyA;
175 public XInterface mvXinterfaceA;
177 public static final String __serviceName="PropTest";
179 public PropTest() {
180 registerProperty("boolA", (short) 0);
181 registerProperty("charA", (short) 0);
182 registerProperty("byteA", (short) 0);
183 registerProperty("shortA", (short) 0);
184 registerProperty("intA", (short) 0);
185 registerProperty("longA", (short) 0);
186 registerProperty("floatA", (short) 0);
187 registerProperty("doubleA", (short) 0);
188 registerProperty("stringA", PropertyAttribute.MAYBEVOID);
189 registerProperty("objectA", PropertyAttribute.MAYBEVOID);
190 registerProperty("anyA", PropertyAttribute.MAYBEVOID);
191 registerProperty("typeA", PropertyAttribute.MAYBEVOID);
192 registerProperty("xinterfaceA", PropertyAttribute.MAYBEVOID);
193 registerProperty("xtypeproviderA", PropertyAttribute.MAYBEVOID);
194 registerProperty("arBoolA", PropertyAttribute.MAYBEVOID);
195 registerProperty("arCharA", PropertyAttribute.MAYBEVOID);
196 registerProperty("arByteA", PropertyAttribute.MAYBEVOID);
197 registerProperty("arShortA", PropertyAttribute.MAYBEVOID);
198 registerProperty("arIntA", PropertyAttribute.MAYBEVOID);
199 registerProperty("arLongA", PropertyAttribute.MAYBEVOID);
200 registerProperty("arFloatA", PropertyAttribute.MAYBEVOID);
201 registerProperty("arDoubleA", PropertyAttribute.MAYBEVOID);
202 registerProperty("arStringA", PropertyAttribute.MAYBEVOID);
203 registerProperty("arObjectA", PropertyAttribute.MAYBEVOID);
204 registerProperty("arAnyA", PropertyAttribute.MAYBEVOID);
205 registerProperty("arXinterfaceA", PropertyAttribute.MAYBEVOID);
206 registerProperty("ar2BoolA", PropertyAttribute.MAYBEVOID);
207 registerProperty("boolClassA", PropertyAttribute.MAYBEVOID);
208 registerProperty("charClassA", PropertyAttribute.MAYBEVOID);
209 registerProperty("byteClassA", PropertyAttribute.MAYBEVOID);
210 registerProperty("shortClassA", PropertyAttribute.MAYBEVOID);
211 registerProperty("intClassA", PropertyAttribute.MAYBEVOID);
212 registerProperty("longClassA", PropertyAttribute.MAYBEVOID);
213 registerProperty("floatClassA", PropertyAttribute.MAYBEVOID);
214 registerProperty("doubleClassA", PropertyAttribute.MAYBEVOID);
215 registerProperty("roIntA", PropertyAttribute.READONLY);
216 registerProperty("roIntClassA", PropertyAttribute.READONLY);
217 registerProperty("roObjectA", PropertyAttribute.READONLY);
218 registerProperty("roAnyA", PropertyAttribute.READONLY);
219 registerProperty("bcBoolA",(short) ( PropertyAttribute.BOUND | PropertyAttribute.CONSTRAINED));
220 registerProperty("bcBoolClassA", (short) (PropertyAttribute.BOUND | PropertyAttribute.CONSTRAINED | PropertyAttribute.MAYBEVOID));
221 registerProperty("bcObjectA", (short) (PropertyAttribute.BOUND | PropertyAttribute.CONSTRAINED | PropertyAttribute.MAYBEVOID));
222 registerProperty("bcAnyA", (short) (PropertyAttribute.BOUND | PropertyAttribute.CONSTRAINED |PropertyAttribute.MAYBEVOID));
223 registerProperty("mvIntA", PropertyAttribute.MAYBEVOID);
224 registerProperty("mvObjectA", PropertyAttribute.MAYBEVOID);
225 registerProperty("mvAnyA", PropertyAttribute.MAYBEVOID);
226 registerProperty("mvXinterfaceA", PropertyAttribute.MAYBEVOID);
230 // XServiceName
231 public String getImplementationName( )
233 return getClass().getName();
236 // XServiceName
237 public boolean supportsService( /*IN*/String name )
239 if (name.equals(__serviceName))
240 return true;
241 return false;
244 //XServiceName
245 public String[] getSupportedServiceNames( )
247 String[] retValue= new String[]{__serviceName};
248 return retValue;
251 public static XSingleServiceFactory __getServiceFactory(String implName,
252 XMultiServiceFactory multiFactory,
253 XRegistryKey regKey)
255 XSingleServiceFactory xSingleServiceFactory = null;
257 if (implName.equals( PropTest.class.getName()) )
258 xSingleServiceFactory = FactoryHelper.getServiceFactory( PropTest.class,
259 PropTest.__serviceName,
260 multiFactory,
261 regKey);
263 return xSingleServiceFactory;
266 public static boolean __writeRegistryServiceInfo(XRegistryKey regKey)
268 return FactoryHelper.writeRegistryServiceInfo( PropTest.class.getName(),
269 PropTest.__serviceName, regKey);