Get the style color and number just once
[LibreOffice.git] / odk / examples / DevelopersGuide / Components / SimpleLicense / LicenseTest.java
blobb47aa70082ef5f95913eb0ae48f065a61c572963
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
5 * the BSD license.
7 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * All rights reserved.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
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 com.sun.star.lib.uno.helper.Factory;
37 import com.sun.star.lang.XSingleComponentFactory;
38 import com.sun.star.lib.uno.helper.WeakBase;
39 import com.sun.star.lang.XServiceInfo;
41 /** This class capsulates the class, that implements the minimal component, a
42 * factory for creating the service (<CODE>__getComponentFactory</CODE>) and a
43 * method, that writes the information into the given registry key
44 * (<CODE>__writeRegistryServiceInfo</CODE>).
46 public class LicenseTest {
47 /** This class implements the component. At least the interfaces XServiceInfo,
48 * XTypeProvider, and XInitialization should be provided by the service.
50 public static class _LicenseTest extends WeakBase
51 implements XServiceInfo {
52 /** The service name, that must be used to get an instance of this service.
54 private static final String __serviceName =
55 "org.openoffice.LicenseTest";
57 /** This method returns an array of all supported service names.
58 * @return Array of supported service names.
60 public String[] getSupportedServiceNames() {
61 return getServiceNames();
64 /** This method is a simple helper function to used in the
65 * static component initialisation functions as well as in
66 * getSupportedServiceNames.
68 public static String[] getServiceNames() {
69 String[] sSupportedServiceNames = { __serviceName };
70 return sSupportedServiceNames;
73 /** This method returns true, if the given service will be
74 * supported by the component.
75 * @param sServiceName Service name.
76 * @return True, if the given service name will be supported.
78 public boolean supportsService( String sServiceName ) {
79 return sServiceName.equals( __serviceName );
82 /** Return the class name of the component.
83 * @return Class name of the component.
85 public String getImplementationName() {
86 return _LicenseTest.class.getName();
91 /**
92 * Gives a factory for creating the service.
93 * This method is called by the <code>JavaLoader</code>
94 * <p>
95 * @return returns a <code>XSingleComponentFactory</code> for creating
96 * the component
97 * @param sImplName the name of the implementation for which a
98 * service is desired
99 * @see com.sun.star.comp.loader.JavaLoader
101 public static XSingleComponentFactory __getComponentFactory(String sImplName)
103 XSingleComponentFactory xFactory = null;
105 if ( sImplName.equals( _LicenseTest.class.getName() ) )
106 xFactory = Factory.createComponentFactory(_LicenseTest.class,
107 _LicenseTest.getServiceNames());
109 return xFactory;
112 /** This method is a member of the interface for initializing an object
113 * directly after its creation.
114 * @param object This array of arbitrary objects will be passed to the
115 * component after its creation.
116 * @throws com.sun.star.uno.Exception Every exception will not be handled, but will be
117 * passed to the caller.
119 public void initialize( Object[] object )
120 throws com.sun.star.uno.Exception {
121 /* The component describes what arguments are expected and in which
122 * order! At this point you can read the objects and initialize
123 * your component using these objects.
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */