View Javadoc

1   /*
2    * "Peko" Visual Novel System
3    *
4    * All Rights Reserved.
5    * Copyright (c) 1999-2003 Tsukuba Bunko.
6    *
7    * $Id: WaitHandler.java,v 1.2 2005/07/11 14:23:15 ppoi Exp $
8    */
9   package tsukuba_bunko.peko.scenario.util;
10  
11  import	org.xml.sax.Attributes;
12  
13  import	tsukuba_bunko.peko.ActionControler;
14  import	tsukuba_bunko.peko.Logger;
15  import	tsukuba_bunko.peko.PekoSystem;
16  
17  import	tsukuba_bunko.peko.scenario.ElementHandler;
18  import	tsukuba_bunko.peko.scenario.PSMLUtil;
19  
20  
21  /***
22   * <samp>wait</samp> 要素を処理する ElementHandler です。
23   * @author	$Author: ppoi $
24   * @version	$Revision: 1.2 $
25   */
26  public class WaitHandler	extends ElementHandler	{
27  
28  	/***
29  	 * <code>WaitHandler</code> のインスタンスを作成します。
30  	 */
31  	public WaitHandler()
32  	{
33  		super();
34  	}
35  
36  
37  	/***
38  	 * <samp>dur</samp> 属性で指定されたミリ秒時間、コントローラに処理の中断を指示します。
39  	 * @param	attrs	属性
40  	 */
41  	public void waitFor( Attributes attrs )
42  	{
43  		ActionControler	controler = PekoSystem.getInstance().getActionControler();
44  
45  		String	dur = PSMLUtil.getAttributeValue( attrs, "dur" );
46  		if( dur == null )	{
47  			controler.stop();
48  		}
49  		else	{
50  			try	{
51  				controler.stop( Long.parseLong(dur) );
52  			}
53  			catch( NumberFormatException nfe )	{
54  				Logger.warn( MessageIDs.SCN6001W, new Object[]{getSceneContext().getCurrentPath()}, nfe );
55  				controler.stop();
56  			}
57  		}
58  	}
59  
60  
61  //
62  //	ContentHandler の実装
63  //
64  	public void startDocument()
65  	{
66  		ActionControler	controler = PekoSystem.getInstance().getActionControler();
67  		controler.setSaveEnabled( true );
68  	}
69  
70  	public void endDocument()
71  	{
72  		ActionControler	controler = PekoSystem.getInstance().getActionControler();
73  		controler.setSaveEnabled( false );
74  	}
75  
76  	public void startElement( String namespaceURI, String localName, String qName, Attributes attrs )
77  	{
78  		waitFor( attrs );
79  	}
80  }