当前位置: 首页>>代码示例>>Java>>正文


Java FreeColXMLReader.getLocalName方法代码示例

本文整理汇总了Java中net.sf.freecol.common.io.FreeColXMLReader.getLocalName方法的典型用法代码示例。如果您正苦于以下问题:Java FreeColXMLReader.getLocalName方法的具体用法?Java FreeColXMLReader.getLocalName怎么用?Java FreeColXMLReader.getLocalName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.freecol.common.io.FreeColXMLReader的用法示例。


在下文中一共展示了FreeColXMLReader.getLocalName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();

    if (MARKET_TAG.equals(tag)) {
        initialAmount = xr.getAttribute(INITIAL_AMOUNT_TAG, 0);

        initialPrice = xr.getAttribute(INITIAL_PRICE_TAG, 1);

        priceDiff = xr.getAttribute(PRICE_DIFFERENCE_TAG, 1);

        xr.closeTag(MARKET_TAG);

    } else {
        super.readChild(xr);
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:21,代码来源:GoodsType.java

示例2: HighScoresMessage

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
 * Create a new {@code HighScoresMessage} from a stream.
 *
 * @param game The {@code Game} this message belongs to.
 * @param xr The {@code FreeColXMLReader} to read from.
 * @exception XMLStreamException if there is a problem reading the stream.
 */
public HighScoresMessage(Game game, FreeColXMLReader xr)
    throws XMLStreamException {
    super(TAG, xr, KEY_TAG);

    List<HighScore> scores = new ArrayList<>();
    while (xr.moreTags()) {
        String tag = xr.getLocalName();
        if (HighScore.TAG.equals(tag)) {
            HighScore hs = new HighScore(xr);
            if (hs != null) scores.add(hs);
        } else {
            expected(HighScore.TAG, tag);
        }
        xr.expectTag(tag);
    }
    xr.expectTag(TAG);
    appendChildren(scores);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:26,代码来源:HighScoresMessage.java

示例3: AddPlayerMessage

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
 * Create a new {@code AddPlayerMessage} from a stream.
 *
 * @param game The {@code Game} this message belongs to.
 * @param xr The {@code FreeColXMLReader} to read from.
 * @exception XMLStreamException if there is a problem reading the stream.
 */
public AddPlayerMessage(Game game, FreeColXMLReader xr)
    throws XMLStreamException {
    super(TAG);

    this.destination = null;
    FreeColXMLReader.ReadScope rs
        = xr.replaceScope(FreeColXMLReader.ReadScope.NOINTERN);
    List<Player> players = new ArrayList<>();
    try {
        while (xr.moreTags()) {
            String tag = xr.getLocalName();
            if (Player.TAG.equals(tag)) {
                Player p = xr.readFreeColObject(game, Player.class);
                if (p != null) players.add(p);
            } else {
                expected(Player.TAG, tag);
            }
            xr.expectTag(tag);
        }
        xr.expectTag(TAG);
    } finally {
        xr.replaceScope(rs);
    }
    appendChildren(players);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:33,代码来源:AddPlayerMessage.java

示例4: UpdateMessage

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
 * Create a new {@code UpdateMessage} from a stream.
 *
 * @param game The {@code Game} this message belongs to.
 * @param xr The {@code FreeColXMLReader} to read from.
 * @exception XMLStreamException if there is a problem reading the stream.
 */
public UpdateMessage(Game game, FreeColXMLReader xr)
    throws XMLStreamException {
    this((ServerPlayer)null);

    FreeColXMLReader.ReadScope rs
        = xr.replaceScope(FreeColXMLReader.ReadScope.NOINTERN);
    List<FreeColObject> fcos = new ArrayList<>();
    try {
        while (xr.moreTags()) {
            String tag = xr.getLocalName();
            fcos.add(xr.readFreeColObject(game));
            xr.expectTag(tag);
        }
        xr.expectTag(TAG);
    } finally {
        xr.replaceScope(rs);
    }
    appendChildren(fcos);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:27,代码来源:UpdateMessage.java

示例5: ServerListMessage

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
 * Create a new {@code ServerListMessage} from a stream.
 *
 * @param game The {@code Game}, which is null and ignored.
 * @param xr The {@code FreeColXMLReader} to read from.
 * @exception XMLStreamException if there is a problem reading the stream.
 */
public ServerListMessage(Game game, FreeColXMLReader xr)
    throws XMLStreamException {
    this();

    List<ServerInfo> svs = new ArrayList<>();
    while (xr.moreTags()) {
        String tag = xr.getLocalName();
        if (ServerInfo.TAG.equals(tag)) {
            svs.add(new ServerInfoMessage(tag, game, xr).getServerInfo());
        } else {
            expected(ServerInfo.TAG, tag);
        }
    }
    xr.expectTag(TAG);
    addServers(svs);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:24,代码来源:ServerListMessage.java

示例6: MonarchActionMessage

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
 * Create a new {@code MonarchActionMessage} from a stream.
 *
 * @param game The {@code Game} this message belongs to.
 * @param xr The {@code FreeColXMLReader} to read from.
 * @exception XMLStreamException if there is a problem reading the stream.
 */
public MonarchActionMessage(Game game, FreeColXMLReader xr)
    throws XMLStreamException {
    super(TAG, xr, ACTION_TAG, MONARCH_TAG, TAX_TAG, RESULT_TAG);

    StringTemplate template = null;
    while (xr.moreTags()) {
        String tag = xr.getLocalName();
        if (StringTemplate.TAG.equals(tag)) {
            if (template == null) {
                template = xr.readFreeColObject(game, StringTemplate.class);
            } else {
                expected(TAG, tag);
            }
        } else {
            expected(StringTemplate.TAG, tag);
        }
        xr.expectTag(tag);
    }
    xr.expectTag(TAG);
    appendChild(template);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:29,代码来源:MonarchActionMessage.java

示例7: readChild

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void readChild(FreeColXMLReader xr) throws XMLStreamException {
    final String tag = xr.getLocalName();

    if (tag != null) {
        switch (tag) {
        case NUMBER_TAG:
            requireNumberOption();
            numberOption.readFromXML(xr);
            break;
        case ROLE_TAG:
            requireRoleOption();
            roleOption.readFromXML(xr);
            break;
        case UNIT_TYPE_TAG:
            requireUnitTypeOption();
            unitTypeOption.readFromXML(xr);
            break;
        default:
            super.readChild(xr);
            break;
        }
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:28,代码来源:AbstractUnitOption.java

示例8: DeliverGiftMessage

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
 * Create a new {@code DeliverGiftMessage} from stream.
 *
 * @param game The {@code Game} this message belongs to.
 * @param xr The {@code FreeColXMLReader} to read from.
 * @exception XMLStreamException if there a problem reading the stream.
 */
public DeliverGiftMessage(Game game, FreeColXMLReader xr)
    throws XMLStreamException {
    super(TAG, xr, UNIT_TAG, SETTLEMENT_TAG);

    Goods goods = null;
    while (xr.moreTags()) {
        String tag = xr.getLocalName();
        if (Goods.TAG.equals(tag)) {
            if (goods == null) {
                goods = xr.readFreeColObject(game, Goods.class);
            } else {
                expected(TAG, tag);
            }
        } else {
            expected(Goods.TAG, tag);
        }
        xr.expectTag(tag);
    }
    xr.expectTag(TAG);
    appendChild(goods);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:29,代码来源:DeliverGiftMessage.java

示例9: readChild

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void readChild(FreeColXMLReader xr) throws XMLStreamException {
    final Specification spec = getSpecification();
    final String tag = xr.getLocalName();

    if (CARGO_TAG.equals(tag)) {
        cargo.add(xr.getType(spec, ID_ATTRIBUTE_TAG,
                             GoodsType.class, (GoodsType)null));

        xr.closeTag(CARGO_TAG);

    } else {
        super.readChild(xr);
    }
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:19,代码来源:TradeRouteStop.java

示例10: MultipleMessage

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
 * Create a new {@code MultipleMessage} from a stream.
 *
 * @param game The {@code Game} to read within.
 * @param xr The {@code FreeColXMLReader} to read from.
 * @exception XMLStreamException if the stream is corrupt.
 * @exception FreeColException if the internal message can not be read.
 */
public MultipleMessage(Game game, FreeColXMLReader xr)
    throws XMLStreamException, FreeColException {
    this();
    
    this.messages.clear();
    while (xr.moreTags()) {
        final String mt = xr.getLocalName();
        Message m = Message.read(game, xr);
        if (m != null) this.messages.add(m);
        xr.expectTag(mt);
    }
    xr.expectTag(TAG);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:22,代码来源:MultipleMessage.java

示例11: readChild

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void readChild(FreeColXMLReader xr) throws XMLStreamException {
    final AIMain aiMain = getAIMain();
    final String tag = xr.getLocalName();

    if (AI_GOODS_LIST_TAG.equals(tag)) {
        addExportGoods(xr.makeAIObject(aiMain, ID_ATTRIBUTE_TAG,
                                       AIGoods.class, (AIGoods)null, true));
        xr.closeTag(AI_GOODS_LIST_TAG);

    } else if (GOODS_WISH_LIST_TAG.equals(tag)) {
        wishes.add(xr.makeAIObject(aiMain, ID_ATTRIBUTE_TAG,
                                   GoodsWish.class, (GoodsWish)null, true));
        xr.closeTag(GOODS_WISH_LIST_TAG);

    } else if (TILE_IMPROVEMENT_PLAN_LIST_TAG.equals(tag)
        // @compat 0.11.3
        || OLD_TILE_IMPROVEMENT_PLAN_LIST_TAG.equals(tag)
        // end @compat 0.11.3
               ) {
        tileImprovementPlans.add(xr.makeAIObject(aiMain, ID_ATTRIBUTE_TAG,
                TileImprovementPlan.class, (TileImprovementPlan)null, true));
        xr.closeTag(tag);// FIXME: tag -> TILE_IMPROVEMENT_PLAN_LIST_TAG

    } else if (WORKER_WISH_LIST_TAG.equals(tag)) {
        wishes.add(xr.makeAIObject(aiMain, ID_ATTRIBUTE_TAG,
                                   WorkerWish.class, (WorkerWish)null, true));
        xr.closeTag(WORKER_WISH_LIST_TAG);

    } else {
        super.readChild(xr);
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:37,代码来源:AIColony.java

示例12: readChild

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void readChild(FreeColXMLReader xr) throws XMLStreamException {
    final String tag = xr.getLocalName();

    if (Cargo.TAG.equals(tag)) {
        tAdd(new Cargo(getAIMain(), xr), -1);

    } else {
        super.readChild(xr);
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:15,代码来源:TransportMission.java

示例13: readChild

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void readChild(FreeColXMLReader xr) throws XMLStreamException {
    final String tag = xr.getLocalName();

    if (TradeRouteStop.TAG.equals(tag)) {
        TradeRouteStop trs = new TradeRouteStop(getGame(), xr);
        if (trs != null) addStop(trs);
        
    } else {
        super.readChild(xr);
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:16,代码来源:TradeRoute.java

示例14: readChild

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void readChild(FreeColXMLReader xr) throws XMLStreamException {
    final Specification spec = getSpecification();
    final String tag = xr.getLocalName();

    if (TILE_TYPE_CHANGE_TAG.equals(tag)
        // @compat 0.11.6
        || OLD_CHANGE_TAG.equals(tag)
        // end @compat 0.11.6
        ) {
        TileTypeChange change = new TileTypeChange(xr, spec);
        if (change != null) addChange(change);

    } else if (DISASTER_TAG.equals(tag)) {
        Disaster disaster = xr.getType(spec, ID_ATTRIBUTE_TAG,
                                       Disaster.class, (Disaster)null);
        int probability = xr.getAttribute(PROBABILITY_TAG, 100);
        addDisaster(disaster, probability);
        xr.closeTag(DISASTER_TAG);

    } else if (WORKER_TAG.equals(tag)) {
        addAllowedWorker(xr.readId());
        xr.closeTag(WORKER_TAG);

    } else {
        super.readChild(xr);
    }
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:32,代码来源:TileImprovementType.java

示例15: readChild

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void readChild(FreeColXMLReader xr) throws XMLStreamException {
    final Specification spec = getSpecification();
    final String tag = xr.getLocalName();

    if (REQUIRED_ABILITY_TAG.equals(tag)) {
        String id = xr.readId();
        addRequiredAbility(id, xr.getAttribute(VALUE_TAG, true));
        spec.addAbility(id);
        xr.closeTag(REQUIRED_ABILITY_TAG);

    } else if (REQUIRED_GOODS_TAG.equals(tag)) {
        GoodsType type = xr.getType(spec, ID_ATTRIBUTE_TAG,
                GoodsType.class, (GoodsType)null);
        int amount = xr.getAttribute(VALUE_TAG, 0);
        addRequiredGoods(new AbstractGoods(type, amount));
        xr.closeTag(REQUIRED_GOODS_TAG);

    } else if (Limit.TAG.equals(tag)) {
        Limit limit = new Limit(xr, spec);
        if (limit.getLeftHandSide().getType() == null) {
            limit.getLeftHandSide().setType(getId());
        }
        addLimit(limit);

    } else {
        super.readChild(xr);
    }
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:33,代码来源:BuildableType.java


注:本文中的net.sf.freecol.common.io.FreeColXMLReader.getLocalName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。