Coverage report

  %line %branch
tsukuba_bunko.peko.scenario.text.ParagraphHandler
0% 
0% 

 1  
 /*
 2  
  * "Peko" Visual Novel System
 3  
  *
 4  
  * All Rights Reserved.
 5  
  * Copyright (c) 1999-2003 Tsukuba Bunko.
 6  
  *
 7  
  * $Id: ParagraphHandler.java,v 1.2 2005/07/11 14:18:23 ppoi Exp $
 8  
  */
 9  
 package tsukuba_bunko.peko.scenario.text;
 10  
 
 11  
 import	org.xml.sax.Attributes;
 12  
 
 13  
 import	tsukuba_bunko.peko.Logger;
 14  
 
 15  
 import	tsukuba_bunko.peko.scenario.FlagScope;
 16  
 import	tsukuba_bunko.peko.scenario.PSMLUtil;
 17  
 
 18  
 import	tsukuba_bunko.peko.scenario.util.WaitHandler;
 19  
 
 20  
 
 21  
 /**
 22  
  * <samp>p</samp> 要素の処理を行う <code>ElementHandler</code> です。
 23  
  * @author	$Author: ppoi $
 24  
  * @version	$Revision: 1.2 $
 25  
  */
 26  
 public class ParagraphHandler	extends TextElementHandler	{
 27  
 
 28  
 	/**
 29  
 	 * テキストバッファ
 30  
 	 */
 31  0
 	private StringBuffer	_text = null;
 32  
 
 33  
 	/**
 34  
 	 * この要素の評価終了後に設定されるフラグ
 35  
 	 */
 36  0
 	private String	_flagID = null;
 37  
 
 38  
 	/**
 39  
 	 * WaitHandler
 40  
 	 */
 41  0
 	private WaitHandler	_waitHandler = new WaitHandler();
 42  
 
 43  
 
 44  
 	/**
 45  
 	 * <code>ParagraphHandler</code> のインスタンスを作成します。
 46  
 	 */
 47  
 	public ParagraphHandler()
 48  
 	{
 49  0
 		super();
 50  0
 	}
 51  
 
 52  
 
 53  
 	/**
 54  
 	 * パラグラフを表示します。
 55  
 	 * @return	文章を表示した場合
 56  
 	 */
 57  
 	private boolean performParagraph()
 58  
 	{
 59  0
 		TextCoordinator	coordinator = getTextCoordinator();
 60  0
 		String	paragraph = new String( _text );
 61  0
 		if( paragraph.length() > 0 )	{
 62  0
 			coordinator.pushText( new String(_text) );
 63  0
 			_text = new StringBuffer( 48 );
 64  0
 			return true;
 65  
 		}
 66  
 		else	{
 67  0
 			return false;
 68  
 		}
 69  
 	}
 70  
 
 71  
 
 72  
 //
 73  
 //	ContentHandler の実装
 74  
 //
 75  
 	public void startDocument()
 76  
 	{
 77  0
 		Logger.debug( "[scene] start paragraph" );
 78  0
 		_text = new StringBuffer( 48 );
 79  0
 		_flagID = null;
 80  0
 		getTextCoordinator().begin();
 81  0
 	}
 82  
 
 83  
 	public void endDocument()
 84  
 	{
 85  0
 		Logger.debug( "[scene] end paragraph" );
 86  0
 		if( performParagraph() )	{
 87  0
 			stop();
 88  
 		}
 89  0
 		_text = null;
 90  0
 		getTextCoordinator().commit();
 91  
 
 92  0
 		if( _flagID != null )	{
 93  0
 			getSceneContext().declareFlag( _flagID, FlagScope.SESSION );
 94  
 		}
 95  0
 	}
 96  
 
 97  
 	public void startElement( String namespaceURI, String localName, String qName, Attributes attrs )
 98  
 		throws org.xml.sax.SAXException
 99  
 	{
 100  0
 		if( localName.equals("wait") )	{
 101  0
 			performParagraph();
 102  0
 			_waitHandler.waitFor( attrs );
 103  0
 		}
 104  0
 		else if( localName.equals("p") )	{
 105  0
 			_flagID = PSMLUtil.getAttributeValue( attrs, "flag" );
 106  
 		}
 107  0
 	}
 108  
 
 109  
 	public void endElement( String namespaceURI, String localName, String qName )
 110  
 	{
 111  
 		//	スタイルを実装するまでは空のままです。
 112  0
 	}
 113  
 
 114  
 	public void characters( char[] ch, int begin, class="keyword">int length )
 115  
 	{
 116  0
 		_text.append( ch, begin, length );
 117  0
 	}
 118  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.