|
From: <bur...@us...> - 2010-06-13 11:13:50
|
Revision: 6998
http://freecol.svn.sourceforge.net/freecol/?rev=6998&view=rev
Author: burschik
Date: 2010-06-13 11:13:44 +0000 (Sun, 13 Jun 2010)
Log Message:
-----------
Serialize TileType.
Modified Paths:
--------------
freecol/trunk/src/net/sf/freecol/common/model/Specification.java
freecol/trunk/src/net/sf/freecol/common/model/TileType.java
Modified: freecol/trunk/src/net/sf/freecol/common/model/Specification.java
===================================================================
--- freecol/trunk/src/net/sf/freecol/common/model/Specification.java 2010-06-13 10:44:32 UTC (rev 6997)
+++ freecol/trunk/src/net/sf/freecol/common/model/Specification.java 2010-06-13 11:13:44 UTC (rev 6998)
@@ -1100,6 +1100,7 @@
writeSection(out, "events", events);
writeSection(out, "goods-types", goodsTypeList);
writeSection(out, "resource-types", resourceTypeList);
+ writeSection(out, "tile-types", tileTypeList);
writeSection(out, "founding-fathers", foundingFathers);
writeSection(out, "european-nation-types", europeanNationTypes);
Modified: freecol/trunk/src/net/sf/freecol/common/model/TileType.java
===================================================================
--- freecol/trunk/src/net/sf/freecol/common/model/TileType.java 2010-06-13 10:44:32 UTC (rev 6997)
+++ freecol/trunk/src/net/sf/freecol/common/model/TileType.java 2010-06-13 11:13:44 UTC (rev 6998)
@@ -28,6 +28,7 @@
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
import net.sf.freecol.common.option.StringOption;
import net.sf.freecol.common.util.RandomChoice;
@@ -407,4 +408,82 @@
}
}
+ /**
+ * Makes an XML-representation of this object.
+ *
+ * @param out The output stream.
+ * @throws XMLStreamException if there are any problems writing to the
+ * stream.
+ */
+ protected void toXMLImpl(XMLStreamWriter out) throws XMLStreamException {
+ // Start element:
+ out.writeStartElement(getXMLElementTagName());
+
+ // Add attributes:
+ out.writeAttribute(ID_ATTRIBUTE_TAG, getId());
+ out.writeAttribute("basic-move-cost", Integer.toString(basicMoveCost));
+ out.writeAttribute("basic-work-turns", Integer.toString(basicWorkTurns));
+ out.writeAttribute("is-forest", Boolean.toString(forest));
+ out.writeAttribute("is-water", Boolean.toString(water));
+ out.writeAttribute("is-connected", Boolean.toString(connected));
+ out.writeAttribute("can-settle", Boolean.toString(canSettle));
+
+ out.writeStartElement("gen");
+ out.writeAttribute("humidityMin", Integer.toString(humidity[0]));
+ out.writeAttribute("humidityMax", Integer.toString(humidity[1]));
+ out.writeAttribute("temperatureMin", Integer.toString(temperature[0]));
+ out.writeAttribute("temperatureMax", Integer.toString(temperature[1]));
+ out.writeAttribute("altitudeMin", Integer.toString(altitude[0]));
+ out.writeAttribute("altitudeMax", Integer.toString(altitude[1]));
+ out.writeEndElement();
+
+ for (Map.Entry<String, AbstractGoods> entry : primaryGoodsMap.entrySet()) {
+ out.writeStartElement("primary-production");
+ out.writeAttribute("goods-type", entry.getValue().getType().getId());
+ out.writeAttribute("value", Integer.toString(entry.getValue().getAmount()));
+ if (entry.getKey() != null) {
+ out.writeAttribute("tile-production", entry.getKey());
+ }
+ out.writeEndElement();
+ }
+
+ for (Map.Entry<String, AbstractGoods> entry : secondaryGoodsMap.entrySet()) {
+ out.writeStartElement("secondary-production");
+ out.writeAttribute("goods-type", entry.getValue().getType().getId());
+ out.writeAttribute("value", Integer.toString(entry.getValue().getAmount()));
+ if (entry.getKey() != null) {
+ out.writeAttribute("tile-production", entry.getKey());
+ }
+ out.writeEndElement();
+ }
+
+ for (Map.Entry<String, Map<GoodsType, AbstractGoods>> entry : productionMap.entrySet()) {
+ for (AbstractGoods goods : entry.getValue().values()) {
+ out.writeStartElement("production");
+ out.writeAttribute("goods-type", goods.getType().getId());
+ out.writeAttribute("value", Integer.toString(goods.getAmount()));
+ if (entry.getKey() != null) {
+ out.writeAttribute("tile-production", entry.getKey());
+ }
+ out.writeEndElement();
+ }
+ }
+
+ for (RandomChoice<ResourceType> choice : resourceType) {
+ out.writeStartElement("resource");
+ out.writeAttribute("type", choice.getObject().getId());
+ out.writeAttribute("probability", Integer.toString(choice.getProbability()));
+ out.writeEndElement();
+ }
+
+ // End element:
+ out.writeEndElement();
+
+ }
+
+ public static String getXMLElementTagName() {
+ return "tile-type";
+ }
+
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|