01: /*
02: * XML 2 Java Binding (X2JB) - the excellent Java tool.
03: * Copyright 2007, by Richard Opalka.
04: *
05: * This is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU Lesser General Public License as
07: * published by the Free Software Foundation; either version 2.1 of
08: * the License, or (at your option) any later version.
09: *
10: * This software is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this software; if not see the FSF site:
17: * http://www.fsf.org/ and search for the LGPL License document there.
18: */
19: package org.x2jb.bind.handler;
20:
21: import org.w3c.dom.Element;
22: import org.x2jb.bind.BindingException;
23:
24: /**
25: * Users that wish to write their own <b>X2JB Element Handler</b> have to implement this interface.
26: *
27: * <p>Each attribute handler implementation:</p>
28: * <ul>
29: * <li>have to provide default accessible constructor.</li>
30: * <li>should be stateless</li>
31: * </ul>
32: *
33: * @author <a href="mailto:richard_opalka@yahoo.com">Richard Opalka</a>
34: * @version 1.0
35: * @see org.x2jb.bind.handler.AttributeHandler
36: */
37: public interface ElementHandler {
38:
39: /**
40: * Processes the XML element and returns the object wrapping its content.
41: * @param element XML element to be wrapped
42: * @param clazz class type which instance to return
43: * @throws BindingException if a binding error occurs
44: * @return object wrapping XML element
45: */
46: Object bind(Element element, Class clazz) throws BindingException;
47:
48: /**
49: * Returns default value associated with <code>clazz</code> type
50: * @param clazz class type which default instance have to be returned
51: * @throws BindingException if a binding error occurs
52: * @return object representing default value of class <code>clazz</code>
53: */
54: Object getDefault(Class clazz) throws BindingException;
55:
56: }
|