KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > xmi > impl > SAXWrapper


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: SAXWrapper.java,v 1.5 2005/06/22 14:45:00 khussey Exp $
16  */

17 package org.eclipse.emf.ecore.xmi.impl;
18
19
20 import org.xml.sax.Attributes JavaDoc;
21 import org.xml.sax.InputSource JavaDoc;
22 import org.xml.sax.Locator JavaDoc;
23 import org.xml.sax.SAXException JavaDoc;
24 import org.xml.sax.SAXParseException JavaDoc;
25 import org.xml.sax.ext.LexicalHandler JavaDoc;
26 import org.xml.sax.helpers.DefaultHandler JavaDoc;
27
28 import org.eclipse.emf.ecore.xmi.XMIException;
29
30
31 /**
32  * This class wraps an XMLHandler with a SAX DefaultHandler.
33  */

34 public class SAXWrapper extends DefaultHandler JavaDoc implements LexicalHandler JavaDoc
35 {
36   protected XMLHandler handler;
37   
38   /**
39    * Constructor for SAXWrapper.
40    */

41   public SAXWrapper(XMLHandler handler)
42   {
43     super();
44     this.handler = handler;
45   }
46
47   public void setDocumentLocator(Locator JavaDoc locator)
48   {
49     handler.setLocator(locator);
50   }
51
52   public void startDocument() throws SAXException JavaDoc
53   {
54     handler.startDocument();
55   }
56
57   public void endDocument() throws SAXException JavaDoc
58   {
59     handler.endDocument();
60   }
61
62   public void startPrefixMapping(String JavaDoc prefix, String JavaDoc uri) throws SAXException JavaDoc
63   {
64   }
65
66   public void endPrefixMapping(String JavaDoc prefix) throws SAXException JavaDoc
67   {
68   }
69
70   public void startElement(String JavaDoc uri, String JavaDoc localName, String JavaDoc qName, Attributes JavaDoc attributes) throws SAXException JavaDoc
71   {
72     handler.setAttributes(attributes);
73     handler.startElement(uri, localName, qName);
74   }
75
76   public void endElement (String JavaDoc uri, String JavaDoc localName, String JavaDoc qName) throws SAXException JavaDoc
77   {
78     handler.endElement(uri, localName, qName);
79   }
80
81   public void warning (SAXParseException JavaDoc e) throws SAXException JavaDoc
82   {
83     XMIException xmi = new XMIException(e.getException() == null ? e : e.getException(), e.getSystemId(), e.getLineNumber(), e.getColumnNumber());
84     handler.warning(xmi);
85   }
86
87   public void error (SAXParseException JavaDoc e) throws SAXException JavaDoc
88   {
89     XMIException xmi = new XMIException(e.getException() == null ? e : e.getException(), e.getSystemId(), e.getLineNumber(), e.getColumnNumber());
90     handler.error(xmi);
91   }
92
93   public void fatalError (SAXParseException JavaDoc e) throws SAXException JavaDoc
94   {
95     XMIException xmi = new XMIException(e.getException() == null ? e : e.getException(), e.getSystemId(), e.getLineNumber(), e.getColumnNumber());
96     handler.fatalError(xmi);
97     throw e;
98   }
99
100   public void characters (char ch[], int start, int length) throws SAXException JavaDoc
101   {
102     handler.characters(ch, start, length);
103   }
104
105   public void ignorableWhitespace (char ch[], int start, int length) throws SAXException JavaDoc
106   {
107     // handler.ignorableWhitespace(ch, start, length);
108
}
109
110   public void processingInstruction (String JavaDoc target, String JavaDoc data) throws SAXException JavaDoc
111   {
112     handler.processingInstruction(target, data);
113   }
114
115   public void skippedEntity (String JavaDoc name) throws SAXException JavaDoc
116   {
117     // handler.skippedEntity(name);
118
}
119
120   public InputSource JavaDoc resolveEntity(String JavaDoc publicId, String JavaDoc systemId) throws SAXException JavaDoc
121   {
122     // handler.resolveEntity(publicId, systemId);
123
return null;
124   }
125
126   public void notationDecl(String JavaDoc name, String JavaDoc publicId, String JavaDoc systemId) throws SAXException JavaDoc
127   {
128     // handler.notationDecl(name, publicId, systemId);
129
}
130
131   public void unparsedEntityDecl(String JavaDoc name, String JavaDoc publicId, String JavaDoc systemId, String JavaDoc notationName) throws SAXException JavaDoc
132   {
133     // handler.unparsedEntityDecl(name, publicId, systemId, notationName);
134
}
135
136   public void startDTD(java.lang.String JavaDoc name, java.lang.String JavaDoc publicId, java.lang.String JavaDoc systemId)
137   {
138     handler.startDTD(name, publicId, systemId);
139   }
140
141   public void endDTD()
142   {
143   }
144
145   public void startEntity(java.lang.String JavaDoc name)
146   {
147   }
148
149   public void endEntity(java.lang.String JavaDoc name)
150   {
151   }
152
153   public void startCDATA()
154   {
155     handler.startCDATA();
156   }
157
158   public void endCDATA()
159   {
160     handler.endCDATA();
161   }
162
163   public void comment(char [] characters, int start, int length) throws SAXException JavaDoc
164   {
165     handler.comment(characters, start, length);
166   }
167 }
168
Popular Tags