1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AttributeList.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 package basicrunner
.basichelper
;
32 import com
.sun
.star
.lang
.XInitialization
;
33 import com
.sun
.star
.lang
.XSingleServiceFactory
;
34 import com
.sun
.star
.lang
.XServiceInfo
;
35 import com
.sun
.star
.uno
.Type
;
36 import com
.sun
.star
.lang
.XTypeProvider
;
40 * The class provides an implementation of the service
41 * <code>com.sun.star.xml.sax.XAttributeList</code>.
42 * @see com.sun.star.xml.sax.XAttributeList
43 * @see com.sun.star.lang.XServiceInfo
44 * @see com.sun.star.lang.XSingleServiceFactory
46 public class AttributeList
implements XServiceInfo
, XSingleServiceFactory
{
47 /** The service name of this class **/
48 static final String __serviceName
= "basichelper.AttributeList";
51 * Returns True, of the service is supported.
52 * @param name The service name.
53 * @return True, if the service is supported.
55 public boolean supportsService(String name
) {
56 return __serviceName
.equals(name
);
60 * Get all supported services.
61 * @return The supported services.
63 public String
[] getSupportedServiceNames() {
64 return new String
[] {__serviceName
};
68 * Ask for the implementation name.
69 * @return The implementation name.
71 public String
getImplementationName() {
72 return getClass().getName();
76 * Create an instance of the actual implementation of the AttributeList.
77 * Arguments are not supported, so they will bge ignored.
78 * @param args The arguments.
79 * @return A new instance of this class.
81 public Object
createInstanceWithArguments(Object
[] args
) {
82 return new AttributeListImpl();
86 * Create an instance of this class.
87 * @return A new instance of this class.
89 public Object
createInstance() {
90 return createInstanceWithArguments(null);
95 * The actual implementation of the service
96 * <code>com.sun.star.xml.sax.XAttributeList</code>.
97 * Extends the class util.XMLTools.AttributeList.
98 * @see util.XMLTools.AttributeList
99 * @see com.sun.star.xml.sax.XAttributeList
100 * @see com.sun.star.lang.XTypeProvider
101 * @see com.sun.star.lang.XInitialization
103 class AttributeListImpl
extends XMLTools
.AttributeList
104 implements XTypeProvider
, XInitialization
{
107 * Initialize this class.
108 * @param p0 An array of XML attributes that are added to the list.
109 * @throws Exception Initialize failed.
111 public void initialize(Object
[] p0
) throws com
.sun
.star
.uno
.Exception
{
112 for(int i
= 0; i
+ 2 < p0
.length
; i
+= 3) {
113 add((String
)p0
[i
], (String
)p0
[i
+ 1], (String
)p0
[i
+ 2]);
118 * Return all implemented types of this class.
119 * @return All UNO types of this class.
121 public Type
[] getTypes() {
122 Class interfaces
[] = getClass().getInterfaces();
123 Class superInterfaces
[] = getClass().getSuperclass().getInterfaces();
125 Type types
[] = new Type
[interfaces
.length
+ superInterfaces
.length
];
127 for(; i
< interfaces
.length
; ++ i
)
128 types
[i
] = new Type(interfaces
[i
]);
129 for(; i
< interfaces
.length
+ superInterfaces
.length
; ++ i
)
130 types
[i
] = new Type(superInterfaces
[i
- interfaces
.length
]);
135 * Get a unique id for this class
138 public byte[] getImplementationId() {
139 return toString().getBytes();