01: /*
02: * XInfoFileParser.java
03: *
04: * Created on 08 February 2007, 12:25
05: *
06: * To change this template, choose Tools | Template Manager
07: * and open the template in the editor.
08: */
09:
10: package com.xoetrope.svg;
11:
12: import com.xoetrope.carousel.build.BuildProperties;
13: import java.io.IOException;
14: import java.io.Reader;
15: import java.net.URL;
16: import java.util.Vector;
17: import net.xoetrope.xml.XmlElement;
18: import net.xoetrope.xml.XmlSource;
19: import net.xoetrope.xui.XProject;
20:
21: /**
22: *
23: *
24: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
25: * the GNU Public License (GPL), please see license.txt for more details. If
26: * you make commercial use of this software you must purchase a commercial
27: * license from Xoetrope.</p>
28: * <p> $Revision: 1.5 $</p>
29: */
30: public class XInfoFileParser {
31: protected XProject project;
32: protected String path;
33: protected URL url;
34:
35: /**
36: * Creates a new instance of XInfoFileParser
37: * Which will be used to parse information from XML files.
38: */
39: public XInfoFileParser(XProject project, String path) {
40: this .project = project;
41: this .path = path;
42: }
43:
44: /**
45: * Reads the specified element number from the xml file and passes it by use of the <CODE>XHotSpotInfo</CODE> interface's set method
46: * to a class implementing the interface;
47: * @param elementNum <CODE>int</CODE> specifying the xml element to be parsed.
48: * @param statusInfo <CODE>XHotSpotInfo</CODE> interface used to pass the element to an implementing class.
49: */
50: public void read(int elementNum, XHotSpotInfo statusInfo) {
51: Reader reader = null;
52:
53: try {
54: reader = project.getBufferedReader(path);
55: } catch (Exception ex) {
56: if (BuildProperties.DEBUG)
57: ex.printStackTrace();
58: }
59:
60: XmlElement root = XmlSource.read(reader);
61:
62: Vector nodes = root.getChildren();
63: XmlElement node = (XmlElement) nodes.elementAt(elementNum);
64: statusInfo.set(node);
65: }
66: }
|