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 test.sample.valid;
20:
21: import org.x2jb.bind.BindingException;
22: import org.x2jb.bind.handler.ElementHandler;
23: import org.w3c.dom.Element;
24: import org.w3c.dom.NodeList;
25: import test.sample.valid.CustomHandler2.Inner;
26: import test.org.x2jb.bind.Helper;
27:
28: /**
29: * Custom handler, it is used for testing purposes only
30: *
31: * @author <a href="mailto:richard_opalka@yahoo.com">Richard Opalka</a>
32: * @version 1.0
33: */
34: public final class CustomHandler2Impl implements ElementHandler {
35:
36: public final Object bind(Element e, Class c)
37: throws BindingException {
38: NodeList nl = e.getElementsByTagNameNS("http://r/cfg/",
39: "testArray1");
40: String[] retVal = new String[nl.getLength()];
41:
42: for (int i = 0; i < retVal.length; i++) {
43: retVal[i] = Helper.getTextContent(nl.item(i)).toLowerCase();
44: }
45:
46: return new InnerImpl(retVal);
47: }
48:
49: public final Object getDefault(Class clazz) throws BindingException {
50: return null;
51: }
52:
53: private static class InnerImpl implements Inner {
54:
55: private final String[] retVal;
56:
57: private InnerImpl(String[] retVal) {
58: super ();
59: this .retVal = retVal;
60: }
61:
62: public String[] getTestArray1() {
63: return retVal;
64: }
65:
66: }
67:
68: }
|