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


Java FreeColXMLReader.hasAttribute方法代码示例

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


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

示例1: readAttributes

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

    final AIMain aiMain = getAIMain();
    final Specification spec = getSpecification();

    // Delegated from Wish
    transportable = (xr.hasAttribute(TRANSPORTABLE_TAG))
        ? xr.makeAIObject(aiMain, TRANSPORTABLE_TAG,
                          AIGoods.class, (AIGoods)null, true)
        : null;

    goodsType = xr.getType(spec, GOODS_TYPE_TAG,
                           GoodsType.class, (GoodsType)null);

    amountRequested = xr.getAttribute(AMOUNT_REQUESTED_TAG,
                                      GoodsContainer.CARGO_SIZE);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:23,代码来源:GoodsWish.java

示例2: readAttributes

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

    final Specification spec = getSpecification();

    downgrade = xr.getType(spec, DOWNGRADE_TAG,
                           Role.class, (Role)null);

    // @compat 0.11.3
    if (xr.hasAttribute(OLD_EXPERT_UNIT_TAG)) {
        expertUnit = xr.getType(spec, OLD_EXPERT_UNIT_TAG,
                                UnitType.class, (UnitType)null);
    } else
    // end @compat 0.11.3
        expertUnit = xr.getType(spec, EXPERT_UNIT_TAG,
                                UnitType.class, (UnitType)null);

    // @compat 0.11.3
    if (xr.hasAttribute(OLD_MAXIMUM_COUNT_TAG)) {
        maximumCount = xr.getAttribute(OLD_MAXIMUM_COUNT_TAG, 1);
    } else
    // end @compat 0.11.3
        maximumCount = xr.getAttribute(MAXIMUM_COUNT_TAG, 1);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:29,代码来源:Role.java

示例3: readAttributes

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

    final AIMain aiMain = getAIMain();
    final Specification spec = getSpecification();

    // Delegated from Wish
    transportable = (xr.hasAttribute(TRANSPORTABLE_TAG))
        ? xr.makeAIObject(aiMain, TRANSPORTABLE_TAG,
                          AIUnit.class, (AIUnit)null, true)
        : null;

    unitType = xr.getType(spec, UNIT_TYPE_TAG,
                          UnitType.class, (UnitType)null);
    
    expertNeeded = xr.getAttribute(EXPERT_NEEDED_TAG, false);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:22,代码来源:WorkerWish.java

示例4: readAttributes

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

    final AIMain aiMain = getAIMain();

    // Do not use setTarget in serialization
    target = xr.getLocationAttribute(getGame(), TARGET_TAG, false);

    tileImprovementPlan = (xr.hasAttribute(TileImprovementPlan.TAG))
        ? xr.makeAIObject(aiMain, TileImprovementPlan.TAG,
            TileImprovementPlan.class, (TileImprovementPlan)null, true)
        : null;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:18,代码来源:PioneeringMission.java

示例5: readFromXML

import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
 * Initializes this object from an XML-representation of this object,
 * unless the PARTIAL_ATTRIBUTE tag is present which indicates
 * a partial update of an existing object.
 *
 * @param xr The input stream with the XML.
 * @exception XMLStreamException if there are any problems reading
 *     the stream.
 */
