/* * $Id: XmlTestRecorder.java,v 1.3 2002/07/18 16:46:30 etoh Exp $ */ package tdoclet; import java.io.*; import java.util.*; import java.text.*; import javax.xml.parsers.*; import org.xml.sax.*; import org.w3c.dom.*; /** * �ǥե���Ȥη����Υƥ��ȷ�̥ե�����β�ᤪ��ӽ��Ϥ�Ԥ��ޤ�. * * @version 0.1 * @author Taichirou Etoh */ public class XmlTestRecorder { private String fileName; /** �������� */ private List updateHistory = new ArrayList(); public XmlTestRecorder(String fileName) { this.fileName = fileName; } /** * ��¸�Υƥ��ȷ�̤���Ϥ��������˼����ߤޤ�. */ public Collection parse() throws ParseException { Collection record = new ArrayList(); //* ���ꤷ���ե����뤬�ʤ���ж��Υƥ��ȷ�̤�꥿���󤹤� File file = new File(fileName); if (!file.exists()) return record; Document document = null; try { document = Xmls.newDocument(file); } catch (ParserConfigurationException e) { return record; } catch (SAXException e) { return record; } catch (IOException e) { return record; } if (document == null) return record; Element top = document.getDocumentElement(); //* ��¸�� XML �ե������깹����Ͽ��������� NodeList updateList = top.getElementsByTagName("update"); for (int i = 0; i < updateList.getLength(); i++) { Element update = (Element)updateList.item(i); updateHistory.add(((Text)update.getFirstChild()).getData()); } //* ��¸�� XML �ե�������ƥ��ȹ��ܤΥꥹ�Ȥ�������ơ��֥�˳�Ǽ���� NodeList itemList = top.getElementsByTagName("item"); for (int i = 0; i < itemList.getLength(); i++) { Element item = (Element)itemList.item(i); TestItem testItem = TestItem.createTestItemFromElement(item); record.add(testItem); } return record; } /** * ����������֤��ޤ�. */ public List getUpdateHistory() { return Collections.unmodifiableList(updateHistory); } }