01: /*
02: * Copyright (C) 2003-2007 Kepler Project.
03: *
04: * Permission is hereby granted, free of charge, to any person obtaining
05: * a copy of this software and associated documentation files (the
06: * "Software"), to deal in the Software without restriction, including
07: * without limitation the rights to use, copy, modify, merge, publish,
08: * distribute, sublicense, and/or sell copies of the Software, and to
09: * permit persons to whom the Software is furnished to do so, subject to
10: * the following conditions:
11: *
12: * The above copyright notice and this permission notice shall be
13: * included in all copies or substantial portions of the Software.
14: *
15: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16: * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18: * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19: * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20: * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21: * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22: */
23:
24: package org.keplerproject.luajava.test.node;
25:
26: import java.util.Iterator;
27: import java.util.List;
28:
29: import org.keplerproject.luajava.LuaException;
30:
31: /**
32: * Uses the node example with a file that is a representation of a
33: * hibernate configuration XML file.
34: *
35: * @author thiago
36: */
37: public class Main {
38: public static void main(String[] args) throws LuaException {
39: LuaNode node = LuaNode.proccessFile("hibernateConfig.lua");
40:
41: System.out.println(node.getName());
42: System.out.println(node.getAttribute("name"));
43: System.out.println(node.getAttribute("table"));
44:
45: List list = node.getChildren("property");
46:
47: for (Iterator iter = list.iterator(); iter.hasNext();) {
48: LuaNode elem = (LuaNode) iter.next();
49: System.out.println(elem.getName());
50: System.out.println(elem.getAttribute("type"));
51: }
52:
53: list = node.getChild("many-to-one").getChildren();
54:
55: for (Iterator iter = list.iterator(); iter.hasNext();) {
56: LuaNode elem = (LuaNode) iter.next();
57: System.out.println(elem.getName());
58: System.out.println(elem.getValue());
59: }
60: }
61: }
|