Coverage report

| %line | %branch
--- | --- | ---
tsukuba_bunko.peko.resource.InsetsDeserializer |
0% |
0% |

1 |  |
     /*
2 |  |
      * "Peko" Visual Novel System
3 |  |
      *
4 |  |
      * All Rights Reserved.
5 |  |
      * Copyright (c) 1999-2003 Tsukuba Bunko.
6 |  |
      *
7 |  |
      * $Id: InsetsDeserializer.java,v 1.1 2005/07/11 12:49:18 ppoi Exp $
8 |  |
      */
9 |  |
     package tsukuba_bunko.peko.resource;
10 |  |
11 |  |
     import	java.awt.Insets;
12 |  |
13 |  |
     import	tsukuba_bunko.resource.SimpleDeserializer;
14 |  |
15 |  |
16 |  |
     /**
17 |  |
      * {@link java.awt.Insets} 型のリソースに対する {@link tsukuba_bunko.resource.ResourceDeserializer} 実装です。
18 |  |
      * @author	$Author: ppoi $
19 |  |
      * @version	$Revision: 1.1 $
20 |  |
      * @see <a href="http://softlab.tsukuba-bunko.org/peko/userguide/resource.html#type-peko:insets">peko:insets 型のリソース</a>
21 |  |
      */
22 |  |
     public class InsetsDeserializer	extends SimpleDeserializer	{
23 |  |
24 |  |
     	/**
25 |  |
     	 * <code>InsetsDeserializer</code> のインスタンスを作成します。
26 |  |
     	 */
27 |  |
     	public InsetsDeserializer()
28 |  |
     	{
29 | 0 |
     		super();
30 | 0 |
     	}
31 |  |
32 |  |
33 |  |
     //
34 |  |
     //	SimpleDeserializer の実装
35 |  |
     //
36 |  |
     	protected Object convertValue( String source )
37 |  |
     	{
38 | 0 |
     		return parseInsets( source );
39 |  |
     	}
40 |  |
41 |  |
42 |  |
     	/**
43 |  |
     	 * <code>source</code> を Insets として解析します。
44 |  |
     	 * @param	source	解析元の文字列
45 |  |
     	 * @return	解析結果
46 |  |
     	 */
47 |  |
     	public static Insets parseInsets( String source )
48 |  |
     	{
49 |  |
     		try	{
50 |  |
     			int	top, right, bottom, left;
51 | 0 |
     			int	begin = 0;
52 | 0 |
     			int	end = source.indexOf( ',' );
53 | 0 |
     			if( end == -1 )	{
54 | 0 |
     				top = Integer.parseInt( source.trim() );
55 | 0 |
     				return new Insets( top, top, top, top );
56 |  |
     			}
57 |  |
     			else	{
58 | 0 |
     				top = Integer.parseInt( source.substring(begin, end).trim() );
59 |  |
     			}
60 |  |
61 | 0 |
     			begin = end + 1;
62 | 0 |
     			end = source.indexOf( ',', begin );
63 | 0 |
     			if( end == -1 )	{
64 | 0 |
     				right = Integer.parseInt( source.substring(begin).trim() );
65 | 0 |
     				return new Insets( top, right, top, right );
66 |  |
     			}
67 |  |
     			else	{
68 | 0 |
     				right = Integer.parseInt( source.substring(begin, end).trim() );
69 |  |
     			}
70 |  |
71 | 0 |
     			begin = end + 1;
72 | 0 |
     			end = source.indexOf( ',', begin );
73 | 0 |
     			if( end == -1 )	{
74 | 0 |
     				bottom = Integer.parseInt( source.substring(begin).trim() );
75 | 0 |
     				return new Insets( top, right, bottom, right );
76 |  |
     			}
77 |  |
     			else	{
78 | 0 |
     				bottom = Integer.parseInt( source.substring(begin, end).trim() );
79 |  |
     			}
80 |  |
81 | 0 |
     			begin = end + 1;
82 | 0 |
     			left = Integer.parseInt( source.substring(begin).trim() );
83 |  |
84 | 0 |
     			return new Insets( top, left, bottom, right );
85 |  |
     		}
86 | 0 |
     		catch( Exception e )	{
87 | 0 |
     			throw new IllegalArgumentException( e.getMessage() );
88 |  |
     		}
89 |  |
     	}
90 |  |
     }

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