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


Java FreeColXMLReader类代码示例

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


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

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

示例2: readAttributes

import net.sf.freecol.common.io.FreeColXMLReader; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void readAttributes(FreeColXMLReader xr) throws XMLStreamException {
    super.readAttributes(xr);

    final Specification spec = getSpecification();

    owner = xr.findFreeColGameObject(getGame(), OWNER_TAG,
                                     Player.class, (Player)null, true);

    baseRecruitPrice = xr.getAttribute(RECRUIT_PRICE_TAG,
                                       RECRUIT_PRICE_INITIAL);

    recruitLowerCap = xr.getAttribute(RECRUIT_LOWER_CAP_TAG,
                                      LOWER_CAP_INITIAL);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:19,代码来源:Europe.java

示例3: readChild

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

    if (OLD_STORED_GOODS_TAG.equals(tag)) {
        synchronized (this.oldStoredGoods) {
            readStorage(xr, this.oldStoredGoods);
        }

    } else if (STORED_GOODS_TAG.equals(tag)) {
        synchronized (this.storedGoods) {
            readStorage(xr, this.storedGoods);
        }

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

示例4: readChildren

import net.sf.freecol.common.io.FreeColXMLReader; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void readChildren(FreeColXMLReader xr) throws XMLStreamException {
    // The tiles structure is large, and individually
    // overwriteable, so we do not clear it unlike most other containers.

    super.readChildren(xr);

    // Fix up settlement tile ownership in one hit here, avoiding
    // complications with cached tiles within the Tile serialization.
    forEachTile(t -> {
            Settlement s = t.getOwningSettlement();
            if (s != null) s.addTile(t);
        });

    // @compat 0.11.3
    // Maps with incorrect parent/child chains were occurring.
    fixupRegions();
    // end @compat 0.11.3
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:23,代码来源:Map.java

示例5: readChild

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

    if (LostCityRumour.TAG.equals(tag)) {
        LostCityRumour lcr = xr.readFreeColObject(game, LostCityRumour.class);
        if (lcr != null) addTileItem(lcr);

    } else if (Resource.TAG.equals(tag)) {
        addTileItem(xr.readFreeColObject(game, Resource.class));

    } else if (TileImprovement.TAG.equals(tag)
               // @compat 0.11.3
               || OLD_TILE_IMPROVEMENT_TAG.equals(tag)
               // end @compat 0.11.3
               ) {
        addTileItem(xr.readFreeColObject(game, TileImprovement.class));

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

示例6: readChild

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

    if (DESTINATION_TAG.equals(tag)) {
        addDestination(xr.getLocationAttribute(game, ID_ATTRIBUTE_TAG,
                                               true));

        xr.closeTag(DESTINATION_TAG);

    } else {
        super.readChild(xr);
    }
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:19,代码来源:HighSeas.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: 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 (PRODUCTION_TAG.equals(tag)) {
        if (xr.getAttribute(DELETE_TAG, false)) {
            productionTypes.clear();
            xr.closeTag(PRODUCTION_TAG);

        } else {
            addProductionType(new ProductionType(xr, spec));
        }

    } else {
        super.readChild(xr);
    }

    // @compat 0.11.6
    if (hasAbility(Ability.EXPERTS_USE_CONNECTIONS)
            && this.expertConnectionProduction == 0)
        this.expertConnectionProduction = 4;
    // end @compat 0.11.6
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:28,代码来源:BuildingType.java

示例9: readChildren

import net.sf.freecol.common.io.FreeColXMLReader; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void readChildren(FreeColXMLReader xr) throws XMLStreamException {
    // Clear containers.
    if (xr.shouldClearContainers()) {
        skills = null;
        regions = null;
    }

    final Specification spec = getSpecification();
    IndianNationType parent = xr.getType(spec, EXTENDS_TAG,
                                         IndianNationType.class, this);
    if (parent != this) {
        if (parent.skills != null && !parent.skills.isEmpty()) {
            if (skills == null) skills = new ArrayList<>();
            skills.addAll(parent.skills);
        }

        if (parent.regions != null && !parent.regions.isEmpty()) {
            if (regions == null) regions = new ArrayList<>();
            regions.addAll(parent.regions);
        }
    }

    super.readChildren(xr);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:29,代码来源:IndianNationType.java

示例10: readChild

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

    switch (tag) {
    case TEMPLATE_TAG:
        xr.nextTag();
        template = readChildOption(xr);
        xr.closeTag(TEMPLATE_TAG);
        break;
    default:
        try {
            AbstractOption<T> op = readChildOption(xr);
            if (op != null) addMember(op);
        } catch (XMLStreamException xse) {
            logger.log(Level.WARNING, "Invalid option at: " + tag, xse);
            xr.closeTag(tag);
        }
        break;
    }
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:25,代码来源:ListOption.java

示例11: readAttributes

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

    super.readAttributes(xr);

    this.type = xr.getType(spec, TYPE_TAG, GoodsType.class, (GoodsType)null);
    if (this.type == null) {
        throw new XMLStreamException("Null goods type.");
    } else {
        setId(this.type.getId());
    }

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

    this.location = xr.getLocationAttribute(game, LOCATION_TAG, true);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:21,代码来源:Goods.java

示例12: readChildren

import net.sf.freecol.common.io.FreeColXMLReader; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void readChildren(FreeColXMLReader xr) throws XMLStreamException {
    // We can not set the value until we have read the select options
    // so as to be able to check its validity.
    String value = xr.getAttribute(VALUE_TAG, (String)null);
    String defaultValue = xr.getAttribute(DEFAULT_VALUE_TAG, (String)null);

    // Clear containers.
    clearItemValues();
    
    super.readChildren(xr);

    // Now we can correctly set the value.
    setValue(value, defaultValue);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:19,代码来源:SelectOption.java

示例13: readAttributes

import net.sf.freecol.common.io.FreeColXMLReader; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void readAttributes(FreeColXMLReader xr) throws XMLStreamException {
    // ProductionType does not need an id.
    // No need for: super.readAttributes(in);
    // FIXME: as soon as we allow the user to select a production type,
    // we will need an id

    unattended = xr.getAttribute(UNATTENDED_TAG, false);

    productionLevel = xr.getAttribute(PRODUCTION_LEVEL_TAG, (String)null);
    // @compat 0.11.3
    if (productionLevel == null) {
        productionLevel = xr.getAttribute(OLD_PRODUCTION_LEVEL_TAG, (String)null);
    }
    // end @compat 0.11.3
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:20,代码来源:ProductionType.java

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

示例15: readChildren

import net.sf.freecol.common.io.FreeColXMLReader; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void readChildren(FreeColXMLReader xr) throws XMLStreamException {
    // Clear containers.
    if (xr.shouldClearContainers()) {
        effects = null;
    }

    final Specification spec = getSpecification();
    Disaster parent = xr.getType(spec, EXTENDS_TAG, Disaster.class, this);

    if (parent != this && !parent.getEffects().isEmpty()) {
        if (effects == null) effects = new ArrayList<>();
        for (RandomChoice<Effect> choice : parent.getEffects()) {
            Effect effect = new Effect(choice.getObject());
            effect.getFeatureContainer().replaceSource(parent, this);
            addEffect(effect);
        }
    }

    super.readChildren(xr);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:25,代码来源:Disaster.java


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