當前位置: 首頁>>代碼示例>>Java>>正文


Java FreeColXMLReader.atTag方法代碼示例

本文整理匯總了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)));
    }
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:79,代碼來源:AIMain.java


注:本文中的net.sf.freecol.common.io.FreeColXMLReader.atTag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。