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: JavaFlatFilter.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 ************************************************************************/
31 package com
.sun
.star
.xml
.security
.eval
;
33 import com
.sun
.star
.registry
.XRegistryKey
;
34 import com
.sun
.star
.comp
.loader
.FactoryHelper
;
35 import com
.sun
.star
.uno
.UnoRuntime
;
36 import com
.sun
.star
.xml
.sax
.InputSource
;
37 import com
.sun
.star
.xml
.sax
.XDocumentHandler
;
38 import com
.sun
.star
.xml
.sax
.XParser
;
39 import com
.sun
.star
.xml
.sax
.XDTDHandler
;
40 import com
.sun
.star
.xml
.sax
.XEntityResolver
;
41 import com
.sun
.star
.xml
.sax
.XErrorHandler
;
42 import com
.sun
.star
.xml
.sax
.XAttributeList
;
43 import com
.sun
.star
.lang
.XSingleServiceFactory
;
44 import com
.sun
.star
.lang
.XMultiServiceFactory
;
45 import com
.sun
.star
.lang
.XTypeProvider
;
46 import com
.sun
.star
.lang
.XServiceInfo
;
47 import com
.sun
.star
.lang
.Locale
;
50 * the JavaFlatFilter class is a pure java filter, which does nothing
51 * but forwarding the SAX events to the next document handler.
52 * The purpose of this class is to calculate the time consumed by
53 * the UNO C++/Java bridge during exporting/importing.
55 public class JavaFlatFilter
extends Object
56 implements XDocumentHandler
, XParser
, XTypeProvider
, XServiceInfo
58 XDocumentHandler m_xDocumentHandler
;
60 /* XDocumentHandler */
61 public void startDocument()
62 throws com
.sun
.star
.xml
.sax
.SAXException
64 m_xDocumentHandler
.startDocument();
67 public void endDocument()
68 throws com
.sun
.star
.xml
.sax
.SAXException
70 m_xDocumentHandler
.endDocument();
73 public void startElement (String aName
, com
.sun
.star
.xml
.sax
.XAttributeList xAttribs
)
74 throws com
.sun
.star
.xml
.sax
.SAXException
76 m_xDocumentHandler
.startElement(aName
, xAttribs
);
79 public void endElement ( String aName
)
80 throws com
.sun
.star
.xml
.sax
.SAXException
82 m_xDocumentHandler
.endElement(aName
);
85 public void characters ( String aChars
)
86 throws com
.sun
.star
.xml
.sax
.SAXException
88 m_xDocumentHandler
.characters(aChars
);
91 public void ignorableWhitespace ( String aWhitespaces
)
92 throws com
.sun
.star
.xml
.sax
.SAXException
94 m_xDocumentHandler
.ignorableWhitespace(aWhitespaces
);
97 public void processingInstruction ( String aTarget
, String aData
)
98 throws com
.sun
.star
.xml
.sax
.SAXException
100 m_xDocumentHandler
.processingInstruction(aTarget
, aData
);
103 public void setDocumentLocator (com
.sun
.star
.xml
.sax
.XLocator xLocator
)
104 throws com
.sun
.star
.xml
.sax
.SAXException
106 m_xDocumentHandler
.setDocumentLocator(xLocator
);
110 public void parseStream(InputSource strucInputSource
)
114 public void setDocumentHandler(XDocumentHandler xDocumentHandler
)
116 m_xDocumentHandler
= xDocumentHandler
;
119 public void setDTDHandler(XDTDHandler xHandler
)
123 public void setEntityResolver(XEntityResolver xResolver
)
127 public void setErrorHandler(XErrorHandler xHandler
)
131 public void setLocale(Locale locale
)
136 * XTypeProvider implementation
137 * maintain a static implementation id for all instances of JavaFlatFilter
138 * initialized by the first call to getImplementationId()
140 protected static byte[] _implementationId
;
141 public com
.sun
.star
.uno
.Type
[] getTypes()
143 com
.sun
.star
.uno
.Type
[] retValue
= new com
.sun
.star
.uno
.Type
[4];
146 * instantiate Type instances for each interface you support and add them to Type[] array
147 * this object implements XServiceInfo, XTypeProvider and XSignFilter
149 retValue
[0]= new com
.sun
.star
.uno
.Type( XServiceInfo
.class);
150 retValue
[1]= new com
.sun
.star
.uno
.Type( XTypeProvider
.class);
151 retValue
[2]= new com
.sun
.star
.uno
.Type( XDocumentHandler
.class);
152 retValue
[3]= new com
.sun
.star
.uno
.Type( XParser
.class);
155 * XInterface is not needed for Java components, the UnoRuntime does its job
161 synchronized public byte[] getImplementationId()
163 if (_implementationId
== null) {
164 _implementationId
= new byte[16];
165 int hash
= hashCode(); // hashDode of this object
166 _implementationId
[0] = (byte)(hash
& 0xff);
167 _implementationId
[1] = (byte)((hash
>>> 8) & 0xff);
168 _implementationId
[2] = (byte)((hash
>>> 16) & 0xff);
169 _implementationId
[3] = (byte)((hash
>>>24) & 0xff);
171 return _implementationId
;
176 * XServiceInfo implementation
177 * hold the service name in a private static member variable of the class
179 protected static final String __serviceName
= "com.sun.star.xml.crypto.eval.JavaFlatFilter";
180 public String
getImplementationName( )
182 return getClass().getName();
185 public boolean supportsService(String serviceName
)
189 if ( serviceName
.equals( __serviceName
))
197 public String
[] getSupportedServiceNames( )
199 String
[] retValue
= new String
[0];
200 retValue
[0]= __serviceName
;
204 /* static __getServiceFactory() implementation */
205 public static XSingleServiceFactory
__getServiceFactory(String implName
,
206 XMultiServiceFactory multiFactory
,
207 com
.sun
.star
.registry
.XRegistryKey regKey
)
209 com
.sun
.star
.lang
.XSingleServiceFactory xSingleServiceFactory
= null;
210 if (implName
.equals( JavaFlatFilter
.class.getName()) )
212 xSingleServiceFactory
= FactoryHelper
.getServiceFactory( JavaFlatFilter
.class,
213 JavaFlatFilter
.__serviceName
,
218 return xSingleServiceFactory
;
221 /* static __writeRegistryServiceInfo implementation */
222 public static boolean __writeRegistryServiceInfo(XRegistryKey regKey
)
224 return FactoryHelper
.writeRegistryServiceInfo( JavaFlatFilter
.class.getName(),