本文整理匯總了Java中net.sf.freecol.common.io.FreeColXMLReader.atTag方法的典型用法代碼示例。如果您正苦於以下問題:Java FreeColXMLReader.atTag方法的具體用法?Java FreeColXMLReader.atTag怎麽用?Java FreeColXMLReader.atTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.sf.freecol.common.io.FreeColXMLReader
的用法示例。
在下文中一共展示了FreeColXMLReader.atTag方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: readChild
import net.sf.freecol.common.io.FreeColXMLReader; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
protected void readChild(FreeColXMLReader xr) throws XMLStreamException {
final String tag = xr.getLocalName();
final String oid = xr.readId();
try {
Wish wish = null;
// The AI data is quite shallow, so we can get away with
// fixing up forward references just with this simple
// lookup. AIObjects that can be forward referenced must
// ensure they complete initialization somewhere in their
// serialization read* routines.
AIObject aio;
if (oid != null && (aio = getAIObject(oid)) != null) {
aio.readFromXML(xr);
} else if (AIColony.TAG.equals(tag)) {
new AIColony(this, xr);
} else if (AIGoods.TAG.equals(tag)) {
new AIGoods(this, xr);
} else if (AIPlayer.TAG.equals(tag)) {
Player p = getGame().getFreeColGameObject(oid, Player.class);
if (p != null) {
if (p.isIndian()) {
new NativeAIPlayer(this, xr);
} else if (p.isREF()) {
new REFAIPlayer(this, xr);
} else if (p.isEuropean()) {
new EuropeanAIPlayer(this, xr);
} else {
throw new RuntimeException("Bogus AIPlayer: " + p);
}
}
} else if (AIUnit.TAG.equals(tag)) {
new AIUnit(this, xr);
} else if (GoodsWish.TAG.equals(tag)
// @compat 0.11.3
|| OLD_GOODS_WISH_TAG.equals(tag)
// end @compat 0.11.3
) {
wish = new GoodsWish(this, xr);
} else if (TileImprovementPlan.TAG.equals(tag)
// @compat 0.11.3
|| OLD_TILE_IMPROVEMENT_PLAN_TAG.equals(tag)
// end @compat
) {
new TileImprovementPlan(this, xr);
} else if (WorkerWish.TAG.equals(tag)) {
wish = new WorkerWish(this, xr);
} else {
super.readChild(xr);
}
if (wish != null) {
AIColony ac = wish.getDestinationAIColony();
if (ac != null) ac.addWish(wish);
}
} catch (Exception e) {
logger.log(Level.WARNING, "Exception reading AIObject: "
+ tag + ", id=" + oid, e);
// We are hosed. Try to resynchronize at the end of the tag
// or aiMain.
final String mainTag = TAG;
while (xr.moreTags() || !(xr.atTag(tag) || xr.atTag(mainTag)));
}
}