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 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
public class PekoResourceLoader extends ResourceLoader { |
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
0 |
private StringBuffer _path = null; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
public PekoResourceLoader() |
38 |
|
throws ParserConfigurationException, SAXException |
39 |
|
{ |
40 |
0 |
super(); |
41 |
0 |
setDeserializerMapping( TypeMapping.getInstance().getDeserializerMapping() ); |
42 |
0 |
} |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
protected ResourceDeserializer getResourceDeserializer( String namespaceURI, String localName, String qName, Attributes attrs ) |
49 |
|
{ |
50 |
0 |
ResourceDeserializer deserializer = null; |
51 |
|
|
52 |
0 |
if( (_path == null) || (_path.length() == 0) ) { |
53 |
0 |
_path = new StringBuffer( getCurrentPath() ); |
54 |
0 |
} |
55 |
|
else { |
56 |
0 |
_path.append( '.' ); |
57 |
0 |
_path.append( qName ); |
58 |
|
} |
59 |
|
|
60 |
0 |
TypeMapping mapping = TypeMapping.getInstance(); |
61 |
0 |
deserializer = mapping.getResourceDeserializer( new String(_path) ); |
62 |
0 |
return deserializer; |
63 |
|
} |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
public void startDocument() |
70 |
|
{ |
71 |
0 |
super.startDocument(); |
72 |
0 |
_path = null; |
73 |
0 |
} |
74 |
|
|
75 |
|
public void endElement( String namespaceURI, String localName, String qName ) |
76 |
|
throws SAXException |
77 |
|
{ |
78 |
0 |
super.endElement( namespaceURI, localName, qName ); |
79 |
0 |
_path = null; |
80 |
0 |
} |
81 |
|
} |