1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 package com
.sun
.star
.xml
.security
.eval
;
30 import com
.sun
.star
.registry
.XRegistryKey
;
31 import com
.sun
.star
.comp
.loader
.FactoryHelper
;
32 import com
.sun
.star
.uno
.UnoRuntime
;
33 import com
.sun
.star
.xml
.sax
.InputSource
;
34 import com
.sun
.star
.xml
.sax
.XDocumentHandler
;
35 import com
.sun
.star
.xml
.sax
.XParser
;
36 import com
.sun
.star
.xml
.sax
.XDTDHandler
;
37 import com
.sun
.star
.xml
.sax
.XEntityResolver
;
38 import com
.sun
.star
.xml
.sax
.XErrorHandler
;
39 import com
.sun
.star
.xml
.sax
.XAttributeList
;
40 import com
.sun
.star
.lang
.XSingleServiceFactory
;
41 import com
.sun
.star
.lang
.XMultiServiceFactory
;
42 import com
.sun
.star
.lang
.XTypeProvider
;
43 import com
.sun
.star
.lang
.XServiceInfo
;
44 import com
.sun
.star
.lang
.Locale
;
47 * the JavaFlatFilter class is a pure java filter, which does nothing
48 * but forwarding the SAX events to the next document handler.
49 * The purpose of this class is to calculate the time consumed by
50 * the UNO C++/Java bridge during exporting/importing.
52 public class JavaFlatFilter
extends Object
53 implements XDocumentHandler
, XParser
, XTypeProvider
, XServiceInfo
55 XDocumentHandler m_xDocumentHandler
;
57 /* XDocumentHandler */
58 public void startDocument()
59 throws com
.sun
.star
.xml
.sax
.SAXException
61 m_xDocumentHandler
.startDocument();
64 public void endDocument()
65 throws com
.sun
.star
.xml
.sax
.SAXException
67 m_xDocumentHandler
.endDocument();
70 public void startElement (String aName
, com
.sun
.star
.xml
.sax
.XAttributeList xAttribs
)
71 throws com
.sun
.star
.xml
.sax
.SAXException
73 m_xDocumentHandler
.startElement(aName
, xAttribs
);
76 public void endElement ( String aName
)
77 throws com
.sun
.star
.xml
.sax
.SAXException
79 m_xDocumentHandler
.endElement(aName
);
82 public void characters ( String aChars
)
83 throws com
.sun
.star
.xml
.sax
.SAXException
85 m_xDocumentHandler
.characters(aChars
);
88 public void ignorableWhitespace ( String aWhitespaces
)
89 throws com
.sun
.star
.xml
.sax
.SAXException
91 m_xDocumentHandler
.ignorableWhitespace(aWhitespaces
);
94 public void processingInstruction ( String aTarget
, String aData
)
95 throws com
.sun
.star
.xml
.sax
.SAXException
97 m_xDocumentHandler
.processingInstruction(aTarget
, aData
);
100 public void setDocumentLocator (com
.sun
.star
.xml
.sax
.XLocator xLocator
)
101 throws com
.sun
.star
.xml
.sax
.SAXException
103 m_xDocumentHandler
.setDocumentLocator(xLocator
);
107 public void parseStream(InputSource strucInputSource
)
111 public void setDocumentHandler(XDocumentHandler xDocumentHandler
)
113 m_xDocumentHandler
= xDocumentHandler
;
116 public void setDTDHandler(XDTDHandler xHandler
)
120 public void setEntityResolver(XEntityResolver xResolver
)
124 public void setErrorHandler(XErrorHandler xHandler
)
128 public void setLocale(Locale locale
)
133 * XTypeProvider implementation
134 * maintain a static implementation id for all instances of JavaFlatFilter
135 * initialized by the first call to getImplementationId()
137 protected static byte[] _implementationId
;
138 public com
.sun
.star
.uno
.Type
[] getTypes()
140 com
.sun
.star
.uno
.Type
[] retValue
= new com
.sun
.star
.uno
.Type
[4];
143 * instantiate Type instances for each interface you support and add them to Type[] array
144 * this object implements XServiceInfo, XTypeProvider and XSignFilter
146 retValue
[0]= new com
.sun
.star
.uno
.Type( XServiceInfo
.class);
147 retValue
[1]= new com
.sun
.star
.uno
.Type( XTypeProvider
.class);
148 retValue
[2]= new com
.sun
.star
.uno
.Type( XDocumentHandler
.class);
149 retValue
[3]= new com
.sun
.star
.uno
.Type( XParser
.class);
152 * XInterface is not needed for Java components, the UnoRuntime does its job
158 synchronized public byte[] getImplementationId()
160 if (_implementationId
== null) {
161 _implementationId
= new byte[16];
162 int hash
= hashCode(); // hashDode of this object
163 _implementationId
[0] = (byte)(hash
& 0xff);
164 _implementationId
[1] = (byte)((hash
>>> 8) & 0xff);
165 _implementationId
[2] = (byte)((hash
>>> 16) & 0xff);
166 _implementationId
[3] = (byte)((hash
>>>24) & 0xff);
168 return _implementationId
;
173 * XServiceInfo implementation
174 * hold the service name in a private static member variable of the class
176 protected static final String __serviceName
= "com.sun.star.xml.crypto.eval.JavaFlatFilter";
177 public String
getImplementationName( )
179 return getClass().getName();
182 public boolean supportsService(String serviceName
)
186 if ( serviceName
.equals( __serviceName
))
194 public String
[] getSupportedServiceNames( )
196 String
[] retValue
= new String
[0];
197 retValue
[0]= __serviceName
;
201 /* static __getServiceFactory() implementation */
202 public static XSingleServiceFactory
__getServiceFactory(String implName
,
203 XMultiServiceFactory multiFactory
,
204 com
.sun
.star
.registry
.XRegistryKey regKey
)
206 com
.sun
.star
.lang
.XSingleServiceFactory xSingleServiceFactory
= null;
207 if (implName
.equals( JavaFlatFilter
.class.getName()) )
209 xSingleServiceFactory
= FactoryHelper
.getServiceFactory( JavaFlatFilter
.class,
210 JavaFlatFilter
.__serviceName
,
215 return xSingleServiceFactory
;
218 /* static __writeRegistryServiceInfo implementation */
219 public static boolean __writeRegistryServiceInfo(XRegistryKey regKey
)
221 return FactoryHelper
.writeRegistryServiceInfo( JavaFlatFilter
.class.getName(),