4 * License : The MIT License
5 * Copyright(c) 2013 MikuToga Partners
8 package jp.sfjp.mikutoga.vmd.model.xml;
10 import java.io.IOException;
11 import jp.sfjp.mikutoga.vmd.model.VmdMotion;
12 import jp.sfjp.mikutoga.xml.TogaXmlException;
13 import org.xml.sax.InputSource;
14 import org.xml.sax.SAXException;
15 import org.xml.sax.XMLReader;
18 * XMLモーションファイルを読み込むためのローダ。
20 public class XmlVmdLoader {
22 private final XMLReader reader;
23 private final XmlHandler handler = new XmlHandler();
28 * <p>XMLリーダは名前空間をサポートしていなければならない。
29 * @param reader XMLリーダ
30 * @throws NullPointerException 引数がnull
32 public XmlVmdLoader(XMLReader reader) throws NullPointerException{
34 if(reader == null) throw new NullPointerException();
44 * @throws SAXException 構文エラー
45 * @throws IOException 入力エラー
46 * @throws TogaXmlException 構文エラー
48 public VmdMotion parse(InputSource source)
49 throws SAXException, IOException, TogaXmlException{
50 this.reader.setContentHandler(this.handler);
53 this.reader.parse(source);
54 }catch(SAXException e){
55 Throwable cause = e.getCause();
56 if(cause instanceof TogaXmlException){
57 throw (TogaXmlException) cause;
62 return this.handler.getVmdMotion();