本文整理汇总了Java中net.sf.freecol.common.io.FreeColXMLReader.readId方法的典型用法代码示例。如果您正苦于以下问题:Java FreeColXMLReader.readId方法的具体用法?Java FreeColXMLReader.readId怎么用?Java FreeColXMLReader.readId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.freecol.common.io.FreeColXMLReader
的用法示例。
在下文中一共展示了FreeColXMLReader.readId方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readChild
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void readChild(FreeColXMLReader xr) throws XMLStreamException {
String optionId = xr.readId();
Option option = getOption(optionId);
if (option == null) {
AbstractOption abstractOption = readOption(xr);
if (abstractOption != null) {
add(abstractOption);
abstractOption.setGroup(this.getId());
}
} else {
// FreeColActions are read here.
option.readFromXML(xr);
}
}
示例2: readChild
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void readChild(FreeColXMLReader xr) throws XMLStreamException {
final String tag = xr.getLocalName();
if (UNIT_TAG.equals(tag)) {
String id = xr.readId();
String type = xr.getAttribute(TYPE_TAG, (String)null);
String roleId = xr.getAttribute(ROLE_TAG,
Specification.DEFAULT_ROLE_ID);
boolean ex = xr.getAttribute(EXPERT_STARTING_UNITS_TAG, false);
addStartingUnit(id, new AbstractUnit(type, roleId, 1), ex);
xr.closeTag(UNIT_TAG);
} else {
super.readChild(xr);
}
}
示例3: 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 (REQUIRED_ABILITY_TAG.equals(tag)) {
String id = xr.readId();
addRequiredAbility(id, xr.getAttribute(VALUE_TAG, true));
spec.addAbility(id);
xr.closeTag(REQUIRED_ABILITY_TAG);
} else if (REQUIRED_GOODS_TAG.equals(tag)) {
GoodsType type = xr.getType(spec, ID_ATTRIBUTE_TAG,
GoodsType.class, (GoodsType)null);
int amount = xr.getAttribute(VALUE_TAG, 0);
addRequiredGoods(new AbstractGoods(type, amount));
xr.closeTag(REQUIRED_GOODS_TAG);
} else if (Limit.TAG.equals(tag)) {
Limit limit = new Limit(xr, spec);
if (limit.getLeftHandSide().getType() == null) {
limit.getLeftHandSide().setType(getId());
}
addLimit(limit);
} else {
super.readChild(xr);
}
}
示例4: readChild
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void readChild(FreeColXMLReader xr) throws XMLStreamException {
final String tag = xr.getLocalName();
final String oid = xr.readId();
try {
Wish wish = null;
// The AI data is quite shallow, so we can get away with
// fixing up forward references just with this simple
// lookup. AIObjects that can be forward referenced must
// ensure they complete initialization somewhere in their
// serialization read* routines.
AIObject aio;
if (oid != null && (aio = getAIObject(oid)) != null) {
aio.readFromXML(xr);
} else if (AIColony.TAG.equals(tag)) {
new AIColony(this, xr);
} else if (AIGoods.TAG.equals(tag)) {
new AIGoods(this, xr);
} else if (AIPlayer.TAG.equals(tag)) {
Player p = getGame().getFreeColGameObject(oid, Player.class);
if (p != null) {
if (p.isIndian()) {
new NativeAIPlayer(this, xr);
} else if (p.isREF()) {
new REFAIPlayer(this, xr);
} else if (p.isEuropean()) {
new EuropeanAIPlayer(this, xr);
} else {
throw new RuntimeException("Bogus AIPlayer: " + p);
}
}
} else if (AIUnit.TAG.equals(tag)) {
new AIUnit(this, xr);
} else if (GoodsWish.TAG.equals(tag)
// @compat 0.11.3
|| OLD_GOODS_WISH_TAG.equals(tag)
// end @compat 0.11.3
) {
wish = new GoodsWish(this, xr);
} else if (TileImprovementPlan.TAG.equals(tag)
// @compat 0.11.3
|| OLD_TILE_IMPROVEMENT_PLAN_TAG.equals(tag)
// end @compat
) {
new TileImprovementPlan(this, xr);
} else if (WorkerWish.TAG.equals(tag)) {
wish = new WorkerWish(this, xr);
} else {
super.readChild(xr);
}
if (wish != null) {
AIColony ac = wish.getDestinationAIColony();
if (ac != null) ac.addWish(wish);
}
} catch (Exception e) {
logger.log(Level.WARNING, "Exception reading AIObject: "
+ tag + ", id=" + oid, e);
// We are hosed. Try to resynchronize at the end of the tag
// or aiMain.
final String mainTag = TAG;
while (xr.moreTags() || !(xr.atTag(tag) || xr.atTag(mainTag)));
}
}
示例5: readFromXML
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
public void readFromXML(AIMain aiMain, FreeColXMLReader xr) throws XMLStreamException {
final Game game = aiMain.getGame();
String tid = xr.readId();
TransportableAIObject tao = null;
if (tid != null) {
AIObject aio = aiMain.getAIObject(tid);
if (aio == null) {
if (tid.startsWith(Unit.TAG)) {
tao = new AIUnit(aiMain, tid);
} else if (tid.startsWith(AIGoods.TAG)) {
tao = new AIGoods(aiMain, tid);
}
} else {
tao = (TransportableAIObject)aio;
}
}
if (tao == null) {
throw new XMLStreamException("Transportable expected: " + tid);
}
this.transportable = tao;
this.carrier = xr.getAttribute(game, CARRIER_TAG,
Unit.class, (Unit)null);
this.tries = xr.getAttribute(TRIES_TAG, 0);
this.spaceLeft = xr.getAttribute(SPACELEFT_TAG, -1);
this.wrapped = null;
this.plan = new CargoPlan();
this.plan.twait = xr.getLocationAttribute(game, TWAIT_TAG, false);
this.plan.cwait = xr.getLocationAttribute(game, CWAIT_TAG, false);
this.plan.cdst = xr.getLocationAttribute(game, CDST_TAG, false);
this.plan.tdst = xr.getLocationAttribute(game, TDST_TAG, false);
this.plan.turns = xr.getAttribute(TURNS_TAG, -1);
this.plan.mode = xr.getAttribute(MODE_TAG,
CargoMode.class, (CargoMode)null);
this.plan.fallback = xr.getAttribute(FALLBACK_TAG, false);
xr.closeTag(TAG);
}
示例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 (CIBOLA_TAG.equals(tag)) {
String cibola = xr.readId();
// @compat 0.11.3
final String oldPrefix = "lostCityRumour.cityName";
if (cibola.startsWith(oldPrefix)) cibola = "nameCache." + cibola;
// end @compat 0.11.3
NameCache.addCityOfCibola(cibola);
xr.closeTag(CIBOLA_TAG);
} else if (Map.TAG.equals(tag)) {
if (this.specification == null) {
throw new XMLStreamException("Tried to read " + tag
+ " with null specification");
}
map = xr.readFreeColObject(game, Map.class);
} else if (NationOptions.TAG.equals(tag)) {
if (this.specification == null) {
throw new XMLStreamException("Tried to read " + tag
+ " with null specification");
}
nationOptions = new NationOptions(xr, specification);
} else if (Player.TAG.equals(tag)) {
if (this.specification == null) {
throw new XMLStreamException("Tried to read " + tag
+ " with null specification");
}
Player player = xr.readFreeColObject(game, Player.class);
if (player.isUnknownEnemy()) {
setUnknownEnemy(player);
} else {
players.add(player);
}
} else if (Specification.TAG.equals(tag)) {
logger.info(((this.specification == null) ? "Loading" : "Reloading")
+ " specification.");
this.specification = new Specification(xr);
} else {
super.readChild(xr);
}
}
示例7: 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);
}
}
}
示例8: UnitTypeChange
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* Read a unit change from a stream.
*
* @param xr The {@code FreeColXMLReader} to read from.
* @exception XMLStreamException if there is a problem reading
* the stream.
*/
public UnitTypeChange(FreeColXMLReader xr, Specification spec)
throws XMLStreamException {
this(xr.readId(), spec);
readFromXML(xr);
}
示例9: readAttributes
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* Reads the attributes of this object from an XML stream.
*
* @param xr The {@code FreeColXMLReader} to read from.
* @exception XMLStreamException if there is a problem reading the stream.
*/
protected void readAttributes(FreeColXMLReader xr) throws XMLStreamException {
String newId = xr.readId();
if (newId != null) setId(newId);
}