本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
}