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


Java FreeColXMLReader.swallowTag方法代碼示例

本文整理匯總了Java中net.sf.freecol.common.io.FreeColXMLReader.swallowTag方法的典型用法代碼示例。如果您正苦於以下問題:Java FreeColXMLReader.swallowTag方法的具體用法?Java FreeColXMLReader.swallowTag怎麽用?Java FreeColXMLReader.swallowTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.sf.freecol.common.io.FreeColXMLReader的用法示例。


在下文中一共展示了FreeColXMLReader.swallowTag方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readChild

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

    // @compat 0.11.0
    if (OLD_EQUIPMENT_TAG.equals(tag)) {
        xr.swallowTag(OLD_EQUIPMENT_TAG);
    // end @compat 0.11.0

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

    } else {
        super.readChild(xr);
    }
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:26,代碼來源:Unit.java

示例2: 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 (CONSUMES_TAG.equals(tag)) {
        addConsumption(xr.getType(spec, ID_ATTRIBUTE_TAG,
                GoodsType.class, (GoodsType)null),
                xr.getAttribute(VALUE_TAG, UNDEFINED));
        xr.closeTag(CONSUMES_TAG);

    // @compat 0.11.0
    } else if (OLD_DEFAULT_EQUIPMENT_TAG.equals(tag)) {
        xr.swallowTag(OLD_DEFAULT_EQUIPMENT_TAG);
    // end @compat 0.11.0

    } else if (DEFAULT_ROLE_TAG.equals(tag)) {
        defaultRole = xr.getType(spec, ID_ATTRIBUTE_TAG,
                Role.class, spec.getDefaultRole());
        xr.closeTag(DEFAULT_ROLE_TAG);

    // @compat 0.11.6
    } else if (DOWNGRADE_TAG.equals(tag) || UPGRADE_TAG.equals(tag)) {
        xr.closeTag(tag, Scope.TAG);
    // end @compat 0.11.6

    } else {
        super.readChild(xr);
    }
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:34,代碼來源:UnitType.java

示例3: 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.swallowTag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。