public void readFromXML(FreeColXMLReader xr) throws XMLStreamException {
    if (xr.hasAttribute(PARTIAL_ATTRIBUTE_TAG)) {
        readFromXMLPartial(xr);
    } else {
        readAttributes(xr);

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

示例6: readAttributes

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

    modifierType = xr.getAttribute(TYPE_TAG, ModifierType.class,
                                   (ModifierType)null);

    value = xr.getAttribute(VALUE_TAG, UNKNOWN);

    // @compat 0.11.3
    if (xr.hasAttribute(OLD_INCREMENT_TYPE_TAG)) {
        incrementType = xr.getAttribute(OLD_INCREMENT_TYPE_TAG,
                                        ModifierType.class,
                                        (ModifierType)null);
        increment = xr.getAttribute(INCREMENT_TAG, UNKNOWN);
    // end @compat 0.11.3
    } else if (xr.hasAttribute(INCREMENT_TYPE_TAG)) {
        incrementType = xr.getAttribute(INCREMENT_TYPE_TAG,
                                        ModifierType.class,
                                        (ModifierType)null);

        increment = xr.getAttribute(INCREMENT_TAG, UNKNOWN);
    } else {
        incrementType = null;
        increment = 0;
    }

    modifierIndex = xr.getAttribute(INDEX_TAG, DEFAULT_MODIFIER_INDEX);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:33,代码来源:Modifier.java

示例7: readAttributes

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

    final Specification spec = getSpecification();

    type = xr.getType(spec, NATION_TYPE_TAG,
                      NationType.class, (NationType)null);

    selectable = xr.getAttribute(SELECTABLE_TAG, false);

    // @compat 0.11.3
    if (xr.hasAttribute(OLD_PREFERRED_LATITUDE_TAG)) {
        preferredLatitude = xr.getAttribute(OLD_PREFERRED_LATITUDE_TAG, 0);
    } else
    // end @compat 0.11.3
        preferredLatitude = xr.getAttribute(PREFERRED_LATITUDE_TAG, 0);

    // @compat 0.11.3
    if (xr.hasAttribute(OLD_STARTS_ON_EAST_COAST_TAG)) {
        startsOnEastCoast = xr.getAttribute(OLD_STARTS_ON_EAST_COAST_TAG, true);
    } else
    // end @compat 0.11.3
        startsOnEastCoast = xr.getAttribute(STARTS_ON_EAST_COAST_TAG, true);

    refNation = xr.getType(spec, REF_TAG, Nation.class, (Nation)null);

    int rgb = xr.getAttribute(COLOR_TAG, UNDEFINED);
    if (rgb != UNDEFINED) setColor(new Color(rgb));
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:34,代码来源:Nation.java

示例8: readAttributes

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

    name = xr.getAttribute(NAME_TAG, (String)null);

    // @compat 0.11.3
    if (xr.hasAttribute(NAME_KEY_TAG)) {
        key = xr.getAttribute(NAME_KEY_TAG, (String)null);
        key = fixRegionKey(key);
    } else
    // @end compat 0.11.3
        key = xr.getAttribute(KEY_TAG, (String)null);

    type = xr.getAttribute(TYPE_TAG, RegionType.class, (RegionType)null);

    claimable = xr.getAttribute(CLAIMABLE_TAG, false);

    discoverable = xr.getAttribute(DISCOVERABLE_TAG, false);

    scoreValue = xr.getAttribute(SCORE_VALUE_TAG, 0);

    int turn = xr.getAttribute(DISCOVERED_IN_TAG, UNDEFINED);
    discoveredIn = (turn == UNDEFINED) ? null : new Turn(turn);

    discoveredBy = xr.findFreeColGameObject(getGame(), DISCOVERED_BY_TAG,
        Player.class, (Player)null, false);

    parent = xr.makeFreeColObject(getGame(), PARENT_TAG, Region.class, false);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:34,代码来源:Region.java

示例9: readAttributes

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

    final Specification spec = getSpecification();

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

    natural = xr.getAttribute(NATURAL_TAG, parent.natural);

    numberOfEffects = (xr.hasAttribute(EFFECTS_TAG))
        ? xr.getAttribute(EFFECTS_TAG, Effects.class, Effects.ONE)
        : parent.numberOfEffects;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:18,代码来源:Disaster.java

示例10: readAttributes

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

    final Specification spec = getSpecification();

    natural = xr.getAttribute(NATURAL_TAG, false);

    magnitude = xr.getAttribute(MAGNITUDE_TAG, 1);

    addWorkTurns = xr.getAttribute(ADD_WORK_TURNS_TAG, 0);

    requiredImprovementType = xr.getType(spec, REQUIRED_IMPROVEMENT_TAG,
        TileImprovementType.class, (TileImprovementType)null);

    requiredRole = xr.getType(spec, REQUIRED_ROLE_TAG,
        Role.class, (Role)null);
    // @compat 0.11.x
    if (xr.hasAttribute(OLD_EXPENDED_EQUIPMENT_TYPE_TAG)) {
        requiredRole = spec.getRole("model.role.pioneer");
    }
    // end @compat 0.11.x

    expendedAmount = xr.getAttribute(EXPENDED_AMOUNT_TAG, 0);

    movementCost = xr.getAttribute(MOVEMENT_COST_TAG, 0);

    zIndex = xr.getAttribute(ZINDEX_TAG, 0);

    // @compat 0.11.3
    if (xr.hasAttribute(OLD_EXPOSE_RESOURCE_PERCENT_TAG)) {
        exposeResourcePercent = xr.getAttribute(OLD_EXPOSE_RESOURCE_PERCENT_TAG, 0);
    } else
    // end @compat 0.11.3
        exposeResourcePercent = xr.getAttribute(EXPOSE_RESOURCE_PERCENT_TAG, 0);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:40,代码来源:TileImprovementType.java

示例11: 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 (DISASTER_TAG.equals(tag)) {
        Disaster d = xr.getType(spec, ID_ATTRIBUTE_TAG,
                                Disaster.class, (Disaster)null);
        if (d != null) {
            addDisaster(d, xr.getAttribute(PROBABILITY_TAG, 100));
        }
        xr.closeTag(DISASTER_TAG);

    } else if (GEN_TAG.equals(tag)) {
        this.humidity[0] = xr.getAttribute(HUMIDITY_MIN_TAG, 0);
        this.humidity[1] = xr.getAttribute(HUMIDITY_MAX_TAG, 100);
        this.temperature[0] = xr.getAttribute(TEMPERATURE_MIN_TAG, -20);
        this.temperature[1] = xr.getAttribute(TEMPERATURE_MAX_TAG, 40);
        this.altitude[0] = xr.getAttribute(ALTITUDE_MIN_TAG, 0);
        this.altitude[1] = xr.getAttribute(ALTITUDE_MAX_TAG, 0);
        // @compat 0.11.3
        if (xr.hasAttribute(OLD_HUMIDITY_MIN_TAG)) {
            this.humidity[0] = xr.getAttribute(OLD_HUMIDITY_MIN_TAG, 0);
        }
        if (xr.hasAttribute(OLD_HUMIDITY_MAX_TAG)) {
            this.humidity[1] = xr.getAttribute(OLD_HUMIDITY_MAX_TAG, 100);
        }
        if (xr.hasAttribute(OLD_TEMPERATURE_MIN_TAG)) {
            this.temperature[0] = xr.getAttribute(OLD_TEMPERATURE_MIN_TAG, -20);
        }
        if (xr.hasAttribute(OLD_TEMPERATURE_MAX_TAG)) {
            this.temperature[1] = xr.getAttribute(OLD_TEMPERATURE_MAX_TAG, 40);
        }
        if (xr.hasAttribute(OLD_ALTITUDE_MIN_TAG)) {
            this.altitude[0] = xr.getAttribute(OLD_ALTITUDE_MIN_TAG, 0);
        }
        if (xr.hasAttribute(OLD_ALTITUDE_MAX_TAG)) {
            this.altitude[1] = xr.getAttribute(OLD_ALTITUDE_MAX_TAG, 0);
        }
        // end @compat 0.11.3
        xr.closeTag(GEN_TAG);

    } else if (PRODUCTION_TAG.equals(tag)
        && xr.getAttribute(DELETE_TAG, false)) {
        this.productionTypes.clear();
        xr.closeTag(PRODUCTION_TAG);

    } else if (PRODUCTION_TAG.equals(tag)) {
        this.productionTypes.add(new ProductionType(xr, spec));

    } else if (RESOURCE_TAG.equals(tag)) {
        addResourceType(xr.getType(spec, TYPE_TAG, ResourceType.class,
                                   (ResourceType)null),
                        xr.getAttribute(PROBABILITY_TAG, 100));
        xr.closeTag(RESOURCE_TAG);

    // @compat 0.11.x
    // Primary and secondary production was dropped at 0.11.0, but
    // some saved games slipped through.
    } else if (PRIMARY_PRODUCTION_TAG.equals(tag)
        || SECONDARY_PRODUCTION_TAG.equals(tag)) {
        GoodsType type = xr.getType(spec, GOODS_TYPE_TAG,
                                    GoodsType.class, (GoodsType)null);
        int amount = xr.getAttribute(VALUE_TAG, 0);
        ProductionType pt = new ProductionType(null, type, amount);
        pt.setUnattended(true);
        this.productionTypes.add(pt);
        xr.closeTag(tag);
    // @end compat 0.11.x

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

示例12: readAttributes

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

    final Specification spec = getSpecification();
    final Game game = getGame();

    x = xr.getAttribute(X_TAG, 0);

    y = xr.getAttribute(Y_TAG, 0);

    type = xr.getType(spec, TYPE_TAG, TileType.class, (TileType)null);
    if (type == null) { // Unexplored tile.
        style = 0;
        highSeasCount = -1;
        owner = null;
        region = null;
        moveToEurope = null;
        contiguity = -1;
        owningSettlement = null;
        return;
    }

    style = xr.getAttribute(STYLE_TAG, 0);

    String str = xr.getAttribute(CONNECTED_TAG, (String)null);
    if (str == null || str.isEmpty()) {
        highSeasCount = -1;
    } else {
        try {
            highSeasCount = Integer.parseInt(str);
        } catch (NumberFormatException nfe) {
            highSeasCount = -1;
        }
    }

    owner = xr.findFreeColGameObject(game, OWNER_TAG,
                                     Player.class, (Player)null, false);

    region = xr.findFreeColGameObject(game, REGION_TAG,
                                      Region.class, (Region)null, false);
    
    moveToEurope = (xr.hasAttribute(MOVE_TO_EUROPE_TAG))
        ? xr.getAttribute(MOVE_TO_EUROPE_TAG, false)
        : null;

    contiguity = xr.getAttribute(CONTIGUITY_TAG, -1);

    // Tiles are added to the settlement owned tiles list in Map.
    // Doing it here can cause cache weirdness.
    Location loc = xr.getLocationAttribute(game, OWNING_SETTLEMENT_TAG,
                                           true);
    owningSettlement = (loc instanceof Settlement) ? (Settlement)loc
        : null;
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:59,代码来源:Tile.java

示例13: readAttributes

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

    capital = xr.getAttribute(CAPITAL_TAG, capital);

    // @compat 0.11.3
    if (xr.hasAttribute(OLD_MINIMUM_SIZE_TAG)) {
        minimumSize = xr.getAttribute(OLD_MINIMUM_SIZE_TAG, minimumSize);
    } else
    // end @compat 0.11.3
        minimumSize = xr.getAttribute(MINIMUM_SIZE_TAG, minimumSize);

    // @compat 0.11.3
    if (xr.hasAttribute(OLD_MAXIMUM_SIZE_TAG)) {
        maximumSize = xr.getAttribute(OLD_MAXIMUM_SIZE_TAG, maximumSize);
    } else
    // end @compat 0.11.3
        maximumSize = xr.getAttribute(MAXIMUM_SIZE_TAG, maximumSize);

    // @compat 0.11.3
    if (xr.hasAttribute(OLD_VISIBLE_RADIUS_TAG)) {
        visibleRadius = xr.getAttribute(OLD_VISIBLE_RADIUS_TAG, visibleRadius);
    } else
    // end @compat 0.11.3
        visibleRadius = xr.getAttribute(VISIBLE_RADIUS_TAG, visibleRadius);

    // @compat 0.11.3
    if (xr.hasAttribute(OLD_CLAIMABLE_RADIUS_TAG)) {
        claimableRadius = xr.getAttribute(OLD_CLAIMABLE_RADIUS_TAG, claimableRadius);
    } else
    // end @compat 0.11.3
        claimableRadius = xr.getAttribute(CLAIMABLE_RADIUS_TAG, claimableRadius);

    // @compat 0.11.3
    if (xr.hasAttribute(OLD_EXTRA_CLAIMABLE_RADIUS_TAG)) {
        extraClaimableRadius = xr.getAttribute(OLD_EXTRA_CLAIMABLE_RADIUS_TAG, extraClaimableRadius);
    } else
    // end @compat 0.11.3
        extraClaimableRadius = xr.getAttribute(EXTRA_CLAIMABLE_RADIUS_TAG, extraClaimableRadius);

    // @compat 0.11.3
    if (xr.hasAttribute(OLD_WANDERING_RADIUS_TAG)) {
        wanderingRadius = xr.getAttribute(OLD_WANDERING_RADIUS_TAG, wanderingRadius);
    } else
    // end @compat 0.11.3
        wanderingRadius = xr.getAttribute(WANDERING_RADIUS_TAG, wanderingRadius);

    // @compat 0.11.3
    if (xr.hasAttribute(OLD_MINIMUM_GROWTH_TAG)) {
        minimumGrowth = xr.getAttribute(OLD_MINIMUM_GROWTH_TAG, minimumGrowth);
    } else
    // end @compat 0.11.3
        minimumGrowth = xr.getAttribute(MINIMUM_GROWTH_TAG, minimumGrowth);

    // @compat 0.11.3
    if (xr.hasAttribute(OLD_MAXIMUM_GROWTH_TAG)) {
        maximumGrowth = xr.getAttribute(OLD_MAXIMUM_GROWTH_TAG, maximumGrowth);
    } else
    // end @compat 0.11.3
        maximumGrowth = xr.getAttribute(MAXIMUM_GROWTH_TAG, maximumGrowth);

    // @compat 0.11.3
    if (xr.hasAttribute(OLD_TRADE_BONUS_TAG)) {
        tradeBonus = xr.getAttribute(OLD_TRADE_BONUS_TAG, tradeBonus);
    } else
    // end @compat 0.11.3
        tradeBonus = xr.getAttribute(TRADE_BONUS_TAG, tradeBonus);

    // @compat 0.11.3
    if (xr.hasAttribute(OLD_CONVERT_THRESHOLD_TAG)) {
        convertThreshold = xr.getAttribute(OLD_CONVERT_THRESHOLD_TAG, convertThreshold);
    } else
    // end @compat 0.11.3
        convertThreshold = xr.getAttribute(CONVERT_THRESHOLD_TAG, convertThreshold);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:80,代码来源:SettlementType.java


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