1 /*
2 * Copyright (c) 2006-2007 Creative Sphere Limited.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 *
10 * Creative Sphere - initial API and implementation
11 *
12 */
13 package org.abstracthorizon.danube.webdav.xml.dav.request;
14
15 import org.abstracthorizon.danube.webdav.xml.XMLParserHandler;
16
17 import org.xml.sax.Attributes;
18 import org.xml.sax.SAXException;
19
20 /**
21 * Abstract XML handler. This method defines some default actions for {@link XMLParserHandler#start(Object, String, Attributes)}
22 * and {@link XMLParserHandler#end(Object, String, String)} methods
23 *
24 * @author Daniel Sendula
25 */
26 public abstract class AbstractSimpleXMLHandler implements XMLParserHandler {
27
28 /** Parent parser handler */
29 protected XMLParserHandler parent;
30
31 /**
32 * Constructor
33 */
34 protected AbstractSimpleXMLHandler() {
35 }
36
37 /**
38 * Constructor
39 * @param parent parent parser handler
40 */
41 public AbstractSimpleXMLHandler(XMLParserHandler parent) {
42 this.parent = parent;
43 }
44
45 /**
46 * Returns current object and does nothing else
47 * @param current current object
48 * @param tag tag
49 * @param attributes attribtues
50 */
51 public Object start(Object current, String tag, Attributes attributes) throws SAXException {
52 if (parent != null) {
53 // return parent.start(current, tag, attributes);
54 return current;
55 } else {
56 return current;
57 }
58 }
59
60 /**
61 * Returns parent object and does nothing else
62 * @param current current object
63 * @param tag tag
64 * @param value tag value
65 */
66 public Object end(Object current, String tag, String value) throws SAXException {
67 return parent;
68 }
69 }