1 /*------------------------------------------------------------------------- 2 Copyright 2006 Olivier Berlanger 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 package net.sf.xolite; 17 18 19 /** 20 * Interface implemented by object to be serialisable (back and forth) to XML. 21 * 22 * @author Olivier Berlanger 23 * @see XMLEventParser 24 * @see XMLSerializer 25 */ 26 public interface XMLSerializable { 27 28 29 /** 30 * Receive notification of the start of an element. (Method for simplified event-driven parsing = simplified SAX) 31 * 32 * @param uri 33 * The started element namespace URI. 34 * @param localName 35 * The started element local name (= name without the namespace prefix) . 36 * @param parser 37 * The current XML event parser. From this parser you can get the attributes of the started element, the SAX 38 * Locator, the defined namespace prefix mappings. 39 * @exception XMLParseException 40 * Any SAX exception, possibly wrapping another exception. 41 * @see org.xml.sax.ContentHandler#startElement 42 */ 43 public void startElement(String uri, String localName, XMLEventParser parser) throws XMLParseException; 44 45 46 /** 47 * Receive notification of the end of an element. (Method for simplified event-driven parsing = simplified SAX) 48 * 49 * @param uri 50 * The ended element namespace URI. 51 * @param localName 52 * The ended element local name (= name without the namespace prefix) . 53 * @param parser 54 * The current XML event parser. From this parser you can get SAX Locator or the text content of the ended 55 * element. 56 * @exception XMLParseException 57 * Any SAX exception, possibly wrapping another exception. 58 * @see org.xml.sax.ContentHandler#endElement 59 */ 60 public void endElement(String uri, String localName, XMLEventParser parser) throws XMLParseException; 61 62 63 /** 64 * Serialize this object to an XML representation (in a DOM tree, a Stream, ...). (Method for serialisation using a visitor 65 * pattern.) 66 * 67 * @param serializer 68 * The object implementing the actual serialization. 69 * @exception XMLSerializeException 70 * if something fails. 71 */ 72 public void serialize(XMLSerializer serializer) throws XMLSerializeException; 73 74 75 }