1
2
3
4
5
6
7
8
9 package tsukuba_bunko.peko.scenario;
10
11 import org.xml.sax.Attributes;
12 import org.xml.sax.SAXException;
13
14 import tsukuba_bunko.peko.PekoSystem;
15
16
17 /***
18 * PSML Scene 要素を処理するハンドラの基本機能を定義します。
19 * @author $Author: ppoi $
20 * @version $Revision: 1.1 $
21 */
22 public abstract class ElementHandler {
23
24 /***
25 * PSML 1.0 "Scene" XML Namespace URI
26 */
27 public static final String NAMESPACE_SCENE = "http://tsukuba-bunko.org/ns/psml-scene";
28
29 /***
30 * シーンコンテクスト
31 */
32 protected SceneContext _context = null;
33
34 /***
35 * 親要素のハンドラ
36 */
37 protected ElementHandler _parent = null;
38
39 /***
40 * シーンがこの要素の処理を以て終了するかどうか
41 */
42 protected boolean _endOfScene = false;
43
44
45 /***
46 * <code>ElementHandler</code> のインスタンスを生成します。
47 */
48 protected ElementHandler()
49 {
50 super();
51 }
52
53 /***
54 * シーンコンテクストを設定します。
55 * @param context シーンコンテクスト
56 */
57 public void setSceneContext( SceneContext context )
58 {
59 _context = context;
60 }
61
62 /***
63 * シーンコンテクストを取得します。
64 * @return シーンコンテクスト
65 */
66 public SceneContext getSceneContext()
67 {
68 return _context;
69 }
70
71 /***
72 * 親要素を処理している ElementHandler を設定します。
73 * @param handler 親要素のハンドラ
74 */
75 public void setParentHandler( ElementHandler handler )
76 {
77 _parent = handler;
78 }
79
80 /***
81 * 親要素を処理している ElementHandler を取得します。
82 * @return 親要素のハンドラ
83 */
84 public ElementHandler getParentHandler()
85 {
86 return _parent;
87 }
88
89 /***
90 * シーンがこの要素の処理を以て終了するかどうかを設定します。
91 * @param end シーンが終了する場合 <code>true</code>、それ以外の場合 <code>false</code>
92 */
93 protected void setEndOfScene( boolean end )
94 {
95 _endOfScene = end;
96 }
97
98 /***
99 * シーンがこの要素の処理を以て終了するかどうかを判定します。
100 * @return シーンが終了する場合 <code>true</code>、それ以外の場合 <code>false</code>
101 */
102 public boolean isEndOfScene()
103 {
104 return _endOfScene;
105 }
106
107 /***
108 * 処理を一時停止します。
109 * @param wait 最大停止時間
110 */
111 protected void stop( long wait )
112 {
113 if( _context != null ) {
114 if( _context.getSceneProcessor().isAborted() ) {
115 return;
116 }
117 tsukuba_bunko.peko.Logger.debug( "[scenario.handler] stop using ElementHandler#stop(wait)." );
118 PekoSystem.getInstance().getActionControler().stop( wait );
119 }
120 }
121
122 /***
123 * 処理をユーザーのアクションがあるまで一時停止します。
124 */
125 protected void stop()
126 {
127 if( _context != null ) {
128 if( _context.getSceneProcessor().isAborted() ) {
129 return;
130 }
131 tsukuba_bunko.peko.Logger.debug( "[scenario.handler] stop using ElementHandler#stop()." );
132 PekoSystem.getInstance().getActionControler().stop();
133 }
134 }
135
136
137
138
139
140 public void startDocument()
141 throws SAXException
142 {
143 }
144
145 public void endDocument()
146 throws SAXException
147 {
148 }
149
150 public void startElement( String namespaceURI, String localName, String qName, Attributes attrs )
151 throws SAXException
152 {
153 }
154
155 public void endElement( String namespaceURI, String localName, String qName )
156 throws SAXException
157 {
158 }
159
160 public void characters( char[] ch, int begin, int length )
161 throws SAXException
162 {
163 }
164 }