Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

FOPSAXSVGDocumentFactory.java 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* $Id$ */
  17. package org.apache.fop.svg;
  18. import java.io.IOException;
  19. import org.xml.sax.EntityResolver;
  20. import org.xml.sax.InputSource;
  21. import org.xml.sax.SAXException;
  22. import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
  23. /**
  24. * This is a special subclass to allow setting a special EntityResolver.
  25. */
  26. public class FOPSAXSVGDocumentFactory extends SAXSVGDocumentFactory {
  27. private EntityResolver additionalResolver;
  28. /**
  29. * Creates a new DocumentFactory object.
  30. * @param parser The SAX2 parser classname.
  31. */
  32. public FOPSAXSVGDocumentFactory(String parser) {
  33. super(parser);
  34. }
  35. /**
  36. * Sets an additional entity resolver. It will be used before the default
  37. * entity resolving.
  38. * @param resolver Additional resolver
  39. */
  40. public void setAdditionalEntityResolver(EntityResolver resolver) {
  41. this.additionalResolver = resolver;
  42. }
  43. /**
  44. * @see org.xml.sax.EntityResolver#resolveEntity(String, String)
  45. */
  46. public InputSource resolveEntity(String publicId, String systemId)
  47. throws SAXException {
  48. if (this.additionalResolver != null) {
  49. try {
  50. InputSource result = this.additionalResolver.resolveEntity(publicId, systemId);
  51. if (result != null) {
  52. return result;
  53. }
  54. } catch (IOException ioe) {
  55. /**@todo Batik's SAXSVGDocumentFactory should throw IOException,
  56. * so we don't have to handle it here. */
  57. throw new SAXException(ioe);
  58. }
  59. }
  60. return super.resolveEntity(publicId, systemId);
  61. }
  62. }