1
2
3
4
5
6
7
8
9 package tsukuba_bunko.peko.resource;
10
11 import javax.xml.parsers.ParserConfigurationException;
12
13 import org.xml.sax.Attributes;
14 import org.xml.sax.SAXException;
15
16 import tsukuba_bunko.resource.ResourceDeserializer;
17 import tsukuba_bunko.resource.ResourceLoader;
18
19
20 /***
21 * "Peko" 用のリソースをロードする ResouceLoader です。
22 * @author $Author: ppoi $
23 * @version $Revision: 1.1 $
24 */
25 public class PekoResourceLoader extends ResourceLoader {
26
27 /***
28 * パス情報
29 */
30 private StringBuffer _path = null;
31
32
33 /***
34 * <code>PekoResourceLoader</code> のインスタンスを作成します。
35 * @throws InitializationError 初期化に失敗した場合
36 */
37 public PekoResourceLoader()
38 throws ParserConfigurationException, SAXException
39 {
40 super();
41 setDeserializerMapping( TypeMapping.getInstance().getDeserializerMapping() );
42 }
43
44
45
46
47
48 protected ResourceDeserializer getResourceDeserializer( String namespaceURI, String localName, String qName, Attributes attrs )
49 {
50 ResourceDeserializer deserializer = null;
51
52 if( (_path == null) || (_path.length() == 0) ) {
53 _path = new StringBuffer( getCurrentPath() );
54 }
55 else {
56 _path.append( '.' );
57 _path.append( qName );
58 }
59
60 TypeMapping mapping = TypeMapping.getInstance();
61 deserializer = mapping.getResourceDeserializer( new String(_path) );
62 return deserializer;
63 }
64
65
66
67
68
69 public void startDocument()
70 {
71 super.startDocument();
72 _path = null;
73 }
74
75 public void endElement( String namespaceURI, String localName, String qName )
76 throws SAXException
77 {
78 super.endElement( namespaceURI, localName, qName );
79 _path = null;
80 }
81 }