1 // $Id: ContentHandlerFacade.java,v 1.3 2004/02/12 22:31:46 powerpete Exp $
2 // [JMP, 01.02.2004] Created this file.
3 package org.jface.stepmt.core.util;
4
5 import org.xml.sax.ContentHandler;
6 import org.xml.sax.SAXException;
7 import org.xml.sax.helpers.AttributesImpl;
8
9 /***
10 * @author <a href="mailto:powerpete@users.sf.net">M. Petersen</a>
11 * @version $Id: ContentHandlerFacade.java,v 1.3 2004/02/12 22:31:46 powerpete Exp $
12 */
13 public class ContentHandlerFacade
14 {
15 private ContentHandler contentHandler;
16 private final AttributesImpl attributes = new AttributesImpl();
17 private String uri = "";
18 private String prefix = "";
19
20 public void setContentHandler(ContentHandler contentHandler)
21 {
22 this.contentHandler = contentHandler;
23 }
24
25 public void start() throws SAXException
26 {
27 contentHandler.startDocument();
28 }
29
30 public void end() throws SAXException
31 {
32 contentHandler.endDocument();
33 }
34
35 public void setNamespace(final String uri, final String prefix)
36 {
37 this.uri = uri;
38 this.prefix = prefix == null ? "" : prefix + ":";
39 }
40
41 public void start(final String name) throws SAXException
42 {
43 contentHandler.startElement(uri, name, prefix + name, attributes);
44 }
45
46 public void end(final String name) throws SAXException
47 {
48 contentHandler.endElement(uri, name, prefix + name);
49 }
50
51 public void text(final String text) throws SAXException
52 {
53 contentHandler.characters(text.toCharArray(), 0, text.length());
54 }
55
56 public ContentHandlerFacade attribute(String name, String value)
57 {
58 attributes.addAttribute(uri, name, prefix + name, "CDATA", value);
59 return this;
60 }
61 }
This page was automatically generated by Maven