View Javadoc

1   /*
2    *   Magic-Project is a turn based strategy simulator
3    *   Copyright (C) 2003-2007 Fabrice Daugan
4    *
5    *   This program is free software; you can redistribute it and/or modify it 
6    * under the terms of the GNU General Public License as published by the Free 
7    * Software Foundation; either version 2 of the License, or (at your option) any
8    * later version.
9    *
10   *   This program is distributed in the hope that it will be useful, but WITHOUT 
11   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
13   * details.
14   *
15   *   You should have received a copy of the GNU General Public License along  
16   * with this program; if not, write to the Free Software Foundation, Inc., 
17   * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  package net.sf.magicproject.zone;
20  
21  import java.io.IOException;
22  import java.io.InputStream;
23  
24  import org.apache.commons.lang.StringUtils;
25  
26  import net.sf.magicproject.tools.MToolKit;
27  
28  /***
29   * Corresponds to the zone configuration : name and borderlayout constraints.
30   * 
31   * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
32   * @since 0.93
33   */
34  public class ZoneConfiguration {
35  
36  	/***
37  	 * The zone name.
38  	 */
39  	private final String zoneName;
40  
41  	/***
42  	 * The zone id.
43  	 */
44  	private final int zoneId;
45  
46  	/***
47  	 * The layout constraint when this zone is controled by you.
48  	 */
49  	private final String layoutConstraintYou;
50  
51  	/***
52  	 * The layout class name.
53  	 */
54  	private final String layoutClass;
55  
56  	/***
57  	 * The layout constraint when this zone is controled by the opponent.
58  	 */
59  	private final String layoutConstraintOpponent;
60  
61  	/***
62  	 * Create a new instance of this class from a steam.
63  	 * 
64  	 * @param dbStream
65  	 *          the stream containing the configuration.
66  	 * @param zoneId
67  	 *          the zone id of this configuration.
68  	 * @throws IOException
69  	 *           If some other I/O error occurs
70  	 */
71  	ZoneConfiguration(InputStream dbStream, int zoneId) throws IOException {
72  		this.zoneId = zoneId;
73  		zoneName = MToolKit.readString(dbStream);
74  		layoutClass = StringUtils.trimToNull(MToolKit.readString(dbStream));
75  		layoutConstraintYou = MToolKit.readString(dbStream);
76  		layoutConstraintOpponent = MToolKit.readString(dbStream);
77  	}
78  
79  	/***
80  	 * The layout constraint when this zone is controled by the opponent.
81  	 * 
82  	 * @return The layout constraint when this zone is controled by the opponent.
83  	 */
84  	public String getLayoutConstraintOpponent() {
85  		return this.layoutConstraintOpponent;
86  	}
87  
88  	/***
89  	 * The layout constraint when this zone is controled by you.
90  	 * 
91  	 * @return The layout constraint when this zone is controled by you.
92  	 */
93  	public String getLayoutConstraintYou() {
94  		return this.layoutConstraintYou;
95  	}
96  
97  	/***
98  	 * The zone name.
99  	 * 
100 	 * @return zone name.
101 	 */
102 	public String getZoneName() {
103 		return this.zoneName;
104 	}
105 
106 	/***
107 	 * The zone id.
108 	 * 
109 	 * @return zone id.
110 	 */
111 	public int getZoneId() {
112 		return this.zoneId;
113 	}
114 
115 	/***
116 	 * The layout class name.
117 	 * 
118 	 * @return The layout class name.
119 	 */
120 	public String getLayoutClass() {
121 		return this.layoutClass;
122 	}
123 }