| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| tsukuba_bunko.peko.resource.PointDeserializer |
|
|
| 1 | /* |
|
| 2 | * "Peko" Visual Novel System |
|
| 3 | * |
|
| 4 | * All Rights Reserved. |
|
| 5 | * Copyright (c) 1999-2003 Tsukuba Bunko. |
|
| 6 | * |
|
| 7 | * $Id: PointDeserializer.java,v 1.1 2005/07/11 12:49:18 ppoi Exp $ |
|
| 8 | */ |
|
| 9 | package tsukuba_bunko.peko.resource; |
|
| 10 | ||
| 11 | import java.awt.Point; |
|
| 12 | ||
| 13 | import org.xml.sax.SAXException; |
|
| 14 | ||
| 15 | import tsukuba_bunko.resource.SimpleDeserializer; |
|
| 16 | ||
| 17 | ||
| 18 | /** |
|
| 19 | * {@link java.awt.Point} 型のリソースに対する {@link tsukuba_bunko.resource.ResourceDeserializer} 実装です。 |
|
| 20 | * @author $Author: ppoi $ |
|
| 21 | * @version $Revision: 1.1 $ |
|
| 22 | * @see <a href="http://softlab.tsukuba-bunko.org/peko/userguide/resource.html#type-peko:point">peko:point 型のリソース</a> |
|
| 23 | */ |
|
| 24 | public class PointDeserializer extends SimpleDeserializer { |
|
| 25 | ||
| 26 | /** |
|
| 27 | * <code>DimensionDeserializer</code> のインスタンスを作成します。 |
|
| 28 | */ |
|
| 29 | public PointDeserializer() |
|
| 30 | { |
|
| 31 | 0 | super(); |
| 32 | 0 | } |
| 33 | ||
| 34 | ||
| 35 | // |
|
| 36 | // SimpleDeserializer の実装 |
|
| 37 | // |
|
| 38 | protected Object convertValue( String source ) |
|
| 39 | throws SAXException |
|
| 40 | { |
|
| 41 | try { |
|
| 42 | 0 | return PointDeserializer.parsePoint( source ); |
| 43 | } |
|
| 44 | 0 | catch( Exception e ) { |
| 45 | 0 | throw new SAXException( e ); |
| 46 | } |
|
| 47 | } |
|
| 48 | ||
| 49 | ||
| 50 | /** |
|
| 51 | * <code>source</code> を Dimension として解析します。 |
|
| 52 | * @param source 解析元の文字列 |
|
| 53 | * @return 解析結果 |
|
| 54 | */ |
|
| 55 | public static Point parsePoint( String source ) |
|
| 56 | throws IllegalArgumentException |
|
| 57 | { |
|
| 58 | try { |
|
| 59 | 0 | int delm = source.indexOf( ',' ); |
| 60 | 0 | int x = Integer.parseInt( source.substring(0, delm).trim() ); |
| 61 | 0 | int y = Integer.parseInt( source.substring(delm + 1).trim() ); |
| 62 | 0 | return new Point( x, y ); |
| 63 | } |
|
| 64 | 0 | catch( Exception e ) { |
| 65 | 0 | throw new IllegalArgumentException( e.getMessage() ); |
| 66 | } |
|
| 67 | } |
|
| 68 | } |
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |