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


Java FreeColXMLReader.moreTags方法代码示例

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


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

示例1: 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

示例2: 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

示例3: NationSummaryMessage

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

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

示例4: 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

示例5: readStorage

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
 * Read a storage container from a stream.
 *
 * @param xr The {@code FreeColXMLReader} to read from.
 * @param storage The storage container.
 * @exception XMLStreamException if there is a problem reading from
 *     the stream.
 */
private void readStorage(FreeColXMLReader xr,
    Map<GoodsType, Integer> storage) throws XMLStreamException {
    final Specification spec = getGame().getSpecification();

    while (xr.moreTags()) {
        String tag = xr.getLocalName();

        if (Goods.TAG.equals(tag)) {
            GoodsType goodsType = xr.getType(spec, TYPE_TAG,
                GoodsType.class, (GoodsType)null);

            int amount = xr.getAttribute(AMOUNT_TAG, 0);

            storage.put(goodsType, amount);

        } else {
            throw new XMLStreamException("Bogus GoodsContainer tag: "
                + tag);
        }
        xr.closeTag(tag);
    }
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:31,代码来源:GoodsContainer.java

示例6: 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:wintertime,项目名称:FreeCol,代码行数:24,代码来源:ServerListMessage.java

示例7: readFromXML

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
private static void readFromXML(FreeColXMLReader xr) throws XMLStreamException {
    while (xr.moreTags()) {
        String tag = xr.getLocalName();
        if (null != tag) switch (tag) {
            case VERSION_TAG:
                xr.nextTag();
                break;
            case GENERATION_TAG:
                xr.nextTag();
                break;
            case PLURALS_TAG:
                while (xr.moreTags()) {
                    tag = xr.getLocalName();
                    if (PLURAL_RULES_TAG.equals(tag)) {
                        readChild(xr);
                    }
                }   break;
        }
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:21,代码来源:NumberRules.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:wintertime,项目名称:FreeCol,代码行数:29,代码来源:DeliverGiftMessage.java

示例9: AnimateMoveMessage

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
 * Create a new {@code AnimateMoveMessage} 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 AnimateMoveMessage(Game game, FreeColXMLReader xr)
    throws XMLStreamException {
    super(TAG, xr, NEW_TILE_TAG, OLD_TILE_TAG, UNIT_TAG);

    FreeColXMLReader.ReadScope rs
        = xr.replaceScope(FreeColXMLReader.ReadScope.NOINTERN);
    Unit unit = null;
    try {
        while (xr.moreTags()) {
            String tag = xr.getLocalName();
            if (Unit.TAG.equals(tag)) {
                if (unit == null) {
                    unit = xr.readFreeColObject(game, Unit.class);
                } else {
                    expected(TAG, tag);
                }
            } else {
                expected(Unit.TAG, tag);
            }
            xr.expectTag(tag);
        }
        xr.expectTag(TAG);
    } finally {
        xr.replaceScope(rs);
    }
    appendChild(unit);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:35,代码来源:AnimateMoveMessage.java

示例10: readChildren

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

    // Clear containers.
    if (xr.shouldClearContainers()) {
        this.production = null;
    }

    while (xr.moreTags()) {
        final String tag = xr.getLocalName();

        if (PRODUCTION_TAG.equals(tag)) {
            GoodsType type = xr.getType(spec, GOODS_TYPE_TAG,
                                        GoodsType.class, (GoodsType)null);

            int amount = xr.getAttribute(VALUE_TAG, 0);

            this.production = new AbstractGoods(type, amount);

            xr.closeTag(PRODUCTION_TAG);

        } else {
            throw new XMLStreamException("Bogus TileTypeChange tag: "
                + tag);
        }
    }
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:32,代码来源:TileTypeChange.java

示例11: FeatureChangeMessage

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
 * Create a new {@code FeatureChangeMessage} 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 FeatureChangeMessage(Game game, FreeColXMLReader xr)
    throws XMLStreamException {
    super(TAG, xr, ID_TAG, ADD_TAG);

    FreeColXMLReader.ReadScope rs
        = xr.replaceScope(FreeColXMLReader.ReadScope.NOINTERN);
    try {
        while (xr.moreTags()) {
            String tag = xr.getLocalName();
            FreeColObject fco = null;
            if (Ability.TAG.equals(tag)) {
                fco = xr.readFreeColObject(game, Ability.class);
            } else if (Modifier.TAG.equals(tag)) {
                fco = xr.readFreeColObject(game, Modifier.class);
            } else if (HistoryEvent.TAG.equals(tag)) {
                fco = xr.readFreeColObject(game, HistoryEvent.class);
            } else if (LastSale.TAG.equals(tag)) {
                fco = xr.readFreeColObject(game, LastSale.class);
            } else if (ModelMessage.TAG.equals(tag)) {
                fco = xr.readFreeColObject(game, ModelMessage.class);
            } else {
                expected("Feature", tag);
            }
            appendChild(fco);
            xr.expectTag(tag);
        }
        xr.expectTag(TAG);
    } finally {
        xr.replaceScope(rs);
    }
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:39,代码来源:FeatureChangeMessage.java

示例12: DiplomacyMessage

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

    FreeColXMLReader.ReadScope rs
        = xr.replaceScope(FreeColXMLReader.ReadScope.NOINTERN);
    DiplomaticTrade agreement = null;
    Unit extraUnit = null;
    try {
        while (xr.moreTags()) {
            String tag = xr.getLocalName();
            if (DiplomaticTrade.TAG.equals(tag)) {
                if (agreement == null) {
                    agreement = xr.readFreeColObject(game, DiplomaticTrade.class);
                } else {
                    expected(TAG, tag);
                }
            } else if (Unit.TAG.equals(tag)) {
                if (extraUnit == null) {
                    extraUnit = xr.readFreeColObject(game, Unit.class);
                } else {
                    expected(TAG, tag);
                }
            } else {
                expected((agreement == null) ? DiplomaticTrade.TAG : Unit.TAG,
                    tag);
            }
            xr.expectTag(tag);
        }
        xr.expectTag(TAG);
    } finally {
        xr.replaceScope(rs);
    }
    appendChild(agreement);
    appendChild(extraUnit);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:43,代码来源:DiplomacyMessage.java

示例13: 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:FreeCol,项目名称:freecol,代码行数:22,代码来源:MultipleMessage.java

示例14: readChildren

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
@Override
public void readChildren(FreeColXMLReader xr) throws XMLStreamException {
    while (xr.moreTags()) {
        Modifier modifier = new Modifier(xr, Specification.this);
        Specification.this.addModifier(modifier);
        Specification.this.specialModifiers.add(modifier);
    }
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:9,代码来源:Specification.java

示例15: readFromXML

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
 * Initializes this object from its XML-representation.
 *
 * @param xr The {@code FreeColXMLReader} to read from.
 * @exception XMLStreamException if there are any problems reading
 *     the stream.
 */
public void readFromXML(FreeColXMLReader xr) throws XMLStreamException {
    // Beware!  We load mods onto an existing specification, but
    // we do not want to overwrite its main attributes (id,
    // difficulty, version) So only set those variables if they
    // are currently null, as will be the case when we load the
    // root specification.
    String newId = xr.readId();
    if (id == null) id = newId;

    if (difficultyLevel == null) {
        difficultyLevel = xr.getAttribute(DIFFICULTY_LEVEL_TAG,
                                          (String)null);
        // @compat 0.11.3
        if (difficultyLevel == null) {
            difficultyLevel = xr.getAttribute(OLD_DIFFICULTY_LEVEL_TAG,
                                              (String)null);
        }
        // end @compat 0.11.3
    }

    if (version == null) {
        version = xr.getAttribute(VERSION_TAG, (String)null);
    }

    logger.fine("Reading specification " + newId
        + " difficulty=" + difficultyLevel
        + " version=" + version);

    String parentId = xr.getAttribute(FreeColSpecObjectType.EXTENDS_TAG,
                                      (String)null);
    if (parentId != null) {
        try {
            FreeColTcFile parent = FreeColTcFile.getFreeColTcFile(parentId);
            load(parent.getSpecificationInputStream());
            initialized = false;
        } catch (IOException e) {
            throw new XMLStreamException("Failed to open parent specification: ", e);
        }
    }

    while (xr.moreTags()) {
        String childName = xr.getLocalName();
        // @compat 0.11.0
        if (childName.equals(OLD_EQUIPMENT_TYPES_TAG)) {
            xr.swallowTag(OLD_EQUIPMENT_TYPES_TAG);
            continue;
        }
        // end @compat 0.11.0
        ChildReader reader = readerMap.get(childName);
        if (reader == null) {
            logger.warning("No reader found for: " + childName);
        } else {
            reader.readChildren(xr);
        }
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:64,代码来源:Specification.java


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